CVE-2025-13462 Overview
A vulnerability has been identified in Python's tarfile module where improper normalization of AREGTYPE (\\x00) blocks to DIRTYPE occurs during the processing of multi-block members such as GNUTYPE_LONGNAME or GNUTYPE_LONGLINK. This input validation flaw could allow a crafted tar archive to be misinterpreted by the tarfile module compared to other tar implementations, potentially leading to inconsistent file handling behavior.
Critical Impact
Crafted tar archives may be processed differently by Python's tarfile module compared to other implementations, potentially enabling archive manipulation attacks or extraction to unintended locations.
Affected Products
- Python tarfile module (CPython)
Discovery Timeline
- 2026-03-12 - CVE CVE-2025-13462 published to NVD
- 2026-03-12 - Last updated in NVD database
Technical Details for CVE-2025-13462
Vulnerability Analysis
This vulnerability stems from improper input validation (CWE-20) in Python's tarfile module. The issue occurs when the module processes tar archives containing multi-block extended header entries, specifically GNUTYPE_LONGNAME (used for filenames exceeding 100 characters) and GNUTYPE_LONGLINK (used for long symlink targets). During this processing, the module incorrectly applies normalization of AREGTYPE (\\x00) blocks to DIRTYPE, even when it should not do so within the context of multi-block member handling.
This behavioral inconsistency means that a specially crafted tar archive could be interpreted differently by Python's tarfile module compared to GNU tar, BSD tar, or other tar implementations. Such discrepancies can be leveraged in security-sensitive contexts where multiple systems process the same archive with different behaviors.
Root Cause
The root cause lies in the block type normalization logic within the tarfile module. When parsing tar archive headers, the module normalizes AREGTYPE (represented by a null byte \\x00) to REGTYPE for regular files. However, this normalization continues to apply during multi-block member processing (such as GNU extended headers), where the block type semantics differ. The normalization logic fails to account for the stateful nature of multi-block parsing, leading to incorrect type assignments.
Attack Vector
This vulnerability requires local access to exploit. An attacker would need to craft a malicious tar archive containing specific block sequences that exploit the normalization inconsistency. The attack vector involves:
- Creating a tar archive with GNUTYPE_LONGNAME or GNUTYPE_LONGLINK extended headers
- Including continuation blocks with AREGTYPE (\\x00) type bytes that get incorrectly normalized
- Targeting applications that use Python's tarfile module for archive extraction or inspection
The vulnerability mechanism involves crafting tar archives where continuation blocks within GNU extended header sequences contain null type bytes. When processed by Python's tarfile module, these blocks are incorrectly normalized to DIRTYPE, potentially causing path handling inconsistencies. See the GitHub Issue Discussion for technical details on the parsing behavior.
Detection Methods for CVE-2025-13462
Indicators of Compromise
- Tar archives with unusually structured GNU extended headers containing GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequences
- Extraction results that differ from expected archive contents when compared across different tar implementations
- Applications using tarfile module exhibiting unexpected directory creation or file placement behavior
Detection Strategies
- Implement archive validation using multiple tar implementations before processing with Python's tarfile module
- Review application logs for unexpected file extraction paths or directory structures
- Audit code that processes untrusted tar archives using the tarfile module
- Compare extraction results between Python's tarfile and system tar for critical archives
Monitoring Recommendations
- Monitor file system activity during tar extraction operations for unexpected directory creation
- Implement integrity checks comparing expected vs. actual extraction results
- Log all tar archive processing operations with archive metadata for forensic analysis
- Alert on tar archives containing GNU extended headers from untrusted sources
How to Mitigate CVE-2025-13462
Immediate Actions Required
- Review applications that process untrusted tar archives using Python's tarfile module
- Consider using alternative tar parsing libraries or system tar commands for sensitive operations
- Implement input validation on tar archives before processing
- Apply the patch from the official Python repository once available in your Python version
Patch Information
The Python development team has addressed this vulnerability through a pull request. Organizations should monitor for the fix to be incorporated into official Python releases. For details, see the GitHub Pull Request and the Python Security Announcement.
Workarounds
- Validate tar archives using system tar or alternative implementations before processing with Python
- Implement allowlisting for expected archive structures when processing tar files
- Use extraction filters (introduced in Python 3.12) to limit tarfile extraction behavior
- Avoid processing untrusted tar archives with tarfile module in security-sensitive contexts
For applications requiring immediate mitigation, consider implementing pre-extraction validation:
# Validate tar archive structure using GNU tar before Python processing
tar --list -f archive.tar > /dev/null 2>&1 && echo "Archive validated"
# Use extraction filters in Python 3.12+ for safer defaults
# tarfile.extract(filter='data') or tarfile.extract(filter='tar')
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


