/

CVE-2026-32711

Severity:

HIGH RISK

(7.8)

Path Traversal in pydicom DICOMDIR FileSet Operations

CVE-2026-32711

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Copy and Potential Move/Delete Outside Intended Directory

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal flaw in pydicom allows a malicious DICOMDIR entry to reference files outside the intended File-set root directory.

When a crafted ReferencedFileID is used, FileSet operations such as copy(), write(), and certain remove()+write() flows may read, copy, move, or delete arbitrary files on the filesystem within the privileges of the running process.

Affected context

This vulnerability affects applications that use pydicom versions 2.0.0-rc.1 through 3.0.1 to process DICOMDIR structures and perform FileSet-based file operations.

It becomes relevant when the application:

  • Consumes DICOMDIR files from external or semi-trusted sources
  • Uses pydicom FileSet APIs (e.g., copy(), write(), remove()+write(use_existing=True)) to manage files on disk
  • Assumes that ReferencedFileID entries will always remain under a defined File-set root and does not perform additional path validation

The issue is tied to how pydicom resolves and uses ReferencedFileID paths relative to the File-set root without enforcing directory containment.

Exploit preconditions

  • Attack surface: DICOMDIR parsing and FileSet operations exposed through pydicom.
  • Required access: Ability to provide or influence a DICOMDIR containing malicious ReferencedFileID values (e.g., upload, import, or ingestion of external DICOM media).
  • Trigger point: The application invokes pydicom FileSet methods such as copy(), write(), or remove()+write(use_existing=True) on a FileSet that includes the crafted entries.
  • Why exploitation is possible: pydicom resolves the ReferencedFileID to confirm existence but does not verify that the normalized path remains within the File-set root directory. As a result, paths containing traversal segments or absolute locations can cause file operations to target arbitrary filesystem locations accessible by the process.

Why this happens

The underlying bug is a classic directory traversal issue (CWE-22) in directory and path handling logic.

pydicom treats ReferencedFileID values from DICOMDIR as relative paths intended to live under a specific File-set root, but only checks that the resolved path exists, not that it is still contained within the designated root after resolution.

Without enforcing that the canonical, normalized path remains under the configured root directory, path traversal sequences (such as parent directory references) or crafted paths can escape the intended file tree.

Subsequent FileSet operations trust these unchecked paths and perform file I/O on them, enabling unintended access to files outside the File-set root.

Potential impact

  • Arbitrary file read from locations outside the File-set root, within the permissions of the application process
  • Unauthorized copying of sensitive files to attacker-controlled destinations or export locations
  • In some flows, unintended move or deletion of files outside the File-set root via remove()+write(use_existing=True) or similar operations
  • Indirect escalation of impact if accessed files contain credentials, configuration secrets, or other security-relevant data

General mitigation guidance

Effective mitigation focuses on constraining file paths to an expected root and treating external DICOMDIR content as untrusted input:

  • Normalize and canonicalize all ReferencedFileID-derived paths, then explicitly verify that they remain under the configured File-set root before performing any file I/O.
  • Introduce a strict allowlist policy for accessible directories, rejecting or logging any path that attempts to traverse outside these boundaries.
  • Run applications that process untrusted DICOMDIRs under dedicated, least-privilege accounts with tightly limited filesystem access.
  • Separate storage for imported DICOM media from sensitive directories (e.g., configuration, logs, user data) to minimize the blast radius of any path misuse.
  • Treat all metadata-driven file operations (from DICOMDIR or similar index files) as high risk and apply uniform validation of paths at a single, well-tested abstraction layer.

How teams detect issues like this

Detecting this class of issue and its misuse typically involves both code-level and operational strategies:

  • Static analysis rules or code review checklists that flag file operations constructed from externally supplied or metadata-based paths without:
  • Canonicalization (e.g., resolving ".." and symlinks), and
  • A containment check against a configured root directory
  • Review of FileSet-related code paths to ensure that ReferencedFileID values are treated as untrusted input and validated before use.
  • Logging and monitoring of FileSet operations, including recording the resolved absolute paths for copy(), write(), and remove() operations, then alerting on attempts to access directories outside the configured File-set root.
  • File access monitoring (e.g., OS-level auditing or EDR) for processes handling DICOM files, focusing on unexpected reads or writes to sensitive directories when DICOMDIR processing occurs.

Sources

SourceLink
github.comgithub.com/pydicom/pydicom/commit/6414f01a053dff925578799f5a7208d2ae585e82
github.comgithub.com/pydicom/pydicom/releases/tag/v3.0.2
github.comgithub.com/pydicom/pydicom/security/advisories/GHSA-v856-2rf8-9f28

Frequently asked

questions

It can be, depending on how the application accepts DICOM input. If an attacker can upload or otherwise supply a DICOMDIR file over the network and the server processes it with pydicom FileSet operations, then exploitation can occur remotely within the context of that service.

The attacker must be able to influence or control the DICOMDIR used by the application. This commonly means having the ability to upload or import DICOM media, or to cause the application to open attacker-provided DICOMDIR files from removable media or network locations.

The safest pattern is to treat all paths derived from DICOMDIR ReferencedFileID values as untrusted and enforce a strong directory containment check. Normalize the path, ensure it is anchored under a predefined File-set root, and reject or sanitize any entry that does not meet this constraint before performing file I/O.

Adopt a standard path-handling utility or abstraction that:

  • Always canonicalizes paths derived from external sources
  • Enforces that paths remain under a designated root or allowed directory set
  • Centralizes these checks so that all file operations using user-controlled or metadata-controlled paths must pass through the same validation layer.

Combine this with least-privilege runtime environments and regular security reviews focused on file and path handling.

Find out what's already
exploitable in your codebase.