CVE-2026-4360: Python Tarfile Hardlink Filter Bypass – Privilege Escalation Risk
CVE-2026-4360 is a vulnerability in Python's tarfile extraction mechanism where the security filter parameter is bypassed when extracting hardlinks from tar archives. When a developer uses the `filter='data'` parameter—intended to restrict file ownership changes—the filter is not applied to hardlinks, allowing an attacker to craft a malicious tar file that assigns unexpected user and group identifiers (uid/gid) to extracted files. This could lead to privilege escalation or file ownership manipulation on systems processing untrusted archives.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 5.3 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
- Weaknesses (CWE)
- CWE-281
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-30 / 2026-08-06
NVD description (verbatim)
In the Tarfile.extract() function, the filter parameter is not passed properly when extracting hardlinks. An affected system that extracts content from untrusted tar files could end up writing files with an unexpected uid/gid despite the user passing filter='data' to the extract() function.
10 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability exists in the Tarfile.extract() function where the filter parameter enforcement fails for hardlink entries. When extracting tar archives, the filter mechanism is designed to sanitize metadata including file ownership. However, the code path handling hardlinks does not invoke the filter logic, creating a bypass. An attacker crafting a tar file with hardlinks pointing to existing files can assign arbitrary uid/gid values that persist after extraction, circumventing the intended data-only extraction policy. The issue is classified under CWE-281 (Improper Preservation of Permissions), reflecting the loss of security context during file operations.
Business impact
Organizations that automatically process or extract tar archives from external sources face elevated risk. This includes build pipelines extracting dependencies, container image layers, software distribution systems, and backup restoration workflows. If an attacker injects a malicious tar with hardlinks, they can manipulate file ownership to facilitate subsequent privilege escalation, cross-tenant data access, or lateral movement. The impact is especially severe in multi-tenant or shared hosting environments where uid/gid misalignment could bridge security boundaries.
Affected systems
Python implementations using the tarfile module's extract() or extractall() methods are affected. The vulnerability applies to any system relying on Python's tarfile module to process untrusted tar archives, regardless of platform (Linux, Unix, macOS, or Windows with Python). Systems explicitly using filter parameters for security hardening are at higher risk because they expect the filter to be enforced consistently.
Exploitability
Exploitation requires crafting a specially-formed tar archive containing hardlinks with malicious uid/gid metadata. No authentication or local access is required; the attacker need only supply the tar file to a vulnerable extraction process. The attack surface is broad for any service accepting tar uploads or automatically extracting them (e.g., CI/CD systems, package managers, backup tools). However, successful exploitation depends on the extraction process running with elevated privileges or in a context where uid/gid changes are meaningful.
Remediation
Apply security updates from the Python project as they become available. Review and prioritize patching for systems that: (1) extract tar archives from untrusted sources, (2) use explicit filter parameters expecting them to be enforced, or (3) operate in multi-tenant environments. In the interim, validate tar archive contents before extraction, use isolated extraction environments with minimal privileges, and monitor file ownership changes in critical directories.
Patch guidance
Check the official Python security advisory and release notes for patched versions of the tarfile module. Updates will likely be backported to supported Python versions (verify against the vendor advisory for exact version numbers). Test patches in a staging environment before deployment, especially for systems with complex tarfile processing pipelines. Consider using tarfile source inspection tools to pre-validate archives before extraction as a compensating control.
Detection guidance
Monitor systems for unexpected file ownership changes (uid/gid modifications) following tar extraction operations. Log and alert on Tarfile.extract() calls processing untrusted sources, particularly those without explicit filter parameters. Audit tar archives for hardlink entries pointing to files with mismatched ownership metadata. In containerized environments, inspect container image layers and build artifacts for suspicious ownership patterns in hardlinked files.
Why prioritize this
While the CVSS score (5.3 MEDIUM) reflects limited direct impact, the vulnerability should be prioritized based on deployment context. Organizations extracting untrusted tar files automatically (CI/CD, package management, container registries) should treat this as HIGH priority. The bypass of intentional security controls makes this a trust boundary violation. Systems with strict privilege separation or those handling sensitive data should patch ahead of non-critical infrastructure.
Risk score, explained
The CVSS 3.1 score of 5.3 (MEDIUM) reflects a network-exploitable vulnerability with low complexity, no privileges or user interaction required, and confidentiality unaffected. The integrity impact is rated LOW because successful exploitation requires specific conditions (hardlinks, elevated extraction context) and does not guarantee widespread file corruption. However, the contextual risk is higher in build pipelines and multi-tenant systems where uid/gid control is a critical security boundary.
Frequently asked questions
Does this vulnerability affect systems that only extract tar files from trusted internal sources?
Likely not, provided the trust boundary is rigorously enforced. The vulnerability requires a maliciously crafted tar file. If your extraction pipeline only processes archives from verified internal builds, risk is minimal. However, if there is any possibility of tar contamination (supply chain, caching, shared storage), you should still patch.
Can I work around this vulnerability without patching?
Partial mitigation is possible: avoid extracting tar files with elevated privileges, use separate user accounts for extraction with minimal permissions, and pre-inspect tar archives for unexpected hardlink ownership metadata before extraction. These are not substitutes for patching but reduce the attack surface while you plan updates.
Does the filter parameter protect against other tar extraction attacks?
The filter parameter is designed to prevent path traversal and unsafe metadata changes. This vulnerability represents a gap in that protection for hardlinks specifically. Patching ensures the filter is applied consistently across all entry types.
What should I do if I suspect malicious tar files were extracted on my systems?
Audit file ownership in affected directories, especially for files owned by unexpected uid/gid values. Review access logs for privilege escalation attempts originating from those files. Consider imaging affected systems for forensic analysis if data sensitivity is high. Apply the patch immediately and re-extract archives from clean sources.
This analysis is provided for informational purposes and reflects publicly available vulnerability data as of the publication date. Security context and risk vary by deployment; prioritize patching based on your own threat model and system criticality. Consult the official Python security advisory for authoritative patch guidance and version numbers. SEC.co does not provide guarantee regarding vulnerability impact in specific environments. Always test patches in non-production before deployment. Source: NVD (public-domain), retrieved 2026-08-09. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-58494MEDIUMWasmtime WASI FilePerms Bypass Allows Read-Only File Overwrite
- CVE-2026-55798MEDIUMPillow Windows Command Injection Vulnerability (CVSS 4.5)
- CVE-2026-59890MEDIUMsetuptools Unicode Normalization Bypass on macOS
- CVE-2026-15308HIGHPython HTML Parser CPU DoS Vulnerability – HIGH Severity
- CVE-2026-54059HIGHPillow PCF Font Memory Exhaustion DoS Vulnerability
- CVE-2026-54060HIGHPillow Font Memory Exhaustion (CVSS 7.5)
- CVE-2026-55379HIGHPillow BDF Font Decompression Bomb Memory Exhaustion (CVSS 7.5)
- CVE-2026-55380HIGHPillow GD Image Decompression Bomb Denial of Service