/

CVE-2025-71345

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71345

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

Malicious pickle payloads invoking torch.utils.bottleneck.__main__.run_autograd_prof are not detected by vulnerable versions of picklescan, allowing embedded code to run at deserialization time.

When applications rely on picklescan for security screening of untrusted pickle files, attackers can bypass detection and achieve remote code execution through crafted pickle data.

Affected context

This vulnerability appears in environments that:

  • Use Python pickle for serialization/deserialization of data or models
  • Rely on picklescan (before 0.0.30) to detect malicious pickle files
  • Potentially accept or process pickle content from untrusted or semi-trusted sources

It is most relevant to machine learning or data processing pipelines where torch-related functionality is available and pickle files cross trust boundaries.

Exploit preconditions

  • Attack surface: Any service, script, or pipeline that deserializes attacker-controlled pickle files using Python's pickle mechanisms
  • Required access: Ability to supply or modify pickle files that will be scanned by picklescan and subsequently deserialized
  • Trigger point: Deserialization of a crafted pickle object that references torch.utils.bottleneck.__main__.run_autograd_prof
  • Why exploitation is possible: picklescan's detection logic does not flag this callable path as malicious, allowing hidden code execution behavior to remain unreported and reach the deserializer

Why this happens

The underlying issue stems from incomplete coverage in the threat detection logic for pickle payloads.

picklescan models unsafe deserialization risks by scanning for known dangerous constructs, but fails to recognize that calling torch.utils.bottleneck.__main__.run_autograd_prof from within a pickle stream can lead to arbitrary code execution.

This maps to CWE-502: Unsafe Deserialization, where the system assumes pickle content has been adequately sanitized, yet still permits execution of attacker-controlled behavior during object reconstruction.

Potential impact

  • Attackers may execute arbitrary code on the host performing deserialization
  • Compromise of machine learning or data processing environments handling untrusted pickle data
  • Unauthorized access to system resources, credentials, or sensitive data accessible to the deserializing process
  • Installation of backdoors, modification of models or datasets, and persistence within affected pipelines

General mitigation guidance

Effective mitigation focuses on reducing reliance on unsafe serialization formats and strengthening trust boundaries around deserialization.

Useful patterns include:

  • Avoiding Python pickle for data exchange across trust boundaries, favoring structured formats like JSON, MessagePack, or protocol buffers that do not execute code
  • Treating all pickle content as untrusted and restricting where deserialization occurs, such as isolating it in sandboxed or low-privilege environments
  • Implementing allowlists for expected object types and modules when deserialization is unavoidable, rejecting unexpected or executable constructs
  • Applying least-privilege to processes that handle untrusted serialized data, limiting filesystem, network, and OS interaction capabilities
  • Enforcing secure-by-default serialization policies within application and pipeline design to prevent ad hoc deserialization of external inputs

How teams detect issues like this

Organizations can approach detection by:

  • Using static analysis or custom scanners to identify use of Python pickle in code paths that process data from external or user-controlled sources
  • Reviewing dependencies that claim to vet pickle safety (such as scanning tools) for coverage gaps, especially around dynamic imports and framework-specific callable paths
  • Incorporating security-focused code reviews that flag unchecked deserialize operations and enforce policy requiring safe formats or hardened deserialization wrappers
  • Deploying runtime monitoring to observe unexpected execution behavior during data loading, such as anomalous imports or function invocations triggered by deserialization

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-4whj-rm5r-c2v8
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-torch-utils-bottleneck-main-run-autograd-prof

Frequently asked

questions

It can be, if an application accepts pickle files over a network interface (such as APIs, file uploads, or RPC mechanisms) and deserializes them after relying on picklescan for validation. In such cases, an attacker can remotely supply a malicious pickle payload.

An attacker needs the ability to provide or influence pickle files that are processed by the vulnerable environment. This might be through uploads, shared storage, pipeline inputs, or any mechanism that feeds pickle data into deserialization routines.

The safest pattern is to avoid using pickle for data crossing trust boundaries and to treat all serialized input as untrusted. Where pickle is unavoidable, use strict allowlists, sandbox deserialization, and do not rely solely on heuristic scanners for security guarantees.

Design systems so that data formats do not trigger code execution by default, enforce architectural rules against unsafe deserialization, and include security reviews for libraries that provide "validation" of serialized inputs. Regularly test detection tools with adversarial payloads to uncover blind spots before production use.

Find out what's already
exploitable in your codebase.