GHSA-v856-2rf8-9f28
HIGHpydicom has a path traversal in FileSet/DICOMDIR ReferencedFileID allows file access outside the File-set root
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Blast Radius
pydicom🐍pydicomReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
Summary
A crafted DICOMDIR can set ReferencedFileID to a path outside the File-set root. pydicom resolves the path only to confirm that it exists, but does not verify that the resolved path remains under the File-set root. Subsequent public FileSet operations such as copy(), write(), and remove()+write(use_existing=True) use that unchecked path in file I/O operations. This allows arbitrary file read/copy and, in some flows, move/delete outside the File-set root.
Details
Verified on pydicom 3.1.0.dev0.
Relevant logic is in src/pydicom/fileset.py:
RecordNode._file_idconvertsReferencedFileIDdirectly toPath(...)FileSet.load()checks only(root / file_id).resolve(strict=True)to confirm existenceFileSet.load()does not verify that the final resolved path is contained within the File-set rootFileInstance.pathreturnsself.file_set.path / self.node._file_idFileSet.copy()usesshutil.copyfile(instance.path, dst)FileSet.write()usesPath(instance.path).unlink()andshutil.move(...)
Because there is no containment check such as resolved.relative_to(root.resolve(strict=True)), a malicious DICOMDIR can reference:
- absolute paths such as
/etc/passwd - traversal paths such as
../... - syntactically conformant file IDs that escape via symlinks
This is not limited to obviously invalid VR input. Even when pydicom emits warnings for invalid ReferencedFileID values, the operation is not blocked. I also confirmed a symlink-based variant using a conformant file ID.
A realistic server-side scenario is:
- a user uploads a DICOM File-set zip
- the server loads the uploaded
DICOMDIRusingFileSet - the server re-exports or reorganizes the File-set using
FileSet.copy()orFileSet.write() - a server-local file referenced by the malicious
DICOMDIRis included in the exported result
PoC
Minimal reproduction:
- Copy a sample File-set that contains a valid
DICOMDIR - Modify one
DirectoryRecordSequenceitem so thatReferencedFileID = "/etc/passwd"(or/tmp/secret.txt) - Load it with
FileSet(ds)orFileSet(path_to_dicomdir) - Call
FileSet.copy(new_root) - Observe that the exported File-set contains the contents of the referenced external file
Example:
from pathlib import Path
from tempfile import mkdtemp
import shutil
from pydicom import dcmread
from pydicom.fileset import FileSet
base = Path("src/pydicom/data/test_files/dicomdirtests")
root = Path(mkdtemp(prefix="fsroot_"))
out = Path(mkdtemp(prefix="fsout_"))
shutil.copy2(base / "DICOMDIR", root / "DICOMDIR")
for d in ("77654033", "98892003", "98892001"):
shutil.copytree(base / d, root / d)
ds = dcmread(root / "DICOMDIR")
item = next(x for x in ds.DirectoryRecordSequence if "ReferencedFileID" in x)
item.ReferencedFileID = "/etc/passwd"
fs = FileSet(ds)
fs.copy(out)
I also verified the issue in a simple web import/export demo where an uploaded malicious File-set caused /etc/passwd to be copied into the exported result.
If useful, I can provide the exact malicious sample and the demo environment separately.
Impact
This is a path traversal / root containment bypass in FileSet handling.
Observed impact:
arbitrary file read/copy outside the File-set root via FileSet.copy() arbitrary file move outside the File-set root via FileSet.write() arbitrary file delete outside the File-set root via FileSet.remove(...); write(use_existing=True) Affected applications are those that accept untrusted DICOMDIR / File-set input and then call public FileSet workflows such as load(), copy(), write(), or remove().
A realistic impact is server-side file disclosure in import/export workflows.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | pydicom | ≥ 3.0.0&&< 3.0.2 | 3.0.2 |
| 🐍PyPI | pydicom | all versions | 2.4.5 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for pydicom. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update pydicom to 3.0.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-v856-2rf8-9f28 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-v856-2rf8-9f28 is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-v856-2rf8-9f28. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-v856-2rf8-9f28 in your dependencies?
O3 detects GHSA-v856-2rf8-9f28 across PyPI dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.