Summary
Stanza can execute arbitrary code when it loads a lemmatizer checkpoint containing attacker-controlled, gzip-compressed pickle data. The risk arises when a caller-influenced checkpoint path is used during pipeline construction, before inference begins.
Affected context
The issue affects Stanza's lemmatizer checkpoint-loading path in versions 1.14.0 through versions before 1.15.0. During pipeline construction, a caller-influenced lemma_model_path can lead the trainer to decompress pos_dict data and pass it to unrestricted pickle.loads. The outer torch.load allowlist does not inspect this nested pickle data.
Exploit preconditions
- Attack surface: Stanza pipeline construction and lemmatizer checkpoint loading
- Required access: Ability to provide or influence the checkpoint loaded through
lemma_model_path - Trigger point: The lemmatizer trainer loads and decompresses the checkpoint's
pos_dictduring pipeline setup - Why exploitation is possible: The decompressed bytes are passed to unrestricted
pickle.loads, which can execute code while deserializing attacker-controlled data
Why this happens
The checkpoint stores pos_dict as gzip-compressed pickle bytes, which are later passed to unrestricted pickle.loads. Pickle deserialization can invoke behavior encoded in the input, so treating a checkpoint as trusted data creates an unsafe deserialization flaw (CWE-502). The outer torch.load setting does not make nested pickle data safe; the code-execution consequence is also related to CWE-94: Improper Control of Generation of Code.
Potential impact
- Attacker-controlled checkpoint data may execute arbitrary code in the Stanza process.
- The process's accessible data, credentials, or connected services could be exposed or modified.
- A compromised process may be used to affect other workloads or systems, depending on its privileges and environment.
General mitigation guidance
Defensive patterns include replacing nested pickle data with a non-executable, schema-constrained format and rejecting unexpected checkpoint structures. Treat model paths and checkpoint contents as untrusted unless their provenance and integrity are established; avoid accepting arbitrary checkpoints from users or external sources. Apply strict validation before processing, and run NLP workloads with least privilege and limited access to secrets, files, and network resources.
How teams detect issues like this
- Use static analysis to identify
pickle.loadsand similar deserialization calls, especially when their input comes from decompression or model/checkpoint fields. - Review checkpoint-loading code for nested serialized content that is not covered by the outer loader's safety controls.
- Check whether user-controlled paths or uploaded model artifacts can reach pipeline construction.
- Apply code-review and CI policies that prohibit unrestricted pickle deserialization of untrusted data; automated review tools can help flag these patterns.

