Summary
picklescan versions before 0.0.35 contain an unsafe pickle deserialization flaw that can be abused to read arbitrary files from the server filesystem.
By chaining io.FileIO with urllib.request.urlopen, unauthenticated attackers can bypass RCE-focused blocklists and exfiltrate sensitive files such as /etc/passwd to remote endpoints.
Affected context
This vulnerability manifests in environments where picklescan is used to inspect or process untrusted pickle data, such as scanning uploaded models or serialized objects.
The risk is elevated when the process has access to sensitive files and outbound network connectivity is allowed.
The issue is particularly relevant in server-side scanning services, CI/CD pipelines, or analysis tools that automatically ingest third-party pickle artifacts.
Exploit preconditions
- Attack surface: Any service, script, or pipeline that accepts or processes untrusted pickle data with picklescan < 0.0.35
- Required access: Ability to submit or control serialized pickle input; no authentication may be required if the interface is public
- Trigger point: Invocation of picklescan on attacker-controlled pickle payloads
- Why exploitation is possible: The deserialization flow allows construction of io.FileIO and urllib.request.urlopen objects, enabling file reads and outbound HTTP requests that bypass blocklists focused only on direct code execution primitives
Why this happens
The underlying issue is an unsafe deserialization pattern in which pickle data is treated as structurally trustworthy.
Instead of strictly limiting allowed types or performing non-executing inspection, the processing path permits construction of powerful I/O-related objects (io.FileIO, urllib.request.urlopen).
This aligns with CWE-22 in that untrusted input controls filesystem paths indirectly, enabling the attacker to read arbitrary files and exfiltrate them, even when direct remote code execution payloads are blocked.
Potential impact
- Disclosure of sensitive configuration files (e.g., /etc/passwd, application config, API keys)
- Exposure of source code or proprietary models hosted on the same filesystem
- Leakage of environment-specific secrets, tokens, or credentials readable by the process
- Facilitation of further attacks by revealing internal paths, usernames, and service endpoints
General mitigation guidance
Defensive strategies focus on eliminating unsafe deserialization behaviors and shrinking the power of deserialized objects:
- Restrict accepted pickle content to a minimal, audited set of safe types and structures
- Use non-executing or sandboxed inspection mechanisms that never instantiate real I/O or network objects from untrusted data
- Run scanning or analysis services under a dedicated, least-privilege account with access only to strictly necessary directories
- Isolate such services in hardened containers or sandboxes and restrict outbound network access wherever feasible
- Treat all third-party pickle artifacts as untrusted and validate them within controlled, security-reviewed workflows
How teams detect issues like this
Detection commonly involves a mix of static and dynamic approaches:
- Static analysis rules that flag pickle operations (e.g., pickle.loads, unpickling flows) where untrusted data is involved, especially when combined with I/O or networking libraries
- Code review checklists that require justification and design review for any pickle usage and for any construction of file or network-related objects during deserialization
- Runtime monitoring for unusual outbound HTTP requests originating from analysis or scanning services, paired with logs of files accessed shortly before such requests
- Periodic security testing of pickle-handling pipelines with crafted payloads to confirm enforcement of type restrictions and sandboxing

