/

CVE-2025-71357

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71357

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in picklescan before version 0.0.30 allows malicious pickle files using idlelib.pyshell.ModifiedInterpreter.runcommand in reduce methods to evade detection.

Attackers can embed hidden code in pickle payloads that will execute remote commands when a victim loads the pickle, making environments that trust pickles particularly risky.

Affected context

This vulnerability appears in environments that rely on picklescan (prior to 0.0.30) to vet or filter untrusted Python pickle files before loading them.

It is relevant where applications deserialize pickles that may originate from external or semi-trusted sources and assume that picklescan's verdict guarantees safety.

The issue manifests specifically when pickle payloads use idlelib.pyshell.ModifiedInterpreter.runcommand within __reduce__ methods, as this pattern bypasses picklescan's malicious object detection logic.

Exploit preconditions

  • Attack surface: Any component or workflow that loads attacker-supplied pickle files and relies on picklescan for safety checks.
  • Required access: Ability for an attacker to craft and deliver a pickle file to a victim system (e.g., file upload, shared storage, messaging, or supply-chain artifacts).
  • Trigger point: The vulnerable condition is triggered when the victim application loads and deserializes the malicious pickle after it has been scanned and incorrectly deemed safe by picklescan.
  • Why exploitation is possible: picklescan fails to recognize idlelib.pyshell.ModifiedInterpreter.runcommand within __reduce__ as a dangerous callable; when the pickle is deserialized, Python's pickle mechanism invokes this method, allowing embedded commands to execute.

Why this happens

The underlying bug is an instance of unsafe deserialization (CWE-502) combined with incomplete detection coverage in a security scanning tool.

Python's pickle protocol allows arbitrary object construction via __reduce__, including invocation of powerful callables like interpreters and command runners.

picklescan's detection logic does not treat idlelib.pyshell.ModifiedInterpreter.runcommand as a hazardous target, so payloads leveraging this function are not flagged even though they can execute arbitrary commands during deserialization.

At an abstract level, the tool assumes that enumerating certain known-dangerous types and callables is sufficient, but its allowlist/blocklist model omits this interpreter method, leaving a blind spot for attackers to exploit.

Potential impact

  • Attackers could execute arbitrary OS-level commands when a victim loads a crafted pickle.
  • Compromise of the victim application's runtime environment, including theft or manipulation of data in process memory.
  • Installation of backdoors or persistence mechanisms through deserialization flows.
  • Lateral movement within the victim's infrastructure if deserialization occurs in privileged or networked services.
  • Undermining of trust in artifact-scanning pipelines that depend on picklescan as a safety gate.

General mitigation guidance

Effective mitigation centers on reducing trust in pickle-based data and tightening deserialization behavior.

Recommended defensive patterns include:

  • Avoiding Python's pickle format for untrusted or semi-trusted data, preferring safer, schema-driven serialization formats that do not execute code.
  • Treating all pickle inputs as untrusted, even if a scanning tool has inspected them, and isolating deserialization in heavily sandboxed or low-privilege contexts.
  • Implementing strict allowlists of permissible types and callables during deserialization, rejecting or aborting when unexpected objects or reducers are encountered.
  • Introducing application-level validation of deserialized structures, ensuring only expected shapes and fields are accepted.
  • Minimizing privileges for processes that perform deserialization (e.g., dropping OS capabilities, restricting filesystem and network access) so that any code execution has limited blast radius.

How teams detect issues like this

Detection efforts can focus on both code and operational signals:

  • Static analysis and review: Search for use of Python's pickle (and related modules like dill) in code paths that handle external data, especially where trust is placed in pre-scan results from tools such as picklescan.
  • Pattern-based scanning: Extend detection rules to flag use of interpreter-like callables (e.g., idlelib.pyshell.ModifiedInterpreter.runcommand) inside __reduce__ or related methods, and treat these as indicators of potentially malicious payloads.
  • Policy enforcement: Enforce development policies discouraging pickle usage for untrusted inputs, and require explicit security review when pickle is unavoidable.
  • Runtime monitoring: Monitor for unexpected command execution originating from deserialization processes, including unusual child processes, shell invocation, or anomalous interpreter behavior.
  • Automated tooling: Integrate static and dynamic security tools into CI/CD pipelines to identify unsafe deserialization patterns and to check that deserialization occurs only within approved, constrained contexts.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-j343-8v2j-ff7w
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-undetected-idlelib-pyshell-modifiedinterpreter-runcommand

Frequently asked

questions

It can be, depending on how pickle files are received. If an application accepts pickle uploads or processes pickles from remote sources and uses picklescan as a safety gate, an attacker can remotely deliver a malicious pickle that executes commands when loaded.

The attacker primarily needs the ability to supply a crafted pickle file that the victim will eventually deserialize. They generally do not require prior authentication to the interpreter itself, only access to the data ingestion path that leads to deserialization.

The safest pattern is to stop using pickle for data that may be influenced by external parties and to avoid relying solely on scanning tools as a security boundary. When pickle usage is unavoidable, confine deserialization to unprivileged, sandboxed environments and implement strict controls on the objects that can be instantiated.

Future prevention relies on secure design choices: prefer non-executable serialization formats, institutionalize guidelines that treat deserialization as a high-risk operation, add automated checks for unsafe deserialization APIs, and enforce architectural patterns that keep untrusted data away from powerful interpreter or command-execution primitives.

Find out what's already
exploitable in your codebase.