Summary
Fickling, a Python pickle decompiler and static analyzer, incorrectly classifies pickles that invoke Python's runpy module as only SUSPICIOUS instead of OVERTLY_MALICIOUS.
When Fickling is used as a security gate for pickle deserialization, this misclassification can mislead users or automated systems into treating dangerous pickles as safe enough to execute, potentially resulting in arbitrary attacker-controlled code running on the host system.
Affected context
This issue affects any environment where:
- Python pickle data is accepted from potentially untrusted or semi-trusted sources, and
- Fickling (≤ 0.1.6) is used as a gatekeeper to decide whether that pickle is safe to load, and
- Security policies or workflows depend on Fickling's severity classification (e.g., BENIGN, SUSPICIOUS, OVERTLY_MALICIOUS) to allow or block deserialization.
In such contexts, pickles that leverage runpy.run_path() or runpy.run_module() for code execution are not treated as clearly malicious, reducing the strength of the security control that Fickling is expected to provide.
Exploit preconditions
- Attack surface: Any API, file upload, message queue, or data channel where an attacker can supply Python pickle payloads that will be evaluated by Fickling.
- Required access: Ability to craft and submit arbitrary pickle data that is analyzed by Fickling before potential deserialization.
- Trigger point: A workflow, tool, or product that:
- Invokes Fickling ≤ 0.1.6 on the pickle, and
- Uses Fickling's "SUSPICIOUS vs. OVERTLY_MALICIOUS" distinction to make a decision (e.g., only blocking OVERTLY_MALICIOUS payloads), and
- Proceeds to deserialize pickles marked as SUSPICIOUS under certain conditions (such as manual override, looser policy, or automated acceptance).
- Why exploitation is possible: The analyzer's ruleset does not treat the
runpymodule as inherently dangerous, so payloads that can achieve code execution viarunpy.run_path()orrunpy.run_module()evade the strictest classification, effectively weakening or bypassing the intended security policy.
Why this happens
The underlying bug is a security policy and classification gap in Fickling's static analysis logic.
Specifically, the tool's threat model and rule configuration failed to consider Python's runpy module as a high-risk execution primitive, even though runpy.run_path() and runpy.run_module() can load and execute arbitrary Python code.
This aligns with:
- CWE-184: Incomplete Blacklist / Improper Enforcement of Behavioral Policy, because the tool maintains a list or heuristic of dangerous behaviors but omits
runpy, allowing malicious behavior to slip into a weaker risk category. - CWE-502: Deserialization of Untrusted Data, in that the tool is intended to mitigate unsafe pickle deserialization but misclassifies a code-executing pattern, reducing the effectiveness of protections against this class of deserialization attack.
Abstractly, the insecure pattern is: a security control relies on partial knowledge of dangerous sinks; some powerful "indirect code execution" APIs are not treated as strictly malicious, so payloads using them are under-classified and may be allowed through.
Potential impact
- Attackers could cause arbitrary Python code execution when a misclassified pickle is eventually deserialized.
- Local system compromise, including access to application data and credentials available to the Python process.
- Execution of follow-on actions such as installing malware, exfiltrating data, or modifying application behavior.
- Compromise of CI/CD or analysis pipelines that automatically process untrusted pickles under the assumption that Fickling's classification is authoritative.
- Erosion of trust in higher-level products or workflows that use Fickling as part of their security decision-making.
General mitigation guidance
Mitigation centers on treating pickle deserialization as inherently dangerous and not relying solely on best-effort static analysis:
- Prefer serialization formats without code execution semantics (e.g., JSON, MessagePack, or protocol buffers) for untrusted data, avoiding
pickleentirely in security-sensitive paths. - Architect workflows so that untrusted pickles are never deserialized in the same trust domain as critical secrets, business logic, or administrative capabilities.
- Treat any indication of "SUSPICIOUS" behavior from an analyzer as grounds for rejection or heavy isolation, rather than permitting deserialization by default.
- Introduce a defense-in-depth policy that assumes analysis tools can have blind spots; require additional validation or sandboxing when working with complex or user-controlled pickle data.
- When security tools are used as gates (like Fickling), define strict policy thresholds (e.g., "only explicitly BENIGN is allowed") rather than tolerating medium-risk classifications.
- Apply least-privilege to any process that must deserialize pickles: restrict filesystem access, network access, environment variables, and access to sensitive APIs to limit damage if malicious code executes.
How teams detect issues like this
High-level approaches to detect and guard against this class of issue include:
- Static analysis & code scanning:
- Search for
pickle.load,pickle.loads, and equivalent deserialization APIs (includingdill,cloudpickle, etc.) in code that touches untrusted data. - Flag locations where deserialization decisions are based on security tool classifications (e.g., Fickling output) rather than strict allow/deny policies.
- Identify uses of high-risk execution primitives (
runpy,exec,eval, dynamic imports) that could be abused indirectly by deserialized content. - Security policy review:
- Review how Fickling or similar tools are integrated into pipelines (CI, data ingestion, artifact analysis) and verify that medium-risk categories cannot silently pass through to deserialization.
- Ensure that documentation and runbooks explicitly state what classifications result in blocking vs. allowing deserialization.
- Runtime and behavioral monitoring:
- Monitor processes that deserialize pickles for unexpected module loads, file reads, or network calls following analysis that appears permissive.
- Use sandboxing or containerization for pickle processing, enabling anomaly detection and easy teardown if malicious behavior is observed.
- Tooling validation:
- Periodically test security tools with known malicious pickle samples (including
runpy-based payloads) to validate that policy classifications align with organizational risk tolerance. - Incorporate security regression tests to ensure that updates to analysis tools or rules do not weaken enforced policy over time.

