Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
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.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2025-4138_tarfile_filter_bypass — CVE-2025-4138 - Python Arbitrary file write outside extraction directory | Kitploit
Tools/GitHubGitHub/thefizzyfish/cve-2025-4138_tarfile_filter_bypass
Payload GenerationVulnerability AnalysisExploitationWeb Application ExploitationCTFPenetration Testing
GitHubthefizzyfish/cve-2025-4138_tarfile_filter_bypass

CVE-2025-4138_tarfile_filter_bypass

CVE-2025-4138 - Python Arbitrary file write outside extraction directory

View Repository
3469 months agoNot yet reviewed
Share

CVE-2025-4138 — Python tarfile filter="data" Bypass

Arbitrary file write outside the extraction directory via PATH_MAX symlink chain.

Affected Versions

  • Python 3.12.0 – 3.12.10
  • Python 3.13.0 – 3.13.3
  • Fixed in 3.12.11 / 3.13.4

Credit:

Reporter: Caleb Brown (Google)

How It Works

Python's tarfile data filter validates symlink targets using os.path.realpath(). When the resolved path exceeds PATH_MAX (4096 bytes on Linux), realpath() silently stops resolving and appends remaining components — including ../ — as literal strings. The filter sees a safe path; the kernel follows the real traversal.

The exploit builds a tar with four stages:

  1. Symlink chain — 16 levels of long directories (247 chars each) with short symlink aliases (a→ddd..., b→ddd...). Inflates the resolved path to ~3968 bytes.
  2. Pivot symlink — ../ × 16 at the end of the chain. realpath() overflows and can't resolve it. Kernel walks back to the extraction root.
  3. Escape symlink — Routes through the pivot, up to /, and down to the target directory.
  4. Payload file — Written through the escape symlink to the target path as root.

Usage

To add/replace authorized_keys for root user

Create SSH key in /tmp

ssh-keygen -t ed25519 -f /tmp/key -N ""

Create evil.tar file

python3 CVE-2025-4138_tarfile_filter_bypass.py \
    -o evil.tar \
    -t /root/.ssh/authorized_keys \
    -p /tmp/key.pub \
    -m 0600
FlagDescription
-oOutput tar path
-tAbsolute path of file to write on target
-pLocal file to use as payload content
-mOctal file permissions (default: 0644)

References

  • NVD — CVE-2025-4138
  • GHSA-hgqp-3mmf-7h8f

For authorized security testing and CTF use only.

Download Tool

Most Popular

View all →

Discover the most used tools by our community.

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 The ultimate OSINT toolkit: investigation graph, confidence scoring, alias families, map, timeline and reports. 49 modules, 400+ sites, no API keys required.

    891
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock One-Tap Execution App (CVE-2026-43499)

    547
  • 3

    ARTEX

    baarai/artex

    LLM multi-agent autonomous penetration testing platform with planner/worker agents, asset and exploration graphs, MITM traffic recording, and vulnerability retesting.

    369
  • 4

    redforge

    cybersecurity91/redforge

    Browser-side red team toolkit with 102 offline tools for recon, payload generation, credential attacks, crypto, encoding and engagement reporting.

    366
  • 5

    looking-glass

    anonghosty/looking-glass

    CSIRT platform that ingests Shadowserver reports into MongoDB and replays them as interactive maps, analysis, findings, advisories and executive dashboards.

    309
  • 6

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    The system of action for AI-native cybersecurity—where intent becomes governed execution, evidence becomes operational memory, and every operation improves the next.

    282

Explore all tools

Browse our collection of tools

View all tools →