Summary
Malicious pickle payloads invoking torch.utils.bottleneck.__main__.run_autograd_prof are not detected by vulnerable versions of picklescan, allowing embedded code to run at deserialization time.
When applications rely on picklescan for security screening of untrusted pickle files, attackers can bypass detection and achieve remote code execution through crafted pickle data.
Affected context
This vulnerability appears in environments that:
- Use Python pickle for serialization/deserialization of data or models
- Rely on picklescan (before 0.0.30) to detect malicious pickle files
- Potentially accept or process pickle content from untrusted or semi-trusted sources
It is most relevant to machine learning or data processing pipelines where torch-related functionality is available and pickle files cross trust boundaries.
Exploit preconditions
- Attack surface: Any service, script, or pipeline that deserializes attacker-controlled pickle files using Python's pickle mechanisms
- Required access: Ability to supply or modify pickle files that will be scanned by picklescan and subsequently deserialized
- Trigger point: Deserialization of a crafted pickle object that references
torch.utils.bottleneck.__main__.run_autograd_prof - Why exploitation is possible: picklescan's detection logic does not flag this callable path as malicious, allowing hidden code execution behavior to remain unreported and reach the deserializer
Why this happens
The underlying issue stems from incomplete coverage in the threat detection logic for pickle payloads.
picklescan models unsafe deserialization risks by scanning for known dangerous constructs, but fails to recognize that calling torch.utils.bottleneck.__main__.run_autograd_prof from within a pickle stream can lead to arbitrary code execution.
This maps to CWE-502: Unsafe Deserialization, where the system assumes pickle content has been adequately sanitized, yet still permits execution of attacker-controlled behavior during object reconstruction.
Potential impact
- Attackers may execute arbitrary code on the host performing deserialization
- Compromise of machine learning or data processing environments handling untrusted pickle data
- Unauthorized access to system resources, credentials, or sensitive data accessible to the deserializing process
- Installation of backdoors, modification of models or datasets, and persistence within affected pipelines
General mitigation guidance
Effective mitigation focuses on reducing reliance on unsafe serialization formats and strengthening trust boundaries around deserialization.
Useful patterns include:
- Avoiding Python pickle for data exchange across trust boundaries, favoring structured formats like JSON, MessagePack, or protocol buffers that do not execute code
- Treating all pickle content as untrusted and restricting where deserialization occurs, such as isolating it in sandboxed or low-privilege environments
- Implementing allowlists for expected object types and modules when deserialization is unavoidable, rejecting unexpected or executable constructs
- Applying least-privilege to processes that handle untrusted serialized data, limiting filesystem, network, and OS interaction capabilities
- Enforcing secure-by-default serialization policies within application and pipeline design to prevent ad hoc deserialization of external inputs
How teams detect issues like this
Organizations can approach detection by:
- Using static analysis or custom scanners to identify use of Python pickle in code paths that process data from external or user-controlled sources
- Reviewing dependencies that claim to vet pickle safety (such as scanning tools) for coverage gaps, especially around dynamic imports and framework-specific callable paths
- Incorporating security-focused code reviews that flag unchecked deserialize operations and enforce policy requiring safe formats or hardened deserialization wrappers
- Deploying runtime monitoring to observe unexpected execution behavior during data loading, such as anomalous imports or function invocations triggered by deserialization

