/

CVE-2025-71376

Severity:

HIGH RISK

(8.1)

Undetected Malicious Pickle (CWE-502) in picklescan

CVE-2025-71376

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via deserialization of malicious pickle data

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 detection gap in picklescan before version 0.0.29 allows specially crafted pickle files using idlelib.autocomplete.AutoComplete.fetch_completions in reduce methods to evade scanning.

If a victim loads these undetected pickle files, embedded code can run and execute arbitrary commands, making environments that deserialize untrusted pickles particularly risky.

Affected context

The vulnerability appears in workflows that rely on picklescan as a safeguard when handling Python pickle files, especially where pickles may originate from semi-trusted or unknown sources.

It is most relevant in environments that:

  • Automatically load or deserialize pickle data
  • Assume picklescan will flag malicious payloads
  • Use tools or pipelines where pickle-based artifacts are exchanged across trust boundaries

In such contexts, the undetected malicious reduce methods can bypass scanning and still reach deserialization routines.

Exploit preconditions

  • Attack surface: Systems or applications that consume pickle files and use picklescan for security screening.
  • Required access: Ability to provide or influence pickle content that a victim system will later load (e.g., uploaded models, cached objects, shared artifacts).
  • Trigger point: Victim deserializes the crafted pickle file using standard Python pickle APIs after it has passed picklescan checks.
  • Why exploitation is possible: picklescan does not recognize malicious use of idlelib.autocomplete.AutoComplete.fetch_completions in reduce methods, allowing attacker-controlled code paths to remain undetected and execute during deserialization.

Why this happens

This issue stems from incomplete coverage of dangerous code paths in picklescan's analysis of pickle opcodes and their associated reduce methods.

Under CWE-502 (Unsafe Deserialization), the core problem is treating complex object reconstruction logic as benign without fully modeling or restricting how functions like AutoComplete.fetch_completions can be abused during unpickling.

Because the analyzer fails to classify this particular pattern as malicious or high risk, embedded attacker-controlled behavior is allowed through, resulting in undetected unsafe deserialization when the pickle is later loaded.

Potential impact

  • Malicious pickle files may evade detection and be treated as safe.
  • Attackers could execute arbitrary OS commands when victims load the crafted pickle.
  • Compromise of local user environments, including access to files and credentials.
  • Execution of arbitrary Python code within affected applications or tooling.
  • Facilitation of lateral movement if the deserialization occurs in privileged or networked contexts.

General mitigation guidance

Effective mitigation focuses on reducing trust in pickle input and hardening deserialization workflows, rather than relying solely on any single scanner.

Common defensive patterns include:

  • Avoiding pickle for data exchange across trust boundaries and preferring safer, non-executable serialization formats such as JSON or protocol buffers.
  • Treating all pickle files as untrusted by default and isolating deserialization in low-privilege, sandboxed environments.
  • Enforcing architectural rules that disallow dynamic object construction from untrusted sources.
  • Using multiple, complementary security checks (linting, static analysis, and policy enforcement) around any deserialization code.
  • Applying least-privilege principles to processes that must deserialize data, limiting the potential damage of successful code execution.

How teams detect issues like this

Detection strategies should focus both on the static characteristics of deserialization code and on how pickle files are processed in the broader system:

  • Use static analysis rules to flag calls to generic Python pickle loaders (pickle.load, pickle.loads, dill.load, etc.) when applied to data from untrusted or external sources.
  • During code review, look for reliance on security scanners as the only line of defense and identify complex reduce methods or object reconstruction patterns that may conceal executable behavior.
  • Define and enforce organizational policies that restrict or prohibit use of pickle in interfaces exposed to external input, and require explicit threat modeling where pickle is essential.
  • Consider automated review tools that can model serialization flows, highlight unsafe deserialization hotspots, and cross-reference them with known risky functions or modules used in reduce methods.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-7cq8-mj8x-j263
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-undetected-idlelib-autocomplete-autocomplete-fetch-completions

Frequently asked

questions

It can, if an attacker can supply pickle files that a remote service or application will deserialize. The exploitability depends on whether the deserialization happens on data received from external or network sources.

An attacker must be able to influence or provide pickle content that a victim process will later load, such as uploaded models, shared cache files, or artifacts exchanged between systems.

The safest pattern is to eliminate untrusted pickle deserialization entirely, replacing pickle with non-executable serialization formats and treating any remaining deserialization as a high-risk operation performed in isolated, low-privilege contexts.

Prevention relies on strong design-time controls: avoid executable serialization formats for data crossing trust boundaries, enforce coding guidelines that restrict unsafe deserialization, and incorporate static analysis and code review practices that closely examine any serialization and deserialization logic.

Find out what's already
exploitable in your codebase.