Listen to this Post
This vulnerability exists in the MONAI framework’s `_download_from_ngc_private()` function. When downloading and extracting a bundle from a private NVIDIA NGC repository, the function uses Python’s `zipfile.ZipFile.extractall()` method without validating the paths of files within the archive. This insecure pattern is known as “Zip Slip” or path traversal. An attacker who controls or compromises a private NGC repository can craft a malicious ZIP archive containing filenames with path traversal sequences, such as ../../../etc/passwd. During extraction, the vulnerable code does not check if the final extraction path remains within the intended target directory. Consequently, files can be written to arbitrary locations on the victim’s filesystem, depending on the permissions of the process running MONAI. This is an oversight because MONAI already implements a secure `safe_extract_member()` function in its `utils.py` module, which is correctly used by other download functions in the same codebase (_download_from_github, _download_from_monaihosting). The safe function explicitly checks for absolute paths and parent directory (..) sequences, preventing escape from the extraction root.
dailycve
Platform: MONAI
Version: Not specified
Vulnerability : Path Traversal
Severity: Critical
date: 2024-10-02
Prediction: Patch 2024-11-15
What Undercode Say:
Analytics:
find . -name ".py" -exec grep -l "extractall" {} \;
python3 -c "import zipfile, os; z=zipfile.ZipFile('mal.zip','w'); z.writestr('../../test.txt','pwned'); z.close()"
Create malicious zip (PoC Step 1)
import zipfile, io
zf = zipfile.ZipFile(io.BytesIO(), 'w')
zf.writestr('../../../tmp/exploit', 'data')
with open('bad.zip','wb') as f: f.write(zf.fp.getvalue())
Vulnerable extraction simulation
with zipfile.ZipFile('bad.zip') as z: z.extractall('/tmp/safe_dir')
How Exploit:
1. Attacker crafts malicious ZIP archive.
- Hosts it on a compromised private NGC repo.
3. Victim uses `_download_from_ngc_private()`.
4. Malicious files escape extraction directory.
Protection from this CVE:
Replace vulnerable `z.extractall(extract_path)` call with MONAI’s existing `_extract_zip()` or `safe_extract_member()` function.
Impact:
Arbitrary File Write. Potential Remote Code Execution. System Compromise.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

