/

CVE-2025-71349

Severity:

HIGH RISK

(8.1)

Undetected Unsafe Deserialization (CWE-502) in picklescan

CVE-2025-71349

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution via malicious pickle payloads

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 before version 0.0.29 fails to recognize the dangerous use of the built-in trace.Trace.run function in pickle payloads, allowing malicious code to remain undetected during analysis.

Remote attackers can craft pickle files that leverage trace.Trace.run in the reduce method, leading to arbitrary code execution when pickle.load processes these files in environments that rely on picklescan for safety checks.

Affected context

This vulnerability affects systems that use picklescan as a security gate or auditing tool for Python pickle files but still deserialize those files with pickle.load.

It becomes relevant in workflows where:

  • Untrusted or semi-trusted pickle data is accepted (e.g., uploaded artifacts, cached models, serialized jobs)
  • picklescan is assumed to detect dangerous constructors and functions
  • The decision to load a pickle is influenced by picklescan's analysis results

In such contexts, reliance on incomplete detection allows crafted payloads using trace.Trace.run to bypass scrutiny.

Exploit preconditions

  • Attack surface: Any interface that accepts pickle files (APIs, file uploads, message queues, shared storage) and analyzes them with picklescan before deserialization.
  • Required access: Ability for an attacker to supply or influence pickle content that will be scanned by picklescan and later loaded with pickle.load.
  • Trigger point: Invocation of pickle.load (or similar APIs) on a malicious pickle that was previously deemed safe by picklescan.
  • Why exploitation is possible: picklescan's detection logic does not treat trace.Trace.run as a dangerous construct, allowing an attacker to embed it in the reduce method so that code is executed during deserialization without being flagged.

Why this happens

The underlying bug is an instance of CWE-502: Unsafe Deserialization, combined with incomplete threat modeling in a security scanning tool.

Python's pickle protocol allows arbitrary object construction and method invocation during deserialization, making it inherently dangerous for untrusted data.

picklescan attempts to statically inspect pickle opcodes to identify unsafe patterns but fails to classify the built-in trace.Trace.run function as a high-risk execution primitive.

This gap means that payloads using trace.Trace.run in the reduce chain can slip past detection, leaving the downstream pickle.load call to perform unsafe deserialization on what is incorrectly perceived as a benign object graph.

Potential impact

  • Remote attackers may achieve arbitrary code execution on systems that deserialize attacker-supplied pickle files.
  • Malicious payloads can run with the privileges of the application process performing pickle.load.
  • Attackers could access or modify sensitive data processed by the application.
  • Compromised hosts may be used as footholds for lateral movement within the network.
  • Integrity of serialized artifacts (models, jobs, configurations) could be violated or poisoned.

General mitigation guidance

Effective mitigation focuses on reducing trust in pickle content and ensuring that security controls do not rely solely on scanners like picklescan:

  • Avoid deserializing untrusted or semi-trusted data with pickle and prefer data-only formats (JSON, MessagePack, protocol buffers) that do not allow arbitrary code execution.
  • Treat pickles as inherently privileged artifacts; limit who can produce them and where they can be loaded.
  • Enforce process isolation and least privilege for components that must still consume pickle data, so that any code execution is contained.
  • Complement scanning tools with strict policy: only accept pickles from controlled build pipelines or signed sources, rather than arbitrary external inputs.
  • Maintain allowlists/denylists of callable objects and modules permitted in serialized payloads, rejecting anything that can invoke general-purpose execution primitives.

How teams detect issues like this

High-level detection approaches include:

  • Static analysis of Python code to flag any use of pickle.load or similar APIs on data that originates from untrusted channels.
  • Code review practices that treat deserialization boundaries as critical points, checking for assumptions about picklescan or other scanners as sufficient protection.
  • Security policies that require non-executable serialization formats for external-facing inputs and document exceptions explicitly.
  • Runtime monitoring to detect unusual or unauthorized execution paths triggered during deserialization flows.
  • Using automated tools (SAST/DAST and specialized serialization analyzers) to surface unsafe deserialization patterns and missing validation in CI pipelines.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-5qwp-399c-mjwf
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-undetected-trace-trace-run-in-pickle-files

Frequently asked

questions

Yes, if an attacker can deliver pickle payloads to an interface that both scans with picklescan and then deserializes with pickle.load, they can potentially trigger remote code execution.

The attacker needs the ability to supply or influence pickle files consumed by the application. No local shell access is required if the application accepts uploads, messages, or artifacts that are pickles.

The safest approach is to stop using pickle for untrusted data entirely and switch to non-executable serialization formats. Where pickles are unavoidable, treat them as highly trusted artifacts, restrict their sources, and do not rely only on scanning tools for safety guarantees.

Establish architectural rules that prohibit unsafe deserialization for external data, adopt secure serialization formats by default, and integrate security reviews around any code that loads complex serialized objects. Continuously update and validate security tooling against new execution primitives and serialization attack patterns.

Find out what's already
exploitable in your codebase.