HIGH 8.1

CVE-2025-71359: picklescan 0.0.29 RCE via lib2to3 Gadget Chain Bypass

picklescan is a Python library designed to scan pickle files for malicious code before they are deserialized. A flaw in versions before 0.0.29 allows attackers to bypass this safety mechanism by embedding malicious code using lib2to3.pgen2.grammar.Grammar.loads in the pickle's reduce method. When an application uses picklescan to check a file but then deserializes it anyway, the malicious payload executes during pickle.load(), giving attackers remote code execution.

Source data · NVD / CISA · public domain

CVSS
3.1 · 8.1 HIGH · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
Weaknesses (CWE)
CWE-502
Affected products
0 configuration(s)
Published / Modified
2026-07-04 / 2026-07-06

NVD description (verbatim)

picklescan before 0.0.29 fails to detect malicious pickle payloads that utilize lib2to3.pgen2.grammar.Grammar.loads in the reduce method, allowing remote code execution. Attackers can craft pickle files embedding dangerous code that evades picklescan detection and executes during pickle.load() deserialization.

3 reference(s) · View on NVD →

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

Technical summary

CVE-2025-71359 exploits a gadget chain detection gap in picklescan's scanning logic. The vulnerability stems from the library's failure to recognize lib2to3.pgen2.grammar.Grammar.loads as a dangerous reduce target. This method can be abused during pickle deserialization to instantiate and execute arbitrary code. The attack relies on pickle's well-known unsafe deserialization model, where reduce methods are called during unpickling. Because picklescan does not flag this specific path, applications relying on picklescan as their sole anti-pickle-exploit defense will incorrectly approve malicious files, leading to remote code execution when pickle.load() is invoked.

Business impact

Organizations using picklescan to validate untrusted pickle files face a critical control bypass. This is particularly severe in data pipelines, ML workflows, or inter-service communication that accept pickle-serialized data from external or semi-trusted sources. An attacker can deliver a weaponized pickle file that passes picklescan validation but executes arbitrary code on the host, potentially compromising confidentiality and integrity. Development teams relying on picklescan as their primary defense against pickle exploitation are at heightened risk until they upgrade.

Affected systems

picklescan versions prior to 0.0.29 are vulnerable. Any application using an older version of picklescan to validate pickle files before deserialization is affected. This includes data science workflows, Python-based services that deserialize pickled objects, and tools that consume pickled ML models or cached data structures. The vulnerability does not affect Python's pickle module itself, only the detection capability of picklescan.

Exploitability

Exploitation requires an attacker to craft a malicious pickle file and trick or directly cause an application to pass it through picklescan validation before deserialization. The attack vector is network-based if the application accepts pickle data remotely. User interaction is required in the CVSS vector, suggesting the victim must either manually deserialize a suspicious file or the application must be explicitly configured to load untrusted pickles. Once a crafted file is accepted, code execution is reliable and full.

Remediation

Upgrade picklescan to version 0.0.29 or later immediately. After patching, validate that your application's pickle validation logic is correctly configured. As a defense-in-depth measure, consider restricting pickle deserialization to trusted sources only, using alternative serialization formats like JSON where possible, or sandboxing pickle deserialization in restricted environments. Review any pickled data that may have been processed by the vulnerable scanner.

Patch guidance

Update picklescan to version 0.0.29 or newer via your package manager (pip install --upgrade picklescan or equivalent). Verify the update is complete by checking the installed version (pip show picklescan). No configuration changes are required post-upgrade, but existing validation rules should be re-tested against known pickle gadgets to confirm improved detection. Consult the picklescan project repository or release notes for any breaking changes or new filtering options in the patched version.

Detection guidance

Monitor for attempts to load pickle files from untrusted sources or unusual deserialization patterns in your application logs. Search for pickle.load(), pickle.loads(), and picklescan usage in your codebase to identify all points where validation occurs. Audit any pickle files that were processed by vulnerable picklescan versions prior to the discovery date (July 2026). If available, use YARA rules or behavioral detection to identify execution of Python code spawned immediately after pickle deserialization. In a SOC context, correlate pickle file uploads or transfers with unexpected process execution on servers running vulnerable picklescan versions.

Why prioritize this

This vulnerability merits immediate attention because it directly undermines a control that organizations implement to prevent pickle-based RCE. A CVSS score of 8.1 (HIGH) reflects the high confidentiality and integrity impact, though availability is unaffected. The bypass nature—where picklescan gives false confidence—makes it especially dangerous. Organizations should deprioritize only if they do not deserialize untrusted pickles or have already migrated away from pickle as a data format.

Risk score, explained

The CVSS 3.1 score of 8.1 reflects: (1) Network attack vector (AV:N)—exploitation requires network delivery of a pickle file; (2) Low attack complexity (AC:L)—no special conditions are needed once the malicious file is crafted; (3) No privilege requirement (PR:N)—any user can submit a pickle file; (4) User interaction required (UI:R)—the application or user must process the file; (5) Unchanged scope (S:U)—the impact is limited to the application using picklescan; (6) High confidentiality and integrity impact (C:H/I:H)—remote code execution allows full system compromise; (7) No availability impact (A:N)—the exploit does not typically cause denial of service. The score does not include KEV status because the vulnerability is not currently listed in CISA's Known Exploited Vulnerabilities catalog.

Frequently asked questions

Does this affect Python's built-in pickle module?

No. Python's pickle module itself is not changed. This vulnerability affects picklescan, a third-party library that attempts to detect malicious pickle payloads before deserialization. The unsafe behavior of pickle.load() remains unchanged; picklescan is a tool to help mitigate it, and this CVE is a gap in that tool's detection logic.

What if we don't use picklescan—are we vulnerable?

No, but you may already be at risk from pickle exploitation in general. picklescan is a defensive tool. If you are not using any anti-pickle measures and are deserializing untrusted data, you are vulnerable to broader pickle gadget attacks. If you are only deserializing trusted or self-generated pickle files, pickle exploitation is not a direct threat, though best practice favors safer serialization formats like JSON or Protocol Buffers.

Is there a workaround if we cannot upgrade immediately?

Short-term: halt deserialization of any pickle files from untrusted sources until you upgrade. If you must continue, inspect pickle files in an isolated sandbox environment before production use. Consider alternative serialization formats for new workflows. However, upgrading is the only reliable fix and should be prioritized.

How do I know if my application has been exploited via this vulnerability?

Review application logs and server audit logs for unexpected process execution, network connections, or file modifications that coincide with pickle file processing. Check for outbound connections or spawned processes immediately following pickle deserialization. If picklescan scans are logged, look for scans of files dated before July 2026 that passed validation. Engage forensics or threat hunting if you suspect compromise.

This analysis is provided for informational and educational purposes. Vulnerability details, patch availability, and affected software versions are based on the disclosed CVE and vendor advisories current as of the publication date. Organizations should verify patch version numbers and compatibility against official vendor documentation and release notes before deploying updates. SEC.co does not warrant the completeness or accuracy of vendor remediation timelines or patch availability in all environments. This content does not constitute professional security advice; consult with your security team and vendor support for guidance specific to your infrastructure. Source: NVD (public-domain), retrieved 2026-08-12. Analysis generated by SEC.co (claude-haiku-4-5).