Summary
Picklescan versions before 0.0.33 fail to detect a specific numpy.f2py.crackfortran.getlincoef gadget used in pickle __reduce__ methods, leaving a code execution path unblocked.
An attacker can craft malicious pickle files that execute arbitrary Python code when loaded, bypassing Picklescan's safety checks and enabling supply-chain poisoning of shared model artifacts.
Affected context
This vulnerability appears in environments that rely on Picklescan as a safety gate for Python pickle loading, particularly in machine learning pipelines and artifact distribution systems.
It is relevant when:
- Untrusted or semi-trusted pickle files (e.g., models, datasets, intermediate artifacts) are scanned by Picklescan before being loaded.
- The runtime uses
pickle.load/pickle.loadsor equivalent to deserialize these artifacts. - Operators assume Picklescan will block dangerous gadgets, and therefore treat scanned pickles as safe enough to load.
Exploit preconditions
- Attack surface: Any service, script, or pipeline that loads pickle files after scanning them with vulnerable versions of Picklescan.
- Required access: Ability to supply or modify pickle artifacts (e.g., upload a model file, commit to a shared repository, or alter artifacts in transit).
- Trigger point: Deserialization of a crafted pickle that uses the
numpy.f2py.crackfortran.getlincoefgadget path during the__reduce__call chain. - Why exploitation is possible: Picklescan's gadget detection logic does not recognize this specific dangerous gadget, so malicious payloads pass validation and are later executed by the standard pickle deserializer.
Why this happens
The underlying issue is incomplete coverage in gadget detection for unsafe deserialization.
Picklescan is designed to identify known dangerous call chains and objects within pickle __reduce__ implementations, but its ruleset did not include the numpy.f2py.crackfortran.getlincoef gadget.
This maps to CWE-502: Unsafe Deserialization, where untrusted serialized data is processed by general-purpose deserializers that can invoke arbitrary code, and safety filters are partial rather than comprehensive.
Potential impact
- Arbitrary Python code execution in the context of the process loading the pickle.
- Compromise of ML pipelines, including model training and inference environments.
- Supply-chain poisoning of shared model or artifact repositories.
- Exfiltration or tampering of sensitive data processed by affected services.
- Use of the compromised environment for further lateral movement or persistence.
General mitigation guidance
Effective mitigation focuses on reducing trust in pickle-based artifacts and limiting what deserialization can do:
- Treat all pickle input as untrusted and minimize its use for long-term storage or external sharing, preferring safer, declarative formats where feasible (e.g., JSON, protobuf, or framework-native model formats).
- Apply strict separation of duties: scanning tools should be one defensive layer, not the only control; pair them with process isolation, sandboxing, or restricted execution environments for any deserialization.
- Restrict available gadgets by avoiding importing unnecessary modules in deserialization contexts and running loaders in environments with minimal libraries and privileges.
- Enforce least privilege on processes that handle pickle files (file system, network, and OS-level permissions) so that even if code execution occurs, its blast radius is constrained.
- Adopt secure-by-default loading patterns such as whitelisting expected object types or using custom, constrained reducers rather than general-purpose pickle for critical artifacts.
How teams detect issues like this
High-level detection strategies typically include:
- Static analysis or policy checks that flag use of general-purpose pickle deserialization (
pickle.load,pickle.loads,dill, etc.) in code paths that handle untrusted inputs. - Code review practices that question the necessity of pickle for external artifacts and look for assumptions that "scan == safe," especially in ML or data engineering workflows.
- Runtime monitoring for unexpected module imports, subprocess invocation, or filesystem/network actions originating from deserialization routines.
- Periodic assessment of safety tools like Picklescan to ensure their gadget coverage is current, using curated test payloads and regression suites.
- Integration of automated security review tooling in CI/CD that recognizes common deserialization sinks and enforces organizational policies on their use.

