CVE-2024-6345
📋 TL;DR
This vulnerability in setuptools allows remote code execution when user-controlled URLs are processed by the package_index module. Attackers can inject malicious commands that execute on the system when setuptools downloads packages. Anyone using setuptools versions up to 69.1.1 with untrusted package sources is affected.
💻 Affected Systems
- pypa/setuptools
⚠️ 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 with attacker gaining complete control over the affected system, potentially leading to data theft, ransomware deployment, or lateral movement within the network.
Likely Case
Arbitrary command execution in the context of the user running setuptools, allowing file system access, data exfiltration, and installation of backdoors.
If Mitigated
Limited impact if proper input validation and sandboxing are implemented, potentially only affecting isolated environments.
🎯 Exploit Status
Exploitation requires the attacker to control the URL processed by setuptools. Public proof-of-concept exists in the huntr.com bounty report.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 70.0
Vendor Advisory: https://github.com/pypa/setuptools/commit/88807c7062788254f654ea8c03427adc859321f0
Restart Required: No
Instructions:
1. Upgrade setuptools using pip: 'pip install --upgrade setuptools>=70.0' 2. Verify installation: 'pip show setuptools' should show version 70.0 or higher 3. Update any pinned dependencies in requirements.txt or setup.py
🔧 Temporary Workarounds
Restrict package sources
allConfigure pip/setuptools to only use trusted package repositories and disable processing of arbitrary URLs.
pip config set global.trusted-host pypi.org pypi.python.org files.pythonhosted.org
pip config set global.index-url https://pypi.org/simple/
Sandbox execution
linuxRun setuptools in a restricted environment or container to limit potential damage from exploitation.
docker run --read-only -v /tmp:/tmp:rw python:latest pip install package
🧯 If You Can't Patch
- Implement strict input validation to reject suspicious URLs containing shell metacharacters or unusual patterns
- Run setuptools with minimal privileges using non-root users and restricted filesystem access
🔍 How to Verify
Check if Vulnerable:
Check setuptools version: 'python -c "import setuptools; print(setuptools.__version__)"' - if version is <=69.1.1, system is vulnerable.
Check Version:
python -c "import setuptools; print(setuptools.__version__)"
Verify Fix Applied:
After upgrade, verify version is >=70.0 using same command. Test with known safe package installation to ensure functionality.
📡 Detection & Monitoring
Log Indicators:
- Unusual command execution during package installation
- Setuptools processes accessing unusual URLs or domains
- Error logs showing failed command injection attempts
Network Indicators:
- Setuptools connecting to unusual or suspicious domains for package downloads
- HTTP requests to non-standard PyPI mirrors with unusual parameters
SIEM Query:
process.name:python AND cmdline:*setuptools* AND (cmdline:*http* OR cmdline:*curl* OR cmdline:*wget*) AND NOT domain:pypi.org AND NOT domain:pythonhosted.org
🔗 References
- https://github.com/pypa/setuptools/commit/88807c7062788254f654ea8c03427adc859321f0
- https://huntr.com/bounties/d6362117-ad57-4e83-951f-b8141c6e7ca5
- https://github.com/pypa/setuptools/commit/88807c7062788254f654ea8c03427adc859321f0
- https://huntr.com/bounties/d6362117-ad57-4e83-951f-b8141c6e7ca5
- https://lists.debian.org/debian-lts-announce/2024/09/msg00018.html