/

CVE-2025-71339

Severity:

HIGH RISK

(8.1)

Unsafe Deserialization (CWE-502) in Picklescan Scanner

CVE-2025-71339

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

A validation gap in Picklescan before 0.0.33 fails to detect the numpy.f2py.crackfortran._eval_length gadget embedded in pickle __reduce__ methods, leaving a known code execution vector unblocked.

Attackers can craft malicious pickle files that pass Picklescan's checks yet execute arbitrary Python code when loaded by applications that rely on Picklescan for safety validation.

Affected context

This vulnerability affects Python applications and services that:

  • Use Picklescan (before 0.0.33) to validate or "sanitize" pickle files, and
  • Continue to load pickles after Picklescan indicates they are safe, and
  • Have numpy available in the runtime environment.

In these contexts, the scanner's inability to recognize a specific dangerous gadget chain allows malicious payloads to be treated as benign.

Exploit preconditions

  • Attack surface: Any pickle-loading functionality that relies on Picklescan as a security gate.
  • Required access: Ability to supply or influence pickle data consumed by the target application (e.g., file upload, API input, shared storage).
  • Trigger point: Deserialization of an attacker-crafted pickle object that uses numpy.f2py.crackfortran._eval_length within __reduce__.
  • Why exploitation is possible: Picklescan's detection ruleset does not cover this gadget, so the malicious pickle can bypass validation and be deserialized by the victim's code as if it were safe.

Why this happens

The underlying issue is incomplete coverage of dangerous deserialization gadgets within a security validation tool.

Although Picklescan attempts to detect risky constructs in pickle __reduce__ methods, its rules do not include the numpy.f2py.crackfortran._eval_length gadget, a callable that can be abused to execute arbitrary code when reconstructed during unpickling.

This aligns with CWE-502: Unsafe Deserialization, where untrusted serialized data is processed in a way that can instantiate objects or call code with attacker-controlled parameters, and the protective mechanism (Picklescan) fails to fully enforce safe patterns.

Potential impact

  • Execution of arbitrary Python code in the context of the deserializing process
  • Compromise of application servers or worker processes loading attacker-controlled pickles
  • Access to sensitive data handled by the affected application
  • Use of the compromised environment for lateral movement or further attacks

General mitigation guidance

Mitigation focuses on reducing trust in serialized input and hardening deserialization boundaries rather than relying solely on gadget blacklists.

Recommended defensive patterns include:

  • Avoiding pickle for untrusted or semi-trusted data; prefer safer serialization formats (e.g., JSON, msgpack with strict schemas) where possible.
  • Treating any pickle from external or user-influenced sources as untrusted, even if a scanner reports it "safe".
  • Isolating deserialization in constrained environments (e.g., separate processes, containers, or sandboxes) with minimal privileges and restricted filesystem/network access.
  • Applying least-privilege execution for services that must use pickle, limiting what damage arbitrary code execution can cause.
  • Using allowlist-based object reconstruction patterns (e.g., custom unpicklers that only permit specific classes and modules) to constrain gadget surfaces.

How teams detect issues like this

Detection strategies should aim to identify both unsafe deserialization practices and overreliance on validation tools:

  • Static analysis rules to flag use of pickle.load, pickle.loads, and equivalent APIs when applied to data that can be influenced by external sources.
  • Code review checklists that highlight any security decisions based solely on Picklescan (or similar tools) and require justification or additional controls.
  • Scanning dependency code and configuration for deserialization logic that runs post-validation, ensuring no unguarded reintroduction of risky gadgets.
  • Runtime monitoring and logging around deserialization paths, including anomaly detection for unexpected module imports or subprocess/system calls triggered shortly after unpickling.

Automated review tools can help surface dangerous deserialization patterns and enforce policies forbidding untrusted pickle usage.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-6556-fwc2-fg2p
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-numpy-f2py-crackfortran-eval-length-gadget

Frequently asked

questions

Yes, if an attacker can supply pickle data to an application that uses Picklescan for validation and then deserializes the data, they can potentially trigger remote code execution.

The attacker needs the ability to influence or provide the pickle payload—such as via file uploads, inter-service messages, shared caches, or persisted objects that are later unpickled by the victim.

The safest approach is to avoid using pickle for any untrusted data and not to rely on gadget-detection tools as a primary safety mechanism; instead, switch to safer serialization formats or strictly constrained custom deserialization logic.

Establish a policy that prohibits untrusted deserialization, perform architectural reviews for any use of pickle or similar mechanisms, and combine static analysis, code review, and least-privilege runtime isolation to minimize the impact of any missed gadget or validation gap.

Find out what's already
exploitable in your codebase.