CVE-2025-4138

HIGH

CPython Path Traversal via TarFile Extraction Filter Bypass

Title source: llm
STIX 2.1

Exploitation Summary

EIP tracks 6 public exploits for CVE-2025-4138. PoCs published by DesertDemons, thefizzyfish, run3.

AI-analyzed exploit summary This repository contains a proof-of-concept exploit for CVE-2025-4138 and CVE-2025-4517, which involve a path traversal vulnerability in Python's tarfile module. The exploit bypasses extraction filters via a symlink chain that exceeds PATH_MAX, enabling arbitrary file writes and potential privilege escalation.

Description

Allows the extraction filter to be ignored, allowing symlink targets to point outside the destination directory, and the modification of some file metadata. You are affected by this vulnerability if using the tarfile module to extract untrusted tar archives using TarFile.extractall() or TarFile.extract() using the filter= parameter with a value of "data" or "tar". See the tarfile extraction filters documentation https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter  for more information. Note that for Python 3.14 or later the default value of filter= changed from "no filtering" to `"data", so if you are relying on this new default behavior then your usage is also affected. Note that none of these vulnerabilities significantly affect the installation of source distributions which are tar archives as source distributions already allow arbitrary code execution during the build process. However when evaluating source distributions it's important to avoid installing source distributions with suspicious links.

Exploits (6)

nomisec WORKING POC 7 stars
by DesertDemons · poc
https://github.com/DesertDemons/CVE-2025-4138-4517-POC

This repository contains a proof-of-concept exploit for CVE-2025-4138 and CVE-2025-4517, which involve a path traversal vulnerability in Python's tarfile module. The exploit bypasses extraction filters via a symlink chain that exceeds PATH_MAX, enabling arbitrary file writes and potential privilege escalation.

Classification
Working Poc 95%
Attack Type
Lpe
Complexity
Moderate
Reliability
Reliable
Target: Python 3.12.0-3.12.10, 3.13.0-3.13.3
No auth needed
Prerequisites: Vulnerable Python version · Application using tarfile.extractall() with filter='data' or filter='tar'
devstral-2 · analyzed Feb 16, 2026 Full analysis →
nomisec WORKING POC 1 stars
by thefizzyfish · poc
https://github.com/thefizzyfish/CVE-2025-4138_tarfile_filter_bypass

This repository contains a functional exploit for CVE-2025-4138, which bypasses Python's tarfile filter by leveraging a PATH_MAX symlink chain to achieve arbitrary file write outside the extraction directory. The exploit constructs a malicious tar file with a series of symlinks that overflow the path resolution buffer, allowing an attacker to write files to arbitrary locations on the target system.

Classification
Working Poc 100%
Attack Type
Other
Complexity
Moderate
Reliability
Reliable
Target: Python tarfile module (versions 3.12.0-3.12.10, 3.13.0-3.13.3)
No auth needed
Prerequisites: Ability to deliver a malicious tar file to the target system · Target system must use Python's tarfile module with filter='data'
devstral-2 · analyzed Feb 19, 2026 Full analysis →
gitlab WORKING POC
by run3 · poc
https://gitlab.com/run3/test

This exploit leverages a tar symlink path traversal vulnerability (CVE-2025-4138) to escape directory restrictions and overwrite /root/.ssh/authorized_keys, achieving root RCE via SSH. The PoC automates key generation, malicious tar creation, and exploit triggering.

Classification
Working Poc 95%
Attack Type
Lpe
Complexity
Moderate
Reliability
Reliable
Target: Unknown backup restoration script (likely custom software)
Auth required
Prerequisites: sudo access to vulnerable restoration script · write access to /opt/backup_clients/backups/
devstral-2 · analyzed Feb 23, 2026 Full analysis →
nomisec WORKING POC
by d3vn0mi · poc
https://github.com/d3vn0mi/CVE-2025-4138-POC

This repository contains a functional exploit PoC for CVE-2025-4138, a path traversal vulnerability in Python's `tarfile` module. The exploit leverages symlink chains to exceed `PATH_MAX`, bypassing safety checks and enabling arbitrary file writes outside the extraction directory.

Classification
Working Poc 95%
Attack Type
Other
Complexity
Moderate
Reliability
Reliable
Target: Python tarfile module
No auth needed
Prerequisites: Python 3 standard library · ability to deliver a malicious tar archive to the target
devstral-2 · analyzed Apr 09, 2026 Full analysis →
nomisec WORKING POC
by localh0ste · poc
https://github.com/localh0ste/CVE-2025-4138

This repository contains a functional exploit for CVE-2025-4138, a directory traversal vulnerability in Python's TarFile module. The exploit leverages symlinks and path manipulation to bypass PATH_MAX checks, allowing arbitrary file writes (e.g., SSH authorized_keys) for privilege escalation.

Classification
Working Poc 95%
Attack Type
Lpe
Complexity
Moderate
Reliability
Reliable
Target: Python TarFile module (versions affected by CVE-2025-4138)
No auth needed
Prerequisites: Ability to execute Python code on the target system · Write access to a directory where the malicious tar file can be extracted
devstral-2 · analyzed Feb 18, 2026 Full analysis →
nomisec WORKING POC
by kyakei · poc
https://github.com/kyakei/CVE-2025-4138-poc

This repository contains a functional Python script that generates a malicious tar archive exploiting CVE-2025-4138 (Path Traversal via PATH_MAX Truncation in Python's tarfile module). The exploit creates a symlink chain to bypass path resolution checks and writes a sudoers file to grant passwordless root access.

Classification
Working Poc 95%
Attack Type
Lpe
Complexity
Moderate
Reliability
Reliable
Target: Python 3.12.0–3.12.10, 3.13.0–3.13.3
No auth needed
Prerequisites: Access to a system with a vulnerable Python version · Ability to transfer and extract the malicious tar file
devstral-2 · analyzed Feb 18, 2026 Full analysis →

Scores

CVSS v3 7.5
EPSS 0.0111
EPSS Percentile 61.5%
Attack Vector NETWORK
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

CISA SSVC

Vulnrichment
Exploitation none
Automatable yes
Technical Impact partial

Details

CWE
CWE-22
Status published
Products (7)
Python Software Foundation/CPython < 3.10.18
Python Software Foundation/CPython < 3.9.23
Python Software Foundation/CPython 3.10.0 - 3.10.18
Python Software Foundation/CPython 3.11.0 - 3.11.13
Python Software Foundation/CPython 3.12.0 - 3.12.11
Python Software Foundation/CPython 3.13.0 - 3.13.4
Python Software Foundation/CPython 3.14.0a1 - 3.14.0b3
Published Jun 03, 2025
Tracked Since Feb 18, 2026