/

CVE-2025-71340

Severity:

HIGH RISK

(8.1)

Unsafe Deserialization (CWE-502) in picklescan Scanner

CVE-2025-71340

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via Supply-Chain Tampering

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

An unsafe deserialization weakness in picklescan through 0.0.26 allows malicious pickle payloads to bypass scanning and execute attacker-controlled code via idlelib.pyshell.ModifiedInterpreter.runcode.

When untrusted or third-party pickle files are loaded with pickle.load(), this blind spot can enable supply-chain attacks on PyTorch models and other serialized Python objects.

Affected context

This vulnerability appears in environments that rely on picklescan (≤ 0.0.26) to vet pickle files before using pickle.load() or equivalent APIs.

It is most relevant in workflows that import externally provided PyTorch model checkpoints, machine learning artifacts, or serialized Python objects from partners, public repositories, or CI/CD pipelines.

Risk increases when teams implicitly trust picklescan's results as a security gate and continue to deserialize pickle files originating outside their direct control.

Exploit preconditions

  • Attack surface: Any Python process that deserializes pickle data using pickle.load() or similar functions.
  • Required access: Ability to supply or modify pickle files consumed by the application (e.g., model files, cached objects, artifacts in pipelines).
  • Trigger point: Loading a crafted pickle file with a vulnerable environment that either uses picklescan as its primary guardrail or skips additional validation.
  • Why exploitation is possible: picklescan ≤ 0.0.26 does not recognize payloads that leverage idlelib.pyshell.ModifiedInterpreter.runcode in __reduce__, allowing arbitrary code execution during deserialization despite a "clean" scan result.

Why this happens

The underlying issue is incomplete coverage of dangerous deserialization patterns in the picklescan library.

Pickle deserialization executes object reconstruction logic, including __reduce__ methods, which can embed callable references that run arbitrary code when an object is unpickled.

In this case, payloads using idlelib.pyshell.ModifiedInterpreter.runcode were not modeled or flagged, mapping directly to CWE-502 (Unsafe Deserialization): untrusted serialized data is interpreted as executable behavior without a comprehensive threat model or strict allowlist of safe constructs.

Potential impact

  • Attackers may execute arbitrary commands within the Python process loading the pickle file.
  • Supply-chain compromise of PyTorch models and ML artifacts can alter training or inference behavior.
  • Malicious code can exfiltrate data, credentials, or API keys accessible to the process.
  • CI/CD pipelines or batch processing jobs that deserialize artifacts can be subverted.
  • Local developer environments and shared research platforms may be silently backdoored.

General mitigation guidance

Mitigation centers on reducing trust in pickle inputs and hardening deserialization workflows rather than relying on a single scanning tool.

Common defensive patterns include:

  • Treat pickle data as untrusted by default and avoid deserializing inputs from unknown or unverified sources.
  • Favor safer, non-executable serialization formats (e.g., JSON, protocol buffers) for data interchange whenever possible.
  • When pickle is unavoidable, constrain the deserialization environment by limiting available modules, using strict allowlists of expected classes, or sandboxing execution.
  • Integrate multiple layers of scrutiny (content validation, integrity checks, provenance verification) before deserialization, especially for supply-chain artifacts.
  • Run deserialization in low-privilege contexts, separating it from sensitive services or credentials to minimize blast radius.

How teams detect issues like this

Effective detection focuses on both code-level patterns and operational signals:

  • Use static analysis and code review to identify any use of pickle.load(), pickle.loads(), or similar APIs handling data from external or loosely controlled sources.
  • Flag security assumptions that depend solely on one scanner or heuristic and require explicit discussion of deserialization risks.
  • Analyze serialized artifacts (model checkpoints, cache files, pipeline outputs) with multiple inspection tools and sanity checks rather than trusting a single result.
  • Enforce policy-level guidance that discourages executable serialization formats for shared or third-party artifacts, and require provenance tracking for ML models.
  • Automated security review systems can be configured to alert when new deserialization entry points are introduced or when unsafe patterns are reintroduced in the codebase.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-3gf5-cxq9-w223
vulncheck.comvulncheck.com/advisories/picklescan-remote-code-execution-via-idlelib-pyshell-modifiedinterpreter-runcode

Frequently asked

questions

It can be, if an attacker can deliver pickle files over a network channel that your application later deserializes (for example, downloading model files or artifacts from compromised repositories or APIs).

The attacker needs the ability to create or influence the pickle files that your environment loads—this might be control over a package index, model hub, artifact store, shared file system, or any upstream pipeline stage that produces serialized objects.

The safest approach is to avoid using pickle for untrusted data entirely and adopt non-executable serialization formats. Where pickle is unavoidable, combine strict allowlisting of expected classes, sandboxed deserialization, and reduced process privileges so that arbitrary code cannot cause widespread damage.

Establish architectural guidelines that treat all deserialization of externally sourced data as high risk, prohibit executable serialization formats in shared supply chains, require multi-layer validation and provenance checks for ML artifacts, and integrate static analysis and policy enforcement to catch unsafe deserialization practices during code review.

Find out what's already
exploitable in your codebase.