CVE-2025-71368: picklescan RCE via doctest.debug_script Bypass
picklescan is a Python security tool designed to scan pickle files for malicious code before they are deserialized. Version 0.0.29 and earlier contain a detection gap: they fail to recognize the doctest.debug_script function as a dangerous payload. An attacker can craft a malicious pickle file that embeds a call to doctest.debug_script, which executes arbitrary commands when the pickle is loaded by a victim. Because picklescan doesn't flag this function, users relying on it for protection may unknowingly deserialize and execute hostile code.
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-06-30 / 2026-07-01
NVD description (verbatim)
picklescan before 0.0.30 fails to detect the doctest.debug_script function when analyzing pickle files, allowing attackers to execute arbitrary code. Remote attackers can craft malicious pickle files embedding doctest.debug_script calls that bypass picklescan detection and execute arbitrary commands upon pickle.load invocation.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from incomplete function coverage in picklescan's detection engine. The doctest.debug_script function, part of Python's standard library, can be leveraged as a gadget chain to achieve arbitrary code execution during pickle deserialization. When a crafted pickle file containing doctest.debug_script is analyzed by picklescan versions before 0.0.30, the tool fails to identify it as a risky operation and permits the pickle to pass validation. Subsequent invocation of pickle.load on the file then triggers the embedded doctest.debug_script call, executing attacker-controlled commands. This is classified under CWE-502 (Deserialization of Untrusted Data), a well-known class of Python pickle vulnerabilities.
Business impact
Organizations that rely on picklescan as a gating mechanism for accepting or processing untrusted pickle files face a significant bypass risk. Applications that deserialize pickles from external sources (APIs, file uploads, caches, messaging systems) protected only by picklescan 0.0.29 or earlier can be compromised despite the presence of the scanning tool. The HIGH severity CVSS score reflects that network-accessible services could be exploited to achieve remote code execution with no authentication required and minimal user interaction (pickle must be deserialized). Data exfiltration, system compromise, and lateral movement become possible for any attacker who can influence pickle content.
Affected systems
Any Python application using picklescan versions before 0.0.30 to validate untrusted pickle input is affected. This includes web services that accept pickled data, microservices using pickle for inter-process communication, data pipeline tools that deserialize cached pickle objects, and any deployment where picklescan is deployed as a security boundary. The vulnerability does not affect applications that do not use picklescan or those that have already upgraded to 0.0.30 or later. Applications using pickle.loads or pickle.load without any validation tool are also vulnerable to this class of attack, though picklescan's purpose is to mitigate such risks.
Exploitability
Exploitation is straightforward from an attacker's perspective. No special privileges or authentication are required; only the ability to craft and deliver a malicious pickle file to a target application. The attack surface depends on the application design—if pickles come from user uploads, untrusted APIs, or any external source, the risk is immediate. Once a crafted pickle embedding doctest.debug_script reaches a vulnerable picklescan instance and is subsequently deserialized, arbitrary code execution occurs automatically. The CVSS vector AV:N/AC:L/PR:N/UI:R indicates network accessibility and low attack complexity, with only user interaction (deserialization) required as a gate. This combination makes the vulnerability practically exploitable in real-world scenarios.
Remediation
Upgrade picklescan to version 0.0.30 or later, which includes detection logic for doctest.debug_script and other previously undetected gadgets. After patching, re-scan any untrusted pickle files that may have been stored or cached while running vulnerable versions. For applications that cannot upgrade immediately, implement additional controls: avoid deserializing untrusted pickles altogether (prefer JSON or other safer formats), restrict pickle deserialization to authenticated internal sources only, run pickle deserialization in isolated, restricted environments (containers, sandboxes), and apply strict input validation and allowlisting of expected pickle objects where feasible.
Patch guidance
Verify the picklescan release notes and GitHub repository to confirm that version 0.0.30 addresses this specific vulnerability. Update your Python environment and any containerized or deployed applications to use picklescan 0.0.30 or the latest available release. This is a straightforward dependency upgrade for most Python projects (pip install --upgrade picklescan). Test the upgrade in a staging environment to ensure no regressions, then deploy to production. After patching, consider re-running picklescan against any historical pickle files processed while vulnerable versions were in use to detect any that may have been malicious and slipped through.
Detection guidance
Hunt for uses of picklescan in your codebase and verify installed versions against 0.0.30. Examine application logs and network traffic for indicators of pickle deserialization from untrusted sources. If you maintain a artifact repository, scan stored pickle files with the updated picklescan version to retrospectively identify any that may have embedded doctest.debug_script or other obfuscated gadgets. Monitor for unexpected subprocess spawning or command execution initiated from processes that deserialize pickle data. Review application code for any direct pickle.load or pickle.loads calls on untrusted input, even if picklescan is in place, as defense-in-depth is prudent.
Why prioritize this
This vulnerability should be treated as high-priority due to its HIGH CVSS score (8.1), the practical ease of exploitation, and the likelihood that picklescan is deployed in environments processing untrusted data. Because picklescan is a security tool, its bypass creates a false sense of protection and may delay incident detection. Organizations relying on it for compliance or security architecture must patch immediately. If your infrastructure ingests pickles from external sources or user-controlled input, this is a critical threat.
Risk score, explained
The CVSS 3.1 score of 8.1 (HIGH) reflects a network-accessible, unauthenticated attack vector (AV:N, PR:N) with low complexity (AC:L) that requires user interaction only in the form of deserialization (UI:R). The attack yields high confidentiality and integrity impact (C:H, I:H) but no availability impact (A:N), since the payload is arbitrary code execution rather than denial of service. The scope remains unchanged (S:U), meaning impact is limited to the vulnerable component. This score appropriately captures the severity: remote code execution is possible against any application accepting the malicious pickle without authentication, contingent only on the application deserializing it.
Frequently asked questions
Does this vulnerability affect applications that do not use picklescan?
No, picklescan is a detection and scanning tool. Applications that do not use picklescan are not made more or less vulnerable by this CVE. However, applications that deserialize untrusted pickles without any validation or protection are inherently vulnerable to pickle gadget chain attacks, of which doctest.debug_script is one example. This CVE highlights why picklescan (when properly patched) or other defenses are necessary.
Can we safely use older versions of picklescan if we validate pickles another way?
Upgrading is still recommended for defense-in-depth, but if you use picklescan 0.0.29 or earlier in combination with additional controls—such as running deserialization in a sandbox, accepting only pickles from trusted sources, or using safer formats like JSON—your risk is lower. That said, patching to 0.0.30 is the most straightforward mitigation and should be prioritized.
Is there a workaround if we cannot upgrade picklescan immediately?
Yes. Immediately cease deserializing pickles from untrusted or external sources. Switch to JSON or other safe serialization formats if possible. If pickle is required, deserialize only in isolated sandboxed environments with minimal privileges, implement strict allowlisting of expected object types, and run deserialization operations as unprivileged users. These controls reduce exploitability even if picklescan is bypassed, though they are not substitutes for patching.
Will picklescan 0.0.30 prevent all pickle-based attacks?
No. picklescan is a detection tool that identifies known dangerous gadget chains and functions. While it is more comprehensive after patching, new gadgets or obfuscated payload techniques may exist that it does not yet detect. Picklescan should be one layer in a defense-in-depth strategy, combined with avoiding untrusted pickle input, sandboxing, and secure coding practices.
This analysis is based on the CVE description and CVSS scoring provided as of the publication date. Verify patch availability and affected versions against the official picklescan repository and vendor advisories before deploying mitigations. This vulnerability does not appear on the CISA KEV list as of the analysis date, but organizations should not delay patching based on KEV status. Security posture and risk tolerance vary; adjust prioritization based on your organization's use of picklescan and exposure to untrusted pickle data. No exploit code or proof-of-concept is provided herein. Source: NVD (public-domain), retrieved 2026-08-09. Analysis generated by SEC.co (claude-haiku-4-5).
Weaknesses (CWE)
Related vulnerabilities
- CVE-2025-11993HIGHWooCommerce Infinite Scroll Plugin PHP Object Injection – HIGH Severity
- CVE-2025-27511HIGHGeoServer DB2 JNDI Injection Remote Code Execution
- CVE-2025-69130HIGHPHP Object Injection in Entrepreneur WordPress Booking Theme ≤3.1.3
- CVE-2025-71339HIGHPicklescan Gadget Bypass Allows Arbitrary Code Execution
- CVE-2025-71340HIGHPicklescan Evasion via idlelib.pyshell.ModifiedInterpreter
- CVE-2025-71341HIGHPicklescan Bypass Enables Remote Code Execution via profile.Profile.runctx
- CVE-2025-71342HIGHPicklescan Evasion Enables Remote Code Execution in PyTorch Models
- CVE-2025-71343HIGHpicklescan Detection Bypass Allows Remote Code Execution