/

CVE-2026-31224

Severity:

HIGH RISK

(8.8)

Unsafe Deserialization in Snorkel MultitaskClassifier.load()

CVE-2026-31224

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Arbitrary Code Execution via Malicious Model Files

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/snorkel-team/snorkel
notion.sonotion.so/CVE-2026-31224-35d1e1393188814185f3f6db86c9a4e9

Frequently asked

questions

It can be, depending on how the application obtains model files. If an attacker can upload or otherwise influence the model file that MultitaskClassifier.load() consumes (for example, via a web interface, API, or shared artifact repository), they can trigger remote code execution when the file is loaded.

Not necessarily. The key requirement is the ability to provide or control the model file. In some deployments this may require authenticated access (e.g., internal ML platform users), while in others it could be exposed to unauthenticated users (e.g., public upload endpoints or unprotected object storage).

The safest pattern is to switch from general-purpose Pickle-based loading to data-only deserialization, such as using torch.load() with weights_only=True or an equivalent restricted mode. Combined with that, enforce a policy that only vetted, internally produced artifacts are ever passed to load routines.

Treat serialization formats like Pickle and generic torch.load() outputs as executable, not as plain data. Establish coding standards that forbid untrusted deserialization, require restricted loading modes for models, mandate artifact provenance checks, and incorporate automated static analysis to flag unsafe patterns during code review and CI.

Find out what's already
exploitable in your codebase.