/

CVE-2025-71374

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71374

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via Detection Bypass

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 bypass in picklescan before 0.0.29 allows malicious pickle data to use profile.Profile.run in reduce methods without being flagged.

When such crafted pickle files are deserialized, attackers can execute arbitrary code, making systems that rely solely on picklescan for safety vulnerable in remote data processing workflows.

Affected context

This vulnerability appears in environments that:

  • Use Python's pickle module (or compatible serializers) for loading untrusted or semi-trusted data
  • Rely on picklescan (before 0.0.29) as a primary safety gate to detect dangerous pickle payloads
  • Accept pickle data from remote sources such as APIs, message queues, file uploads, or data lakes

Under these conditions, crafted payloads that leverage profile.Profile.run within the pickle reduce mechanism may evade scanning and be deserialized without additional safeguards.

Exploit preconditions

  • Attack surface: Any service or tool that deserializes pickle data after scanning with a vulnerable picklescan version
  • Required access: Ability to supply or influence serialized pickle inputs (e.g., upload files, send messages, call APIs)
  • Trigger point: Deserialization of the malicious pickle object, typically via pickle.load or pickle.loads after picklescan reports it as safe
  • Why exploitation is possible: picklescan's detection logic does not recognize the use of profile.Profile.run in reduce methods as dangerous, allowing execution-capable constructs to pass validation and run during object reconstruction

Why this happens

The underlying bug stems from incomplete coverage of dangerous callable and method patterns in picklescan's analysis of pickle reduce operations.

In Python, pickle can recreate objects using callable references and arguments; when those callables can execute arbitrary code, reduce-based payloads become execution vectors.

Because profile.Profile.run was not classified or detected as a high-risk execution sink, malicious payloads using it avoided scrutiny, matching the CWE-502: Unsafe Deserialization pattern where untrusted serialized data drives code execution behavior.

Potential impact

  • Remote attackers may execute arbitrary Python code on the deserializing host
  • Attackers could gain control over application logic and internal workflows
  • Data stored or processed by the affected service can be read, modified, or destroyed
  • Compromise of surrounding infrastructure through lateral movement from the affected process
  • Use of the vulnerable service as a pivot for broader supply-chain or pipeline attacks

General mitigation guidance

Effective mitigation focuses on reducing trust in serialized data and constraining what deserialization can do:

  • Avoid deserializing untrusted or user-controlled pickle data whenever possible; prefer structured formats like JSON or protocol buffers
  • Treat security scanners like picklescan as advisory checks rather than the sole enforcement mechanism, combining them with strict input validation and sandboxing
  • Limit available execution sinks during deserialization by reducing the set of importable modules and callable references in the deserialization context
  • Run deserialization routines with least-privilege identities, restricted file system access, and minimized network permissions
  • Isolate risky deserialization workflows into separate, closely monitored processes or containers to contain potential compromise

How teams detect issues like this

Detection strategies typically combine code-level analysis with runtime monitoring:

  • Use static analysis or grep-based rules to find uses of pickle, cPickle, or similar libraries where inputs may be controlled by remote parties
  • Review code paths that rely on picklescan as a gatekeeper to ensure additional validation and authorization checks exist before deserialization
  • In code review, look for custom reduce methods, callable references, and dynamic imports that might provide execution capabilities upon object reconstruction
  • Employ security tooling that understands Python serialization semantics and can flag high-risk callables or methods used in reduce operations
  • Monitor deserialization-heavy services for anomalous behavior, such as unexpected subprocess creation, file changes, or network calls shortly after loading serialized data

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-x696-vm39-cp64
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-undetected-profile-profile-run

Frequently asked

questions

Yes. If an application accepts pickle data from remote sources and relies on a vulnerable picklescan version to approve payloads before deserialization, an attacker can craft inputs that execute code when loaded.

The attacker needs the ability to supply or influence serialized pickle content consumed by the affected system—such as uploading files, sending queued messages, or calling APIs that result in deserialization.

The safest pattern is to avoid deserializing untrusted pickle data entirely. Where serialization is necessary, prefer non-executable formats, introduce strict schema validation, and treat any remaining deserialization as untrusted code running in a heavily restricted environment.

Establish serialization guidelines that disallow executable formats for untrusted inputs, augment scanner-based protections with architectural safeguards (sandboxing, least privilege, isolation), and incorporate secure deserialization patterns into code review and automated checks across all services.

Find out what's already
exploitable in your codebase.