Summary
A deserialization bypass in picklescan before 0.0.29 fails to detect malicious pickle payloads that abuse idlelib.autocomplete.AutoComplete.get_entity in __reduce__ methods.
This allows attackers to hide arbitrary command execution code in pickle files that appear clean to picklescan and trigger when victims load them with pickle.load().
Affected context
This issue affects workflows and systems that rely on picklescan as a security control to vet untrusted or semi-trusted pickle files before loading them.
It becomes relevant wherever Python's pickle.load() is used on data received from external sources, shared artifacts, or supply-chain components, with the assumption that picklescan will flag dangerous payloads.
The vulnerability specifically involves payloads that exploit idlelib.autocomplete.AutoComplete.get_entity in __reduce__-based gadgets to achieve code execution while remaining undetected by the scanning logic.
Exploit preconditions
- Attack surface: Any application, toolchain, or workflow that:
- Accepts pickle files from external or untrusted sources, and
- Uses picklescan (prior to 0.0.29) as a gatekeeper before calling
pickle.load(). - Required access: Ability to supply or influence a pickle file that will be scanned by picklescan and later deserialized by a victim.
- Trigger point: The vulnerable pickle is passed to Python's
pickle.load()or equivalent APIs in an environment whereidlelib.autocomplete.AutoComplete.get_entityis importable. - Why exploitation is possible: picklescan's detection logic does not recognize this particular gadget chain using
AutoComplete.get_entityin__reduce__, so the malicious payload is not flagged and proceeds to execution upon deserialization.
Why this happens
The root cause lies in incomplete coverage of deserialization gadgets in a security scanning tool that is intended to detect dangerous pickle constructs.
Under CWE-502 (Unsafe Deserialization), the general problem is that data serialized with pickle can carry executable behavior through __reduce__ and related mechanisms.
In this case, picklescan's heuristic or rule-based detection does not account for the use of idlelib.autocomplete.AutoComplete.get_entity as a code execution primitive, allowing attackers to construct payloads that bypass the scanner's expectations and still execute commands when deserialized.
Potential impact
- Attackers may execute arbitrary system commands in the context of the application loading the pickle.
- Compromise of local environments, CI/CD agents, or data-science notebooks that process shared pickle artifacts.
- Theft, modification, or destruction of data accessible to the deserializing process.
- Use of compromised hosts as a foothold for lateral movement within a network.
General mitigation guidance
Mitigation typically involves treating pickle deserialization as inherently high risk and reducing trust in serialized data.
Common defensive patterns include:
- Avoiding
picklefor untrusted or user-supplied data; prefer safer, data-only formats such as JSON or message-pack where possible. - Restricting which code paths and modules are available during deserialization, for example by performing deserialization in an isolated, locked-down environment.
- Implementing strict allowlists of acceptable classes or data structures when deserialization cannot be avoided.
- Incorporating multiple layers of defense, such as content validation, least-privilege execution contexts, and network segmentation, so that a deserialization failure is less likely to lead to full system compromise.
How teams detect issues like this
Detection can focus on both code and operational behavior.
At the code level:
- Use static analysis or code review to identify any use of
pickle.load,pickle.loads, or equivalent APIs on data that may originate from external sources. - Flag patterns where security tools (like picklescan) are treated as the sole control for validating untrusted pickles.
At the operational level:
- Monitor for unusual command executions or process trees originating from services that deserialize pickles.
- Apply security testing to attempt known gadget-based payloads and confirm whether existing scanning and sandboxing controls detect or contain them.
Automated review tools and CI policies can help enforce rules around where and how deserialization is permitted.

