/

CVE-2025-71343

Severity:

HIGH RISK

(8.1)

Unsafe Pickle Deserialization (CWE-502) in picklescan

CVE-2025-71343

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

Malicious pickle files can evade detection in affected versions of picklescan by abusing the lib2to3.pgen2.pgen.ParserGenerator.make_label function during object reduction.

When such crafted pickle files are loaded with pickle.load(), embedded attacker-controlled code may execute, leading to arbitrary command execution in environments that rely on picklescan for safety checks.

Affected context

This vulnerability manifests in Python environments that:

  • Use picklescan (before 0.0.30) to vet pickle files for malicious payloads
  • Treat a "clean" picklescan scan as a safety signal before calling pickle.load()
  • Accept pickle input from semi-trusted or untrusted sources, such as user uploads or networked services

The issue specifically involves payloads that leverage lib2to3.pgen2.pgen.ParserGenerator.make_label during deserialization to run arbitrary commands while bypassing picklescan's detection logic.

Exploit preconditions

  • Attack surface: Any code path that calls pickle.load() on files pre-scanned with a vulnerable picklescan version
  • Required access: Ability to supply or influence serialized pickle data consumed by the application
  • Trigger point: Invocation of pickle.load() on a crafted pickle file that has passed picklescan checks
  • Why exploitation is possible: picklescan's detection rules do not account for the lib2to3.pgen2.pgen.ParserGenerator.make_label pattern in the reduce method, allowing attacker-controlled code execution constructs to slip through undetected

Why this happens

The underlying bug fits CWE-502: Unsafe Deserialization, where untrusted serialized data is processed by powerful deserialization mechanisms without adequate restrictions.

In this case, picklescan's analysis model fails to recognize a specific object reduction pattern involving lib2to3.pgen2.pgen.ParserGenerator.make_label that can be used to execute code during deserialization.

Applications implicitly trust picklescan's "safe" verdict, then call pickle.load() on attacker-controlled input, enabling arbitrary command execution via Python's flexible object construction semantics.

Potential impact

  • Malicious pickle payloads may execute arbitrary OS commands under the application's privileges
  • Attackers could gain remote control over application processes or worker nodes
  • Sensitive data accessed by the deserializing process may be exfiltrated or altered
  • Application integrity could be compromised through state manipulation or code injection
  • Lateral movement within the hosting environment or container cluster can occur if permissions allow

General mitigation guidance

Mitigation generally focuses on reducing trust in pickle data and constraining deserialization behavior:

  • Treat all pickle content as untrusted input and avoid deserialization from external or semi-trusted sources where possible
  • Prefer structured, data-only serialization formats (e.g., JSON or protocol buffers) that lack executable object construction semantics
  • If pickle usage is unavoidable, restrict which types and modules can be instantiated, and enforce strong input validation before deserialization
  • Layer defense-in-depth controls such as process isolation, minimal OS-level privileges, and sandboxing around components that perform deserialization
  • Do not treat any single detection tool as a complete safety boundary; combine static checks, runtime guards, and architectural constraints

How teams detect issues like this

Effective detection is typically multi-layered:

  • Use static analysis or pattern-based scanning to identify risky pickle.load() usage, especially on data sourced from external inputs
  • Review code paths where security tools (like picklescan) are treated as a gatekeeper and ensure no implicit trust is given to their verdicts
  • Implement policies that flag or block deserialization of complex objects or objects from sensitive modules during CI/CD reviews
  • Consider employing dynamic/runtime monitoring to detect suspicious subprocess spawning, file system changes, or network activity immediately after deserialization events
  • Periodically audit dependency behavior and update detection rules when new deserialization abuse patterns are discovered

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-p9w7-82w4-7q8m
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-lib2to3-pgen2-pgen-parsergenerator-make-label-detection-bypass

Frequently asked

questions

It can be, if the application accepts pickle data from remote clients or services and uses picklescan as a safety gate before calling pickle.load(). In such setups, attackers may deliver malicious payloads over the network.

An attacker needs the ability to supply or influence pickle-serialized data consumed by the application. They do not require filesystem or shell access if they can feed data into a deserialization endpoint.

The safest approach is to avoid using pickle for data coming from external or semi-trusted sources, switching to data-only formats with well-defined schemas. If pickle must remain, constrain deserialization strictly, reduce object surfaces, and do not rely solely on scanning tools for safety.

Establish architectural guidelines that treat deserialization as a high-risk operation, mandate using non-executable serialization formats for untrusted data, enforce security-focused code reviews around deserialization, and keep detection rules and tools aligned with emerging exploitation patterns.

Find out what's already
exploitable in your codebase.