CVE-2025-4517
📋 TL;DR
This vulnerability in Python's tarfile module allows attackers to write arbitrary files outside the intended extraction directory when extracting untrusted tar archives using the 'data' or 'tar' filter parameters. It affects Python applications that extract tar files from untrusted sources, particularly those using Python 3.14+ where 'data' became the default filter.
💻 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
Full system compromise via arbitrary file overwrite leading to remote code execution, privilege escalation, or data destruction.
Likely Case
Arbitrary file writes leading to web shell deployment, configuration file modification, or data corruption.
If Mitigated
Limited impact if only trusted archives are processed or proper sandboxing is implemented.
🎯 Exploit Status
Exploitation requires only a malicious tar archive and vulnerable tarfile extraction code. The GitHub references contain technical details.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Python versions with fixes from the referenced commits
Vendor Advisory: https://gist.github.com/sethmlarson/52398e33eff261329a0180ac1d54f42f
Restart Required: No
Instructions:
1. Update Python to version containing fixes from referenced commits. 2. For Python 3.14+, ensure filter='none' is used for untrusted archives. 3. Apply patches from Python's GitHub repository if updating is not possible.
🔧 Temporary Workarounds
Use filter='none' for untrusted archives
allExplicitly set filter='none' when extracting untrusted tar archives to disable the vulnerable filtering behavior.
tar.extractall(path='/safe/path', filter='none')
tar.extract(member, path='/safe/path', filter='none')
Sandbox extraction directory
allExtract archives to isolated, restricted directories with minimal permissions.
🧯 If You Can't Patch
- Avoid extracting untrusted tar archives entirely
- Implement strict input validation and only process archives from trusted sources
🔍 How to Verify
Check if Vulnerable:
Check Python code for tarfile.extractall() or tarfile.extract() calls with filter='data' or filter='tar', or no filter parameter on Python 3.14+.
Check Version:
python --version
Verify Fix Applied:
Verify Python version includes fixes from referenced commits and code uses filter='none' for untrusted archives.
📡 Detection & Monitoring
Log Indicators:
- Unexpected file writes outside extraction directories
- Tar extraction errors or warnings
Network Indicators:
- Inbound tar file uploads to vulnerable endpoints
SIEM Query:
Search for process execution of python with tarfile operations or file writes in unexpected locations.
🔗 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/135034
- https://github.com/python/cpython/pull/135037
- https://mail.python.org/archives/list/security-announce@python.org/thread/MAXIJJCUUMCL7ATZNDVEGGHUMQMUUKLG/