Junglewise Threat Intelligence

NLTK unsafe pickle deserialization in allowlisted loaders

Severity: critical · CVSS 9.8 · Published 2026-08-25

Executive brief

NLTK is a widely-used natural language processing library that loads pre-trained models and tokenizers from pickle files. Versions before 3.10.3 contain a design flaw in their "safe" pickle loading mechanism that was meant to prevent code execution—but instead still allows attackers to run arbitrary commands by crafting malicious model or tokenizer artifacts. If an application loads untrusted models, attackers can achieve complete system compromise.

Technical details

The vulnerability is a deserialization flaw (CWE-502) in NLTK's allowlisted pickle loaders: nltk.picklesec.allowlisted_pickle_load(), nltk.tokenize.punkt.punkt_pickle_load(), and nltk.parse.transitionparser.TransitionParser.parse(). The root cause is that allowlists grant trust to entire module namespaces (e.g., nltk.tokenize, numpy) rather than specific safe callables. An attacker can craft a malicious pickle using pickle REDUCE to invoke dangerous in-namespace functions: ReppTokenizer._execute() calls subprocess.Popen(), and numpy.f2py.crackfortran.myeval() calls eval() with attacker-controlled input. Exploitation requires only that the victim application loads an attacker-supplied model or tokenizer artifact—no authentication or user interaction is needed. The attack is network-reachable if models are downloaded from untrusted sources. Patched versions 3.10.3+ replace broad namespace allowlists with exact (module, qualname) pairs and add post-load type validation and deny-list checks for dangerous modules.

Affected products

  • NLTK Project NLTK <= 3.10.2

Timeline

  • 2026-08-25: disclosed
  • 2026-08-11: patched: Patched version 3.10.3 released before disclosure; primary advisory GHSA-x99w-6fgc-pmfw published Aug 11, 2026

References

Related threats