CVE-2024-12718
📋 TL;DR
This CVE describes a path traversal vulnerability in Python's tarfile module when using extraction filters. It allows attackers to modify file metadata or permissions outside the intended extraction directory by crafting malicious tar archives. Only Python 3.12+ users extracting untrusted archives with filter='data' or filter='tar' are affected.
💻 Affected Systems
- Python
- Applications using Python's tarfile module
⚠️ Manual Verification Required
This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.
Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).
🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.
- Review the CVE details at NVD
- Check vendor security advisories for your specific version
- Test if the vulnerability is exploitable in your environment
- Consider updating to the latest version as a precaution
⚠️ Risk & Real-World Impact
Worst Case
Attackers could modify critical system files' permissions or timestamps, potentially enabling privilege escalation or disrupting system operations.
Likely Case
Unauthorized modification of file metadata in user-writable directories, potentially affecting application integrity or enabling further attacks.
If Mitigated
Limited to metadata/permission changes without file content modification, with proper sandboxing reducing impact.
🎯 Exploit Status
Exploitation requires crafting a malicious tar archive with path traversal sequences. The vulnerability is well-documented with public proof-of-concept examples.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Python 3.12.9, 3.13.1, and later versions
Vendor Advisory: https://www.python.org/download/releases/security/
Restart Required: No
Instructions:
1. Update Python to version 3.12.9+, 3.13.1+, or latest stable release. 2. For Python 3.14+, ensure you're using the patched version. 3. No application restart needed, but restart Python processes to load updated module.
🔧 Temporary Workarounds
Use filter='fully_trusted'
allSet filter parameter to 'fully_trusted' when extracting archives, which disables the vulnerable filtering behavior.
tar.extractall(path='/target', filter='fully_trusted')
tar.extract(member, path='/target', filter='fully_trusted')
Avoid filter parameter for untrusted archives
allDon't use filter='data' or filter='tar' when extracting untrusted tar archives.
tar.extractall(path='/target') # Omit filter parameter for Python <3.14
tar.extract(member, path='/target')
🧯 If You Can't Patch
- Validate all tar archive paths before extraction to ensure they stay within target directory
- Run tar extraction in isolated containers or sandboxes with restricted filesystem access
🔍 How to Verify
Check if Vulnerable:
Check Python version and tarfile usage: if using Python 3.12-3.13 with filter='data'/'tar', or Python 3.14+ with default filter='data' on untrusted archives.
Check Version:
python --version
Verify Fix Applied:
Verify Python version is 3.12.9+, 3.13.1+, or latest. Test extraction with crafted tar containing '../' paths - should be rejected.
📡 Detection & Monitoring
Log Indicators:
- Failed tar extraction attempts with path traversal errors
- Unexpected file permission or timestamp modifications
Network Indicators:
- Large or unusual tar file uploads to web applications
SIEM Query:
Search for process executions of python with tarfile module usage followed by file metadata changes outside expected directories.
🔗 References
- https://gist.github.com/sethmlarson/52398e33eff261329a0180ac1d54f42f
- https://github.com/python/cpython/commit/19de092debb3d7e832e5672cc2f7b788d35951da
- https://github.com/python/cpython/commit/28463dba112af719df1e8b0391c46787ad756dd9
- https://github.com/python/cpython/commit/3612d8f51741b11f36f8fb0494d79086bac9390a
- https://github.com/python/cpython/commit/4633f3f497b1ff70e4a35b6fe2c907cbe2d4cb2e
- https://github.com/python/cpython/commit/9c1110ef6652687d7c55f590f909720eddde965a
- https://github.com/python/cpython/commit/9e0ac76d96cf80b49055f6d6b9a6763fb9215c2a
- https://github.com/python/cpython/commit/aa9eb5f757ceff461e6e996f12c89e5d9b583b01
- https://github.com/python/cpython/commit/dd8f187d0746da151e0025c51680979ac5b4cfb1
- https://github.com/python/cpython/issues/127987
- https://github.com/python/cpython/issues/135034
- https://github.com/python/cpython/pull/135037
- https://mail.python.org/archives/list/security-announce@python.org/thread/MAXIJJCUUMCL7ATZNDVEGGHUMQMUUKLG/
- https://github.com/python/cpython/issues/127987