/

CVE-2025-71362

Severity:

HIGH RISK

(8.1)

Unsafe Deserialization (CWE-502) via NumPy eval calls

CVE-2025-71362

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 deserialization weakness in picklescan before version 0.0.33 fails to detect unsafe use of numpy.f2py.crackfortran functions that call eval on attacker-controlled strings.

When pickle files are loaded from untrusted sources, attackers can embed malicious payloads that execute arbitrary code during deserialization.

Affected context

This vulnerability appears in environments that rely on picklescan for security checks on Python pickle files, particularly when handling data from semi-trusted or untrusted sources.

The risk is present where:

  • Python pickle deserialization is used in workflows
  • NumPy's f2py.crackfortran functions are reachable during loading
  • picklescan is assumed to detect dangerous constructs but is running a version prior to 0.0.33

In these contexts, malicious pickle content can bypass scanning and reach unsafe eval calls.

Exploit preconditions

  • Attack surface: Deserialization of pickle files within Python applications (data loading, model restoration, cache rehydration).
  • Required access: Ability to supply or modify pickle files consumed by the application (e.g., uploads, shared storage, external feeds).
  • Trigger point: Application code that loads pickle content and invokes logic paths involving numpy.f2py.crackfortran.
  • Why exploitation is possible: picklescan prior to 0.0.33 does not recognize or flag eval-based execution paths inside these NumPy functions, allowing attacker-controlled strings to be evaluated as code during deserialization.

Why this happens

The underlying bug is a classic CWE-502: Unsafe Deserialization scenario, combined with incomplete security scanning coverage.

Python pickle deserialization is inherently capable of executing arbitrary Python objects and code, and the use of eval within NumPy's f2py.crackfortran functions introduces an additional dynamic execution vector.

picklescan's earlier versions did not model or detect this unsafe pattern, so the scanner could report a pickle as safe while still allowing attacker-controlled strings to be evaluated, violating the assumption that scanned pickles are non-executable.

Potential impact

  • Arbitrary code execution in the Python process loading the pickle
  • Compromise of application runtime and underlying host environment
  • Unauthorized access to in-process secrets, configuration, and data
  • Manipulation of models, datasets, or computational results
  • Establishment of persistence or lateral movement within the infrastructure

General mitigation guidance

Effective mitigation focuses on reducing trust in deserialization and eliminating dynamic execution from untrusted inputs.

General defensive patterns include:

  • Avoiding pickle for untrusted or externally supplied data, favoring non-executable, structured formats such as JSON or protocol buffers.
  • Constraining deserialization to vetted, minimal object types and disallowing arbitrary module imports or callbacks.
  • Auditing and limiting use of eval, exec, and similar dynamic execution in code paths that can be reached during data loading.
  • Applying strict separation of concerns so that data parsing routines cannot trigger business-logic or system-level operations.
  • Running deserialization within constrained, least-privilege contexts and isolating high-risk parsing in separate processes or sandboxes.

How teams detect issues like this

Organizations can detect this class of issue through a combination of static and process-oriented controls:

  • Static analysis rules that flag use of eval, exec, or dynamic import patterns in code involved in deserialization.
  • Code review guidelines that treat pickle handling and NumPy f2py integration as high-risk, requiring explicit threat modeling.
  • Security policies that prohibit or closely control deserialization of data from untrusted sources, regardless of scanning tools.
  • Automated scanning of dependency code for known unsafe deserialization patterns and dynamic execution sinks.
  • Runtime monitoring for unexpected module loads, subprocess creation, or anomalous behavior during data loading workflows.

Sources

SourceLink
github.comgithub.com/mmaitre314/picklescan/security/advisories/GHSA-r8g5-cgf2-4m4m
vulncheck.comvulncheck.com/advisories/picklescan-arbitrary-code-execution-via-unsafe-deserialization-in-numpy-f2py-crackfortran

Frequently asked

questions

It can be, if an application accepts pickle files or equivalent serialized data from remote users or services and processes them without strong validation. In that case, an attacker can deliver a malicious pickle that leads to code execution upon loading.

The attacker needs the ability to provide or influence pickle files consumed by the affected application—for example, through file uploads, shared storage locations, APIs that accept serialized objects, or manipulated datasets.

The safest pattern is to avoid using pickle for untrusted data entirely, and to remove or isolate dynamic execution constructs (such as eval) from deserialization paths. Where pickle is unavoidable, tightly constrain deserialized types and ensure that no application logic or library code can execute attacker-controlled strings.

Establish a policy that treats all deserialization of external data as high-risk, enforce the use of non-executable data formats for untrusted inputs, and incorporate static analysis and code review checks specifically focused on serialization and dynamic execution. Additionally, maintain a strong dependency hygiene process to identify and address insecure patterns in third-party libraries.

Find out what's already
exploitable in your codebase.