Summary
Snorkel up to version 0.10.0 contains an unsafe deserialization issue in the Trainer.load() method, which uses torch.load() without the security-restrictive weights_only=True parameter.
If an attacker can supply or influence a model checkpoint file, they can craft a malicious payload that leads to arbitrary code execution when the file is loaded through the vulnerable method.
Affected context
This vulnerability affects applications that:
- Use the Snorkel library (through v0.10.0),
- Rely on the
Trainerclass and itsTrainer.load()method to restore models from checkpoints, - Load model artifacts from locations or channels that may be influenced by external parties (e.g., user uploads, shared storage, CI artifacts, third-party model repositories).
The risk is elevated when model checkpoint files are not strictly controlled, validated, or sourced from fully trusted origins.
Exploit preconditions
- Attack surface: Model checkpoint loading via
Trainer.load()in Snorkel-based applications. - Required access: Ability to provide or modify model checkpoint files that the application will load (e.g., upload, replace on disk, control network storage, or compromise a model repository).
- Trigger point: Invocation of
Trainer.load()on a malicious checkpoint file, either during training resumption, evaluation, or deployment startup. - Why exploitation is possible:
Trainer.load()callstorch.load()withoutweights_only=True, causing PyTorch to deserialize arbitrary Pickle objects embedded in the checkpoint, which can execute attacker-controlled code during deserialization.
Why this happens
The underlying issue is the use of a general-purpose deserialization mechanism on data that may be attacker-controlled, without restricting what can be instantiated.
In this case, Trainer.load() relies on torch.load(), which uses Python's Pickle under the hood. Without the weights_only=True option or equivalent safeguards, the loader reconstructs arbitrary Python objects encoded in the checkpoint file, including those with side effects during unpickling. This maps directly to CWE-502: Deserialization of Untrusted Data, where serialized data is treated as trusted program state instead of opaque, data-only content.
Potential impact
- Arbitrary code execution in the context of the process loading the model.
- Compromise of the host system running the Snorkel-based application.
- Theft or manipulation of sensitive data used during training or inference.
- Installation of backdoors or persistence mechanisms in ML pipelines or deployment environments.
- Lateral movement to other systems reachable from the compromised host.
General mitigation guidance
Effective mitigation focuses on treating model files as potentially hostile and constraining deserialization behavior:
- Prefer loading data-only artifacts: use
weights_only=Trueor equivalent options to limit loading to tensor weights and simple data structures rather than arbitrary objects. - Introduce a strict trust boundary around model checkpoints: only load models from vetted, authenticated sources (e.g., signed artifacts, controlled registries, or tightly permissioned storage).
- Apply content validation and metadata checks before loading: verify expected file format, schema, and origin rather than blindly deserializing.
- Run ML workloads under least privilege, using dedicated service accounts, restricted filesystem access, and isolation mechanisms (containers, sandboxes) to limit blast radius if deserialization is abused.
- Reduce reliance on generic object serialization formats like Pickle for cross-boundary data exchange, favoring safer, data-only formats where feasible.
How teams detect issues like this
Detection should aim to identify unsafe deserialization patterns and untrusted model sources:
- Configure static analysis or code scanning to flag calls to
torch.load()(or similar APIs) that are invoked withoutweights_only=Trueor other restrictions, especially in code paths that handle external or user-influenced input. - During code review, scrutinize any logic that:
- Loads models, checkpoints, or pipelines from file or network locations, and
- Uses Pickle-based or equivalent deserialization mechanisms without explicit trust assumptions.
- Implement security policies in CI/CD that:
- Prevent merging changes introducing new unsafe deserialization calls,
- Require explicit justification and documentation for any remaining uses of generic Pickle-based loading.
- Use runtime monitoring or logging to track when and from where model checkpoints are loaded, correlating unusual sources or patterns with potential abuse.

