/

CVE-2025-71371

Severity:

HIGH RISK

(8.1)

Undetected Unsafe Pickle Deserialization (CWE-502) Risk

CVE-2025-71371

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via Undetected Malicious Pickles

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

Malicious pickle payloads can bypass detection in vulnerable versions of picklescan by abusing code.InteractiveInterpreter.runcode in reduce methods.

When such payloads are later deserialized with pickle.load(), they can execute arbitrary code on the host system if the attacker controls the pickle content.

Affected context

This vulnerability arises in ecosystems that rely on picklescan to vet untrusted or semi-trusted pickle files before loading them.

It is most relevant in workflows where:

  • Python objects are persisted and shared using the pickle module
  • picklescan is assumed to provide sufficient security screening for pickle files
  • Deserialization via pickle.load() occurs on the same files without additional controls

Under these conditions, crafted payloads that use code.InteractiveInterpreter.runcode in reduce methods may evade detection.

Exploit preconditions

  • Attack surface: Any component that ingests pickle files and trusts picklescan to flag malicious content.
  • Required access: Ability to supply or overwrite pickle files consumed by the application or pipeline.
  • Trigger point: Invocation of pickle.load() (or equivalent) on a malicious pickle that has passed picklescan checks.
  • Why exploitation is possible: The detection logic does not recognize abuse of code.InteractiveInterpreter.runcode within reduce methods, allowing attackers to embed execution paths that are not flagged before deserialization.

Why this happens

The underlying issue is incomplete coverage in the unsafe deserialization detection logic.

picklescan aims to identify dangerous constructs in pickle payloads but fails to treat calls to code.InteractiveInterpreter.runcode in reduce methods as a high-risk execution primitive.

This maps to CWE-502: Unsafe Deserialization, where untrusted serialized data is allowed to drive code execution because analysis or validation does not fully constrain the deserialization behavior.

Potential impact

  • Attackers may execute arbitrary Python code when the malicious pickle is deserialized.
  • Malware or backdoors could be introduced into systems that load attacker-controlled pickle files.
  • Sensitive data handled in the same process may be read, modified, or exfiltrated.
  • System integrity can be compromised, potentially enabling further lateral movement or privilege escalation depending on runtime context.

General mitigation guidance

Mitigation patterns focus on reducing trust in serialized data and limiting the power of deserialization:

  • Avoid using pickle for data exchange across trust boundaries; prefer safer, data-only formats such as JSON or protocol buffers.
  • Treat all pickle files as untrusted and restrict or eliminate dynamic code execution during deserialization.
  • Apply strict, allow-list-based validation for callable objects and modules that can be invoked during reconstruction of pickled objects.
  • Run deserialization code with least-privilege principals and, where feasible, in isolated processes or sandboxes to limit impact.
  • Use detection and screening tools as a secondary defense, not as the sole security control, and complement them with safe design choices.

How teams detect issues like this

Detection of this class of issue generally relies on layered approaches:

  • Static analysis or pattern-based scanning for dangerous deserialization primitives, including uses of pickle.load() on untrusted input and calls to execution-oriented APIs in reduce methods.
  • Code review practices that flag reliance on security tools as the only protection around deserialization of potentially untrusted data.
  • Policies that restrict the use of general-purpose serialization formats capable of executing code, requiring safer alternatives for cross-boundary data.
  • Automated review tools can help identify high-risk serialization and deserialization calls, but should be paired with architectural checks to ensure data-only formats are used where possible.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-cj3c-v495-4xqh
vulncheck.comvulncheck.com/advisories/picklescan-remote-code-execution-via-code-interactiveinterpreter-detection-bypass

Frequently asked

questions

Exploitability depends on whether an attacker can supply pickle files that your system later deserializes. In environments that accept or process externally sourced pickles, the scope can be significant.

An attacker needs the ability to influence the pickled data being scanned and subsequently loaded—this could be via file uploads, shared storage, or compromised data pipelines.

The safest approach is to avoid using pickle across any trust boundary and instead adopt data-only serialization formats. Where pickle cannot be removed, tightly constrain deserialization behavior and treat all detection tooling as advisory, not authoritative.

Design systems so that untrusted data is never deserialized using code-capable formats, enforce architectural policies favoring safe serialization, and integrate security reviews for any use of pickle or comparable mechanisms in your codebase.

Find out what's already
exploitable in your codebase.