Summary
Malicious pickle payloads can evade detection in vulnerable versions of picklescan by abusing unsupported torch.jit tensor operations.
When these crafted files are later deserialized with pickle.load(), they can execute arbitrary code, making any workflow that relies on picklescan for safety exposed to hidden RCE risk.
Affected context
This vulnerability appears in environments that rely on picklescan as a security filter for untrusted or semi-trusted pickle files, especially in Python ML or data pipelines using PyTorch.
It manifests where pickle files are accepted from external sources, scanned with picklescan, and then loaded with pickle.load() under the assumption that picklescan will block dangerous content.
The issue is specifically tied to malformed payloads that embed torch.jit.unsupported_tensor_ops.execWrapper calls, which picklescan fails to recognize as malicious.
Exploit preconditions
- Attack surface: Any service, script, or pipeline that ingests pickle files, uses picklescan for vetting, and then calls pickle.load() on "approved" files.
- Required access: Ability to supply or influence pickle files processed by the environment (e.g., file uploads, model sharing, cached artifacts, shared storage).
- Trigger point: Deserialization occurs when pickle.load() is invoked on a payload that previously passed picklescan scanning.
- Why exploitation is possible: picklescan's detection logic does not treat torch.jit.unsupported_tensor_ops.execWrapper as a dangerous construct, allowing attackers to embed executable behaviors that trigger during unpickling.
Why this happens
The underlying issue is an incomplete unsafe deserialization defense: picklescan assumes it can identify and block all dangerous pickle constructs but has gaps in its recognition logic.
Specifically, support for PyTorch's torch.jit.unsupported_tensor_ops.execWrapper is missing from the rule set, so deserialization payloads using this mechanism slip through without being flagged as malicious.
This maps to CWE-502 (Unsafe Deserialization), where untrusted serialized data is allowed to instantiate objects or run logic during deserialization, combined with an overreliance on a partial detection tool as a trust boundary.
Potential impact
- Arbitrary code execution when an attacker-controlled pickle file is deserialized.
- Compromise of applications or services that load scanned pickle files.
- Unauthorized access to sensitive data and secrets available to the deserializing process.
- Lateral movement within the host or environment where the vulnerable process runs.
- Data corruption or poisoning of machine learning models and datasets.
General mitigation guidance
Effective mitigation centers on reducing trust in pickle-based inputs and enforcing strict deserialization boundaries.
Common defensive patterns include:
- Treating all pickle data as untrusted and avoiding automatic deserialization in security-sensitive contexts.
- Replacing pickle with safer, schema-driven serialization formats (e.g., JSON, MsgPack, or protocol buffers) for externally supplied data.
- Wrapping any unavoidable pickle.load() calls in highly constrained, least-privilege environments (e.g., sandboxed workers, separate OS users, reduced filesystem and network capabilities).
- Applying allowlist-based object deserialization strategies where only explicitly permitted types and modules can be instantiated.
- Using multiple, complementary validation checks instead of relying on a single scanner as a hard security boundary.
How teams detect issues like this
Detection typically involves both static and dynamic analysis of how serialization is used in the codebase:
- Static analysis rules that flag calls to pickle.load(), torch.load(), or related APIs when used on data from untrusted or semi-trusted sources.
- Code review practices that question any workflow relying on picklescan or similar tools as the primary protection against malicious payloads.
- Policy checks in CI/CD to enforce serialization guidelines, such as "no pickle for user-supplied data" or "pickle only in isolated workers."
- Runtime monitoring and logging around deserialization pathways to detect unusual imports, subprocess spawning, or file/network activity during unpickling.
- Optional use of automated security scanners that understand unsafe deserialization patterns and PyTorch-specific exec-style constructs.

