MEDIUM 5.4

CVE-2026-29509: Patool Path Traversal Vulnerability (Arbitrary File Write)

Patool, a popular archive extraction utility, contains a flaw in how it validates whether extracted files stay within their intended directory. An attacker can craft a malicious archive with specially named files that trick the validation check and write files anywhere on the system. The vulnerability only affects systems running Python versions before 3.12. While the immediate impact is limited by the need for user interaction (the user must extract the archive), this is a classic arbitrary file write scenario that could lead to code execution or system compromise depending on file placement and permissions.

Source data · NVD / CISA · public domain

CVSS
3.1 · 5.4 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
Weaknesses (CWE)
CWE-22
Affected products
0 configuration(s)
Published / Modified
2026-06-26 / 2026-07-14

NVD description (verbatim)

Patool before 4.0.5 contains a path traversal vulnerability in the safe_extract() function in patoolib/programs/py_tarfile.py when running on Python before 3.12, where the is_within_directory() helper uses os.path.commonprefix() for character-level string comparison instead of path-level comparison, allowing a crafted archive member path to bypass the containment check. Attackers can supply a malicious archive with specially crafted member paths to write arbitrary files.

3 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability exists in the safe_extract() function within patoolib/programs/py_tarfile.py. The is_within_directory() helper function uses os.path.commonprefix() for validation, which performs character-level string comparison rather than proper path-level comparison. This allows a carefully crafted archive member path to bypass the containment check. For example, a path like '/opt/appdata/' and '/opt/app_backdoor/exploit.sh' share the prefix '/opt/app' at the character level, potentially satisfying a flawed prefix check while actually pointing outside the intended extraction directory. The issue manifests only on Python versions before 3.12, suggesting that later Python versions may have introduced safer path handling or that Patool's code paths differ under 3.12+.

Business impact

Successful exploitation could allow an attacker to place executable files, configuration files, or libraries in critical system locations, potentially leading to privilege escalation, persistent backdoor installation, or application compromise. The real-world risk depends on the privileges of the user extracting archives and the trust model of your organization. If users routinely extract archives from untrusted sources, or if automated tools extract archives without proper sandboxing, this represents a material supply-chain or user-action vector. The medium CVSS score reflects the requirement for user interaction, but the outcome (arbitrary file write) can be severe.

Affected systems

Patool versions prior to 4.0.5 are affected when running on Python 3.11 or earlier. Systems running Python 3.12 or later are not vulnerable. This includes any deployment where Patool is used as a library or command-line tool for archive extraction on legacy Python environments. Both standalone Patool installations and those bundled with other applications should be assessed.

Exploitability

Exploitability is straightforward in terms of attack complexity—an attacker simply needs to craft a malicious archive with path traversal payloads and distribute it. However, the attack requires user action: someone must actively extract or process the archive. There is no known public exploit code, and the vulnerability has not been added to the CISA Known Exploited Vulnerabilities catalog, meaning in-the-wild exploitation has not been formally documented at this time. This does not eliminate the risk; it reflects the relatively recent publication and the niche role of Patool in many environments.

Remediation

Upgrade Patool to version 4.0.5 or later. Alternatively, upgrade to Python 3.12 or higher if feasible, as the vulnerability does not manifest in that environment. Until patching is complete, implement procedural controls: disable or restrict archive extraction from untrusted sources, use sandboxed extraction environments, and educate users to avoid extracting archives from unknown origins.

Patch guidance

Check your current Patool version with 'patool --version' and your Python version with 'python --version'. If you are on Patool versions earlier than 4.0.5 and Python 3.11 or earlier, plan an immediate upgrade to Patool 4.0.5 or later. Verify the upgrade by re-checking the version after installation. If upgrading Patool is not feasible in the short term, consider upgrading Python to 3.12+ as a workaround. Test the patched version in a non-production environment first, particularly if Patool is integrated into automated workflows or critical processes.

Detection guidance

Monitor for unusual file creation events outside expected directories when Patool or archive extraction tools are invoked. Look for archive files with suspicious member paths containing patterns like '../', '..\', or path segments that reference parent directories. Log archive extraction activities and correlate them with unexpected file writes. If you have access to Patool source or logs, inspect the safe_extract() function call paths and the is_within_directory() validation for any bypass indicators. Consider baseline monitoring of file system changes immediately following archive processing.

Why prioritize this

This vulnerability merits prompt but not emergency attention. The medium CVSS score and requirement for user interaction lower the immediate risk compared to unauthenticated remote code execution flaws. However, path traversal leading to arbitrary file write is a classic privilege-escalation or persistence vector. Prioritize patching if: (1) your organization regularly handles archives from external sources, (2) users have privileges to write to sensitive directories, or (3) Patool is part of an automated CI/CD or data processing pipeline. For isolated environments or airgapped systems where archive extraction is tightly controlled, priority can be lower but should not be deferred indefinitely.

Risk score, explained

The CVSS 3.1 score of 5.4 (MEDIUM) reflects: Attack Vector = Network (archives can be distributed remotely), Attack Complexity = Low (crafting the malicious archive is straightforward), Privileges Required = None (no authentication needed), User Interaction = Required (the user must extract the archive), Scope = Unchanged (impact is limited to the local system), Confidentiality = Low (a file write could expose or access some data), Integrity = Low (files can be written or modified), and Availability = None (no denial of service). The score appropriately captures that this is a user-triggered arbitrary file write with moderate severity.

Frequently asked questions

Does this affect me if I only use Python 3.12 or later?

No. The vulnerability is specific to Python versions before 3.12. If your entire Patool environment runs on Python 3.12+, you are not affected by this flaw, even on older Patool versions. However, verify that all instances and integrations truly use Python 3.12+; a single legacy process using an earlier version could still be a risk.

What types of files can an attacker write to bypass containment?

Any file that the Patool process has permission to write. Depending on the user context, this could include system libraries, startup scripts, configuration files in home directories, or application binaries. The practical damage depends on where and what the attacker writes and the subsequent execution context.

Is there a workaround if I cannot upgrade immediately?

Temporary workarounds include: upgrading to Python 3.12+ (which eliminates the vulnerability), restricting Patool's file permissions to a sandboxed directory, disabling archive extraction from external or untrusted sources, or using alternative archive utilities if available. However, these are interim measures; upgrade Patool as soon as possible.

Could this be exploited silently in an automated process?

Yes, if Patool is used in a CI/CD pipeline, data processing workflow, or service to extract archives without explicit user review of file contents. An attacker who can inject a malicious archive into the processing chain could write files without user awareness. This scenario elevates the practical risk beyond simple file download-and-extract workflows.

This analysis is based on the published CVE record and vendor information available as of the date of publication. Security landscapes evolve; verify all patch versions, Python compatibility, and affected product lists against the official Patool security advisories and your specific environment. No guarantee is made regarding exploit availability, real-world prevalence, or the completeness of vendor patches. This intelligence is for informational purposes to support security decision-making and should be combined with your organization's risk assessment, asset inventory, and threat model. Source: NVD (public-domain), retrieved 2026-08-05. Analysis generated by SEC.co (claude-haiku-4-5).