CVE-2025-8194

Tarfile infinite loop during parsing with negative member offset

Published Jul 28, 2025 CVSS 3.1 · 7.5 High EPSS 1.4% KEV · Not listed
Description
There is a defect in the CPython “tarfile” module affecting the “TarFile” extraction and entry enumeration APIs. The tar implementation would process tar archives with negative offsets without error, resulting in an infinite loop and deadlock during the parsing of maliciously crafted tar archives.

This vulnerability can be mitigated by including the following patch after importing the “tarfile” module:  https://gist.github.com/sethmlarson/1716ac5b82b73dbcbf23ad2eff8b33e1

Analysis

AI-generated

Technical impact

The vulnerability resides in CPython’s tarfile module, where parsing a tar archive with a negative member offset triggers an infinite loop and deadlock in the extraction and enumeration APIs. The flaw does not disclose data but prevents the process from completing, effectively hanging the application that attempts to read or list the archive. The severity of the denial of service is reflected in a CVSS score of 7.5 and a CWE‐835 classification of infinite loop.

Affected Systems

Python Software Foundation CPython is the affected product. All CPython releases that include the unpatched tarfile implementation are vulnerable, as the security advisory does not specify a limited version set. Systems running Python and using tarfile to extract or inspect uploaded archives are at risk.

Risk and Exploitability

Although the exploit requires crafting a malicious tar archive, it can be achieved by an attacker who can trigger tarfile processing – potentially via a file upload interface, command‑line operations, or automated extraction tasks. The EPSS score of less than 1% indicates a low current exploitation probability, and the vulnerability is not listed in the CISA KEV catalog, suggesting no known widespread exploitation at the time of analysis. Still, the infinite loop can consume CPU resources until the process is killed, allowing an attacker to force a denial of service on the target system.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the patch provided in the official advisory, such as the code snippet linked in the vulnerability description, immediately after any import of the tarfile module
  • Upgrade to a CPython release that contains the committed fix (see the referenced GitHub commits and pull request that address the issue)
  • If an upgrade is not feasible, neutralize the attack surface by rejecting tar archives with negative offsets or validating archive offsets before processing, thereby preventing the infinite loop condition.

Generated by OpenCVE AI on April 22, 2026 at 11:26 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4445-1 python3.9 security update
EUVD EUVD EUVD-2025-22999 There is a defect in the CPython “tarfile” module affecting the “TarFile” extraction and entry enumeration APIs. The tar implementation would process tar archives with negative offsets without error, resulting in an infinite loop and deadlock during the parsing of maliciously crafted tar archives. This vulnerability can be mitigated by including the following patch after importing the “tarfile” module:  https://gist.github.com/sethmlarson/1716ac5b82b73dbcbf23ad2eff8b33e1
Ubuntu USN Ubuntu USN USN-7710-1 Python vulnerabilities
Ubuntu USN Ubuntu USN USN-7710-2 Python 2.7 vulnerability
History
Type Values Removed Values Added
Description There is a defect in the CPython “tarfile” module affecting the “TarFile” extraction and entry enumeration APIs. The tar implementation would process tar archives with negative offsets without error, resulting in an infinite loop and deadlock during the parsing of maliciously crafted tar archives. This vulnerability can be mitigated by including the following patch after importing the “tarfile” module: import tarfile def _block_patched(self, count):     if count < 0: # pragma: no cover         raise tarfile.InvalidHeaderError("invalid offset")     return _block_patched._orig_block(self, count) _block_patched._orig_block = tarfile.TarInfo._block tarfile.TarInfo._block = _block_patched There is a defect in the CPython “tarfile” module affecting the “TarFile” extraction and entry enumeration APIs. The tar implementation would process tar archives with negative offsets without error, resulting in an infinite loop and deadlock during the parsing of maliciously crafted tar archives. This vulnerability can be mitigated by including the following patch after importing the “tarfile” module:  https://gist.github.com/sethmlarson/1716ac5b82b73dbcbf23ad2eff8b33e1
References
Type Values Removed Values Added
First Time appeared Python
Python cpython
Vendors & Products Python
Python cpython
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description There is a defect in the CPython “tarfile” module affecting the “TarFile” extraction and entry enumeration APIs. The tar implementation would process tar archives with negative offsets without error, resulting in an infinite loop and deadlock during the parsing of maliciously crafted tar archives. This vulnerability can be mitigated by including the following patch after importing the “tarfile” module: import tarfile def _block_patched(self, count):     if count < 0: # pragma: no cover         raise tarfile.InvalidHeaderError("invalid offset")     return _block_patched._orig_block(self, count) _block_patched._orig_block = tarfile.TarInfo._block tarfile.TarInfo._block = _block_patched
Title Tarfile infinite loop during parsing with negative member offset
Weaknesses CWE-835
References
Metrics cvssV3_1

{'score': 7.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H'}

Weaknesses
  • CWE-835

    Loop with Unreachable Exit Condition ('Infinite Loop')

Sources

Status
PUBLISHED
Assigner
PSF
Published
Updated
Jul 31, 2026, 2:01 PM
Reserved
Jul 25, 2025, 2:05 PM
Status
Deferred
Published
Jul 28, 2025, 7:15 PM
Modified
Jul 31, 2026, 2:16 PM
Severity
Moderate
Public date
Jul 28, 2025, 6:42 PM