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.crackfortranfunctions 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
f2pyintegration 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.

