Summary
Snorkel's MultitaskClassifier.load() method deserializes model files with torch.load() without enabling weights_only=True, allowing full Pickle-based object loading.
If an attacker can supply a crafted model file, this insecure deserialization path can execute arbitrary Python code on the system that loads the model.
Affected context
This vulnerability appears in environments using the Snorkel library (through v0.10.0) that:
- Rely on MultitaskClassifier.load() to restore pretrained models
- Accept or consume model weight files (e.g., .pt, .pth, or similar) from external or semi-trusted sources
- Run code in contexts where torch.load() operates with its default, unrestricted deserialization behavior
The risk is higher in workflows that automate model loading from user uploads, shared storage, or remote repositories without strict trust or provenance guarantees.
Exploit preconditions
- Attack surface: Model loading interface that calls MultitaskClassifier.load()
- Required access: Ability to provide or replace a model file that will be passed into load() (e.g., file upload, shared disk, CI artifact, or compromised storage)
- Trigger point: Invocation of MultitaskClassifier.load() on the attacker-controlled model file
- Why exploitation is possible: torch.load() defaults to full Pickle deserialization and, without weights_only=True or equivalent restrictions, it can instantiate arbitrary Python objects whose constructors or reducers can execute code during loading.
Why this happens
The core issue is the use of a general-purpose, code-capable deserialization mechanism on data that may not be fully trusted.
MultitaskClassifier.load() delegates to torch.load() without enabling security-restrictive options such as weights_only=True, leaving the loader in a mode where it will unpickle arbitrary Python objects from the model file.
This maps directly to CWE-502: Deserialization of Untrusted Data, where untrusted serialized data is treated as safe and can trigger execution paths embedded in object graphs during reconstruction.
The bug is conceptual rather than purely syntactic: model files are treated as benign data blobs, but the underlying serialization format (Pickle) is executable and must be handled as untrusted code.
Potential impact
- Arbitrary code execution on the machine loading the model
- Installation of malware, backdoors, or persistence mechanisms on the host
- Access to sensitive data available to the model loading process (API keys, model training data, intellectual property)
- Lateral movement within the environment if the process has network or system privileges
- Tampering with model behavior or training pipelines by executing attacker-controlled logic during loading
General mitigation guidance
Effective mitigation centers on treating model files as potentially hostile input and limiting what deserialization can do.
General defensive patterns include:
- Prefer data-only loading modes such as torch.load(..., weights_only=True) or equivalent APIs that restrict deserialization to tensors and primitive data.
- Enforce a strict trust boundary for model artifacts: only load files produced within your own controlled pipeline or from cryptographically verified sources.
- Use content validation and metadata checks (e.g., signatures, checksums, structured manifests) before loading a model file, rejecting unknown or unexpected formats.
- Run model-loading code under least-privilege accounts with constrained filesystem and network permissions to limit blast radius if deserialization is abused.
- Separate build/training environments from production inference so that even if training pipelines consume more flexible formats, production services only accept curated, validated weights.
How teams detect issues like this
Security teams can look for this issue using a combination of static and process-level monitoring techniques:
- Static analysis and code search:
- Identify direct and indirect uses of torch.load() or other Pickle-based APIs, especially in load(), from_pretrained(), or similar restore functions.
- Flag call sites where weights_only is omitted or set to a permissive configuration, particularly in libraries exposed to external inputs.
- Code review signals:
- Loading model files from user-controlled locations (uploads, shared folders, external URLs) without explicit trust checks.
- Absence of artifact provenance validation (signatures, checksums, or explicit allowlists) before deserialization.
- Policy enforcement:
- Introduce internal guidelines that prohibit unbounded Pickle/torch.load() usage in user-facing or multi-tenant services.
- Integrate automated scanners or SAST tools in CI to detect unsafe deserialization patterns and require manual review.
- Runtime monitoring:
- Observe unusual child processes or system calls originating from model-loading workflows, which may indicate execution of malicious payloads.

