/

CVE-2025-71348

Severity:

HIGH RISK

(8.1)

Undetected Unsafe Deserialization (CWE-502) in picklescan

CVE-2025-71348

Analyzed

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

The vulnerability in picklescan allows malicious pickle files invoking torch.utils._config_module.load_config inside custom reduce methods to bypass detection.

When such pickles are loaded, embedded arbitrary code may execute, enabling remote code execution in contexts like model loading or supply chain workflows.

Affected context

This issue arises in environments that rely on picklescan (before 0.0.28) to vet Python pickle files for malicious behavior.

It primarily affects workflows that:

  • Load untrusted or semi-trusted pickle artifacts (e.g., ML models, serialized objects)
  • Depend on picklescan to detect dangerous reduce-based execution paths
  • Use PyTorch or related tooling where torch.utils._config_module.load_config is available

In such contexts, attackers can deliver crafted pickle files that appear safe to picklescan but still execute arbitrary code at load time.

Exploit preconditions

  • Attack surface: Consumption of pickle files from external or less-trusted sources (e.g., model hubs, third-party datasets, CI artifacts).
  • Required access: Ability to supply or influence pickle files that are scanned with picklescan and later loaded with pickle.load (or equivalent).
  • Trigger point: Deserialization of the crafted pickle by the application, often during model loading or configuration restoration.
  • Why exploitation is possible: picklescan's detection logic does not recognize invocation of torch.utils._config_module.load_config within reduce methods as a dangerous execution sink, allowing attacker-controlled code to run during deserialization.

Why this happens

The underlying bug class is unsafe deserialization combined with incomplete detection coverage of dangerous execution primitives.

picklescan relies on pattern-based analysis of pickle opcodes and reduce methods to identify code execution paths, but it fails to treat torch.utils._config_module.load_config as a high-risk sink.

This maps to CWE-502: Deserialization of Untrusted Data, where a defensive control (the scanner) does not fully account for all ways untrusted data can trigger code execution, allowing crafted objects to bypass checks and run arbitrary logic during pickle.load.

Potential impact

  • Remote code execution when vulnerable systems deserialize attacker-controlled pickle files
  • Compromise of ML training or inference environments via malicious models or artifacts
  • Supply chain attacks through poisoned artifacts in registries, model hubs, or CI/CD pipelines
  • Data exfiltration, credential theft, or lateral movement from compromised runtime environments

General mitigation guidance

Mitigation typically centers on minimizing trust in pickle content and hardening deserialization workflows rather than relying on a single scanning tool.

Common defensive patterns include:

  • Avoiding deserialization of untrusted pickle data entirely, preferring safer, structured formats (e.g., JSON, protobuf) where feasible
  • Treating pickle deserialization as a privileged operation, running it in isolated or sandboxed environments with reduced permissions
  • Layering defenses by combining scanners with strict allowlists of permissible modules, functions, and classes during deserialization
  • Explicitly limiting or disabling access to configuration-loading or execution-oriented functions when processing external artifacts
  • Applying least-privilege to services responsible for loading ML models or serialized objects so that a compromise yields minimal system control

How teams detect issues like this

Effective detection of similar issues generally involves:

  • Static analysis rules that flag use of pickle (and equivalent serializers) on data sourced from external or less-trusted inputs
  • Code review checklists that require justification for any use of pickle, especially in supply chain or artifact ingestion paths
  • Policies that identify and monitor dangerous sinks (such as configuration loaders, dynamic import mechanisms, or code evaluation functions) reachable during deserialization
  • Automated security testing that feeds crafted pickle samples into pipelines to verify that scanners and controls detect or block execution
  • Inventory and monitoring of deserialization endpoints, including logging of artifact origins and integrity checks, to identify anomalous or unapproved pickle consumption

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-vv6j-3g6g-2pvj
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-torch-utils-config-module-load-config-bypass

Frequently asked

questions

It can be, depending on how pickle files enter the system. If an application automatically downloads or accepts pickle artifacts (for example, ML models from a remote repository) and relies on picklescan for safety, an attacker could deliver a malicious file that is processed remotely and leads to code execution.

The attacker needs the ability to supply or modify pickle files that the target system will scan with picklescan and subsequently load. This can include publishing malicious artifacts to shared registries, compromising artifact stores, or intercepting and altering files in a CI/CD or data pipeline.

The safest pattern is to avoid using pickle for untrusted data altogether and to replace it with safer, strictly structured serialization formats. Where pickle use is unavoidable, constrain deserialization to a controlled environment with strict allowlists and isolation, and do not rely solely on a single scanner for assurance.

Prevention relies on designing systems that assume deserialization is dangerous: require threat modeling for any use of pickle, enforce policies that ban or tightly restrict deserialization of external data, adopt secure-by-default serialization libraries, and integrate multiple layers of detection and isolation into ML and artifact ingestion pipelines.

Find out what's already
exploitable in your codebase.