Summary
Malicious pickle files can bypass detection in affected versions of picklescan by invoking numpy.f2py.crackfortran.myeval via the __reduce__ method.
When such crafted pickle payloads are later loaded by an application, they can execute arbitrary code despite having previously passed picklescan checks, creating a high-risk remote code execution scenario.
Affected context
This vulnerability appears in environments that rely on picklescan (before 0.0.33) as a security gate for inspecting Python pickle files.
It is most relevant where:
- Untrusted or semi-trusted pickle data is accepted from external sources
- picklescan is integrated into upload pipelines, artifact validation, or security reviews
- Downstream systems assume that "scan passed" implies pickle safety and subsequently perform
pickle.loador equivalent deserialization.
Exploit preconditions
- Attack surface: Any workflow that ingests attacker-controlled pickle files and uses picklescan to assess their safety.
- Required access: Ability to submit or influence serialized pickle content (e.g., file uploads, data streams, shared artifacts).
- Trigger point: A vulnerable version of picklescan analyzes the malicious pickle, fails to flag it, and an application later deserializes the payload.
- Why exploitation is possible: The scanner's detection logic does not recognize dangerous use of
numpy.f2py.crackfortran.myevalinvoked via the pickle__reduce__mechanism, allowing arbitrary code execution during deserialization while appearing benign at scan time.
Why this happens
The core issue stems from incomplete coverage of dangerous deserialization behaviors in picklescan's analysis engine.
Under CWE-502, unsafe deserialization occurs when untrusted data is converted back into objects that can trigger execution paths; here, the pickle protocol's __reduce__ hook is used to invoke numpy.f2py.crackfortran.myeval, a function capable of evaluating arbitrary code.
Because picklescan focuses on known risky constructs but lacks specific rules for this invocation pattern, crafted payloads evade detection, undermining the tool's role as a protective control.
Potential impact
- Arbitrary code execution in the process that deserializes the malicious pickle file
- Compromise of application servers or data processing workers
- Exfiltration or tampering of sensitive in-memory data handled post-deserialization
- Installation of backdoors or malware in environments where pickle files are routinely loaded
- Lateral movement within the infrastructure if compromised processes hold elevated privileges
General mitigation guidance
Secure patterns revolve around reducing trust in serialized data and strengthening deserialization controls rather than depending solely on a single scanner.
Common mitigation strategies include:
- Treating all pickle input as untrusted and avoiding deserialization for user-supplied content wherever feasible.
- Preferring safer, schema-based serialization formats (e.g., JSON, MessagePack, Protobuf) that lack executable semantics.
- Applying strict allowlists for modules and callables that can be reconstructed during deserialization, or disabling custom
__reduce__behavior in critical code paths. - Running deserialization logic in isolated, least-privilege contexts to limit blast radius if malicious payloads are processed.
- Complementing static scanners with defense-in-depth controls such as runtime sandboxing, OS-level access restrictions, and robust logging around deserialization events.
How teams detect issues like this
High-level detection focuses on both identifying unsafe pickle usage and verifying the completeness of scanning rules.
Possible approaches include:
- Static analysis checks for calls to
pickle.load,pickle.loads, or similar APIs where data originates from external or untrusted sources. - Code review practices that flag reliance on picklescan (or any single tool) as a sole safety guarantee and look for dangerous function references like
numpy.f2py.crackfortran.myevalin serialization-related code. - Security policies that require schema-based formats for cross-boundary data exchange and mandate explicit documentation of any remaining pickle-based protocols.
- Periodic evaluation of deserialization scanners against curated test suites of malicious payloads to confirm coverage and catch bypasses.
- Optional use of automated SAST/DAST tools configured with rules for CWE-502 patterns to continuously monitor repositories and pipelines.

