/

CVE-2025-71356

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71356

Deferred

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 prior to version 0.0.28 allows malicious pickle payloads using torch.fx.experimental.symbolic_shapes.ShapeEnv.evaluate_guards_expression to bypass detection.

Attackers can embed code that executes when the pickle is loaded, exposing applications that rely on picklescan for pre-load safety checks to remote code execution risks.

Affected context

This vulnerability affects environments that:

  • Use Python pickle files for model, configuration, or data exchange
  • Rely on picklescan (pre-0.0.28) to statically vet pickle payloads before loading
  • Work with PyTorch and the torch.fx.experimental.symbolic_shapes APIs

The risk materializes when untrusted or semi-trusted pickle files are accepted and assumed safe solely based on picklescan scanning results.

Exploit preconditions

  • Attack surface: Any application, service, or notebook that loads pickle files after scanning them with vulnerable versions of picklescan.
  • Required access: Ability to supply or modify pickle files consumed by a victim (e.g., uploaded models, shared artifacts, or datasets).
  • Trigger point: A victim process deserializes a crafted pickle using Python's pickle mechanisms, trusting picklescan's prior analysis.
  • Why exploitation is possible: picklescan before 0.0.28 does not recognize or flag dangerous calls to torch.fx.experimental.symbolic_shapes.ShapeEnv.evaluate_guards_expression, allowing attacker-controlled code paths to remain undetected in the serialized stream.

Why this happens

The underlying bug is an incomplete threat model and coverage gap in a security scanning tool for pickle files.

In terms of CWE-502: Unsafe Deserialization, the pickle format can encode executable behavior via object graphs and callable references.

picklescan's detection logic failed to treat torch.fx.experimental.symbolic_shapes.ShapeEnv.evaluate_guards_expression as a potentially dangerous execution sink, leaving a deserialization pathway where attacker-controlled data can drive function execution without being flagged.

Abstractly, this reflects a pattern where deserialization safety tools do not exhaustively enumerate or model all dangerous constructors, methods, or evaluation points available in the runtime environment.

Potential impact

  • Remote code execution in the context of the process loading the malicious pickle
  • Compromise of ML pipelines, including tampering with models and training data
  • Unauthorized access to sensitive data available to the deserializing application
  • Abuse of victim infrastructure for further attacks, lateral movement, or cryptomining
  • Corruption of analytical results and model behavior due to poisoned artifacts

General mitigation guidance

Effective mitigation focuses on reducing trust in pickle inputs and limiting what deserialization can do:

  • Treat all pickle files as untrusted unless they come from tightly controlled, authenticated sources.
  • Prefer non-executable serialization formats (e.g., JSON, protocol buffers) for data exchange where possible.
  • Implement allowlist-based loading patterns that restrict which modules, classes, and functions can be referenced during deserialization.
  • Run deserialization operations with least privilege, in isolated environments or sandboxes, so that unexpected execution is contained.
  • Regularly review and update safety tools and policies that analyze serialization streams to reflect new dangerous APIs and execution sinks.

How teams detect issues like this

Detection typically combines tool-based checks with process controls:

  • Use static analysis or security review tools that understand Python pickle internals and can flag references to risky functions and modules (including PyTorch's symbolic shape evaluation).
  • Incorporate code review practices that question any use of pickle for untrusted input and highlight reliance on single tools for safety validation.
  • Establish policies that restrict deserialization of artifacts from external or user-controlled sources without additional validation or sandboxing.
  • Monitor runtime environments for unusual child processes, file access patterns, or network activity triggered during or immediately after deserialization operations.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-f4x7-rfwp-v3xw
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-torch-fx-experimental-symbolic-shapes-shapeenv-evaluate-guards-expression

Frequently asked

questions

It can be, depending on how pickle files are ingested. If an attacker can upload or cause a victim to open a crafted pickle over the network, and the victim loads it after scanning with a vulnerable picklescan version, remote code execution may occur.

The attacker needs the ability to supply or influence pickle artifacts that the target environment will load—such as model files, shared datasets, or configuration blobs. No direct shell access is required if the application automatically deserializes these files.

The safest broad pattern is to avoid using pickle for untrusted data, adopt non-executable formats, and ensure any remaining deserialization runs in tightly constrained environments with explicit allowlists for permitted types and functions.

Prevention hinges on a combination of technical and process controls: minimize reliance on executable serialization formats, continuously update scanning tools to cover new dangerous APIs, enforce security reviews for deserialization logic, and integrate sandboxing and least-privilege principles into any workflow that must process externally supplied serialized artifacts.

Find out what's already
exploitable in your codebase.