Summary
A detection gap in picklescan before version 0.0.34 allows malicious pickle payloads using the _operator.methodcaller built-in to evade scanning.
When such payloads are later processed with pickle.load(), they can execute arbitrary code on the system that deserializes them, making any workflow that trusts pickles from untrusted or semi-trusted sources particularly risky.
Affected context
This vulnerability affects environments that rely on picklescan as a security control to vet Python pickle files before loading them.
It is most relevant when pickle files may originate from outside the immediate trust boundary (e.g., user uploads, shared storage, CI artifacts, or third-party data sources).
The issue manifests when developers assume picklescan will reliably flag all malicious constructs, but still use pickle.load() or related APIs on files that may be attacker-controlled.
Exploit preconditions
- Attack surface: Any Python component that deserializes pickle data (files, network streams, or blobs) using
pickle.load()or equivalent. - Required access: Ability to supply or modify pickle content that is scanned by vulnerable versions of picklescan and subsequently deserialized.
- Trigger point: Invocation of
pickle.load()(or similar) on a payload that passed picklescan's checks due to the_operator.methodcallerdetection gap. - Why exploitation is possible: Pickle deserialization allows execution of arbitrary object constructors and callables; picklescan's incomplete coverage fails to recognize
_operator.methodcalleras a dangerous primitive, so crafted payloads can execute code while appearing benign to the scanner.
Why this happens
The underlying bug is an incomplete threat model and rule set for identifying dangerous constructs in Python pickle streams.
Pickle as a format supports invoking arbitrary callables and reconstructing complex objects, which maps directly to CWE-502: Unsafe Deserialization when inputs are not fully controlled.
In this case, picklescan's logic did not treat _operator.methodcaller as a hazardous function, leaving a gap where attackers could chain it with other objects to trigger arbitrary method calls during unpickling.
The pattern is an overreliance on a partial blacklist of dangerous primitives instead of treating untrusted pickle data as fundamentally unsafe.
Potential impact
- Malicious pickle payloads may evade automated scanning and be treated as safe.
- Arbitrary code can execute on systems that deserialize attacker-supplied pickle data.
- Compromise of applications that rely on pickles for configuration, models, or cached data.
- Lateral movement within environments where deserialization happens in privileged or networked services.
- Data tampering or corruption in workflows that process pickled objects (e.g., ML pipelines, job queues).
General mitigation guidance
Mitigation generally focuses on reducing trust in pickle data and avoiding unsafe deserialization patterns.
Recommended defensive patterns include:
- Treating all untrusted or externally sourced pickle data as inherently dangerous, regardless of scanner output.
- Preferencing serialization formats that do not support arbitrary code execution (e.g., JSON, protobuf, or schema-validated formats) for data exchange.
- Restricting where and how
pickle.load()is used, confining it to strictly controlled, internal-only data paths. - Running deserialization routines with least privilege and strong isolation so that any potential code execution has minimized impact.
- Complementing blacklist-based detection with policy that discourages or forbids pickle usage in high-risk contexts.
How teams detect issues like this
High-level detection approaches revolve around reviewing both code and security tooling assumptions:
- Static analysis rules that flag use of
pickle.load(),pickle.loads(), or similar APIs on data that may cross trust boundaries. - Code review practices that question reliance on picklescan or similar scanners as the sole security mechanism for pickle deserialization.
- Security policies that categorize pickle-based data flows as high risk and require explicit justification or alternative formats.
- Automated scanning tools that audit repositories and configurations for unsafe deserialization patterns and highlight where scanner limitations could lead to false negatives.

