Summary
Fickling, a Python pickling decompiler and static analyzer, failed to explicitly block dangerous uses of ctypes and pydoc prior to version 0.1.7, allowing malicious pickle payloads to be marked as "LIKELY_SAFE".
By chaining pydoc.locate with ctypes, an attacker can achieve remote code execution (RCE) while evading the scanner's detection, making any workflow that "trusts" Fickling's verdict vulnerable if it processes untrusted pickle data.
Affected context
This vulnerability affects environments that:
- Use Fickling to statically analyze or gate Python pickle files for safety
- Treat a "LIKELY_SAFE" scan result as a trust signal for loading or further processing pickles
- Accept or process pickle data from sources that may be influenced by an attacker
The issue arises because dangerous code paths via pydoc.locate and ctypes were not explicitly modeled as unsafe, allowing attacker-controlled pickle opcodes to be constructed that slip past Fickling's checks.
Exploit preconditions
- Attack surface: Any service, pipeline, or review process that relies on Fickling's analysis to assess the safety of pickle files.
- Required access: Ability to supply or influence serialized pickle content that will be scanned by Fickling and potentially later executed or loaded.
- Trigger point: The malicious pickle is scanned and flagged as "LIKELY_SAFE" by Fickling, and then a downstream component deserializes or otherwise executes it based on that assurance.
- Why exploitation is possible: Fickling's detection logic did not consider combinations of
pydoc.locateandctypesas dangerous, leading to an incomplete blacklist / insufficient regular expression (CWE-184) over an already hazardous deserialization mechanism (CWE-502).
Why this happens
The underlying bug stems from relying on a finite, incomplete list of known-dangerous constructs when analyzing Python pickles, rather than modeling the broader capability of dynamic object loading and execution.
Specifically, the scanner did not treat pydoc.locate and ctypes as high-risk primitives, even though they can dynamically resolve and invoke arbitrary objects, including system-level functions.
This reflects CWE-184: Incomplete Blacklist / Incomplete Whitelist, where security checks miss viable attacker-controlled paths, combined with CWE-502: Deserialization of Untrusted Data, because the ecosystem around pickle inherently allows code execution during object reconstruction.
As a result, a crafted pickle can chain permitted operations to reach effective code execution while the analyzer incorrectly labels the payload as safe.
Potential impact
- Malicious pickle files may be incorrectly classified as safe by Fickling.
- Remote code execution in applications or tools that load pickle data based on Fickling's safety assessment.
- Compromise of CI/CD pipelines or security review workflows that use Fickling as a gatekeeper.
- Lateral movement or data exfiltration from systems that deserialize attacker-supplied pickles after passing the scan.
- Erosion of trust in automated pickle analysis and potential exploitation of similar blind spots in other scanning tools.
General mitigation guidance
Effective mitigation focuses on both reducing reliance on pickle trust decisions and hardening static analysis:
- Avoid deserializing untrusted pickles: Treat Python pickle as inherently unsafe for untrusted data; use safer serialization formats (e.g., JSON, MessagePack, or domain-specific schemas) for cross-boundary data exchange.
- Defense-in-depth over scanners: Do not treat any static analyzer's "safe" label as a sole authorization signal to deserialize; couple analysis with strict input trust policies and architectural constraints.
- Model dynamic resolution as dangerous: When building or configuring scanners, treat functions like
pydoc.locate,eval, dynamic imports, and FFI interfaces (likectypes) as high-risk primitives. - Use allowlists instead of blocklists: Prefer whitelisting a small set of benign, well-understood types or modules that can be reconstructed, rather than attempting to enumerate and block every dangerous path.
- Privilege and isolation: Run any component that must deserialize pickle data with minimal privileges and in isolated sandboxes or containers, reducing the blast radius of a potential compromise.
How teams detect issues like this
To detect similar issues and misuse patterns, teams can apply multiple layers of review:
- Static analysis for dynamic primitives: Scan source code for uses of
pickle,cPickle,dill,cloudpickle,pydoc.locate, andctypesin code paths that handle external or untrusted data. - Pattern-based rules in scanners: Extend or configure SAST tools to flag deserialization flows that call or resolve dynamic execution primitives, not just explicit known-dangerous functions.
- Code review signals: During review, treat any new or expanded use of pickle and reflection-like APIs as a security-sensitive change requiring explicit justification and threat modeling.
- Policy enforcement: Enforce organizational guidelines that prohibit untrusted pickle deserialization and require documented exceptions, possibly with CI policies that block merges introducing unsafe patterns.
- Cross-tool validation: Periodically test pickle analyzers (including Fickling and others) with known malicious payloads to verify that detection rules correctly identify dangerous constructs and combinations.

