pypi / nltk
nltk
What changed in nltk 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
27 breaking101 security7 new APIs and options7 performance3 behavior and defaults16 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initnltk 3161 changes
Breaking changes 27
Unaligned NULL-target pairs are omitted from Alignment strings; alignments with unaligned pairs can be shown, ranged, and drawn on every surface.
Alignment strings now omit NULL targets.
Parsing now runs in linear time and refuses oversized categories, mitigating denial-of-service attacks.
The Java wrapper accepts a main class as its first argument, rejects launcher switches, argfiles, and source files, validates options, and restricts jar locations.
Placeholder labels are treated as missing data when calculating Krippendorff's alpha.
Set this environment variable to 1 to assert that a proxy used for URL fetching is trusted.
Pickle format loads reconstruct plain data only and refuse pickles naming classes or functions; URL fetches are also subject to network restrictions.
Resources and model save destinations are restricted to trusted data roots; unsafe roots are skipped with a warning. Keep private data in a private directory and add it to nltk.data.path.
URL fetching refuses non-global addresses, pins the validated address, restricts file URLs, and refuses proxied fetches unless explicitly trusted.
Provides the default five-second timeout for regular-expression matching; matches exceeding it raise TimeoutError.
Library terminal output renders control characters, escape sequences, and unbalanced bidi overrides as visible escapes to prevent terminal injection.
The wheel no longer includes nltk.test.unit; it remains available from a source checkout or sdist.
XML parsing rejects entity declarations and external references and limits tree depth; oversized or deeply nested input raises ValueError.
Model files are created exclusively under the pinned directory.
Walks deeper than MAX_RECURSION_DEPTH are refused instead of being silently truncated.
The ZWJ pattern no longer captures whitespace, and repeated shapes are handled linearly.
Per-call java() options are validated, and the -XX:/-D allowlist is replaced with a minimal one.
Stanford JAR execution is sandboxed to nltk_data directories.
inisec.py was removed; the notes point developers to PYTHONSAFEPATH instead.
Hardens downloads against XML entity expansion, concurrent download races, path traversal, unsafe ZIP extraction, symlink attacks, decompression bombs, and arbitrary file writes; enables ENFORCE by default.
Rejects binaries resolved relative to the current working directory.
Hardens path containment and ZIP extraction against symlinks, path traversal, validation/extraction mismatches, and unsafe path operations; restricts primitive types accepted by wrappers.
Bounds the default max_phrase_length to prevent cubic denial of service.
Returns None when multiple languages tie for the highest score.
Aligns behavior with Brants (2000) specifications.
The JAR is no longer loaded from the current working directory.
Requires a session token to shut down the WordNet Browser.
Security 101
java() now guards cmd[0] against JEP 330 source-file execution.
Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()
Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal
NLTK: AllowlistUnpickler does not deny numpy submodule-local file-I/O sinks
NLTK: ARFF_Formatter Injects Weka ARFF Schema Directives via Attacker-Controlled Class Labels
NLTK: BllipParser passes caller-supplied model paths to the bllipparser C extension with no pathsec check, enabling arbitrary read
NLTK corpus-reader view methods bypass the scoped root sandbox via intermediate-directory symlinks
NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element
NLTK: Downloader cyclic collection indices cause an infinite closure walk
NLTK incomplete fix: additional JVM/JAR sandbox bypass through unvalidated launcher tokens in java() command arguments
NLTK: Path Traversal in save_maxent_params / load_maxent_params Allow Arbitrary File READ/WRITE
NLTK: Quadratic CPU exhaustion in LegalitySyllableTokenizer.tokenize via unguarded onset reversal loop
NLTK: Quadratic CPU exhaustion in NLTK XMLCorpusView.read_block via deeply nested XML corpus tags
NLTK: Quadratic CPU exhaustion in TreebankWordTokenizer.span_tokenize via list.pop(0) in quote-restore loop
NLTK: Quadratic-time CPU denial of service in ConllCorpusReader SRL instance builder via nested span rescan
NLTK: Quadratic-time CPU denial of service in Tree.chomsky_normal_form right-factor binarization via list.pop(0)
NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan
NLTK: StreamBackedCorpusView constructor os.stat leaks out-of-root file existence, size, and mtime bypassing pathsec ENFORCE
NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases
NLTK: Symlink escape in YCOECorpusReader lets a psd/pos directory symlink read files outside the corpus root within the data sandbox
NLTK: Unbounded CPU consumption in SteppingRecursiveDescentParser.parse() with ambiguous or self-embedding grammars
NLTK: Uncontrolled recursion in CCG lexicon parser causes denial of service via deeply nested category input
NLTK: Uncontrolled recursion in DependencyGraph traversal causes denial of service via deep dependency chains
NLTK: Uncontrolled recursion in semantic-logic type parser causes denial of service via nested type strings
NLTK: Uncontrolled recursion in Toolbox settings helpers causes denial of service via deeply nested input
NLTK: Uncontrolled recursion in Tree.fromlist causes denial of service via deeply nested list input
NLTK: Untrusted search path in prover9/mace4 config allows local code execution via relative binary_location
NLTK: WekaClassifier passes an unvalidated caller-controlled model path to the weka JVM, bypassing nltk.pathsec containment
NLTK: XMLCorpusView comment and CDATA parsing permits quadratic CPU denial of service
JSON and YAML resource loading now applies size and depth bounds; YAML uses a bounded safe loader.
NLTK-compiled regular expressions, including caller-supplied patterns, are bounded against excessive compilation and match time; patterns retain re syntax and match objects remain those of the regex engine.
Downloaded archives and extraction are restricted to safe package directories, with ownership, writability, size, checksum, and archive-member checks.
The Toolbox reader and writers were hardened following a security re-audit.
Deserialization is bounded against depth and resource-exhaustion denial-of-service attacks.
Algorithmic-complexity DoS hardening is extended in a repository-wide sweep, including two-string distances.
Corpus-reader roots are validated against the data sandbox.
MaltParser's Java execution is sandboxed.
NLTK: Allowlisted pickle loaders still permit code execution in current source
NLTK AllowlistUnpickler dotted-name validation bypass allows remote code execution
NLTK: Corpus Reader Sandbox Bypass
NLTK: Corpus readers follow symlinks outside trusted roots despite pathsec enforcement
NLTK: Downloader.download follows hardlinks and overwrites outside-root files
NLTK: Entity-expansion DoS (billion laughs) via remaining raw ElementTree parses
NLTK: pathsec SSRF protection can be bypassed when a proxy is configured
NLTK: Pl196xCorpusReader has quadratic ReDoS on malformed TEI blocks
NLTK: Quadratic CPU Exhaustion in
XMLCorpusView._read_xml_fragment()NLTK: Quadratic-time DoS in PorterStemmer via long runs of 'y'
NLTK: ReDoS in nltk.tgrep via unvalidated user-supplied regular expressions
NLTK: Uncontrolled recursion in nltk.featstruct.FeatStructReader causes unhandled RecursionError (DoS) via deeply nested feature-structure input
NLTK: Uncontrolled resource consumption in RecursiveDescentParser via ambiguous or left-recursive grammars
NLTK: Uncontrolled search path when invoking the Graphviz 'dot' binary
Unbounded work in parsers and grammar transforms is bounded to mitigate denial-of-service risks.
The sandbox is hardened against write-side symlink TOCTOU and shared-temp squatting.
The system temp directory is trusted only when it is private.
A symlink escape vulnerability in FramenetCorpusReader was fixed.
NLTK: Symlink-based arbitrary file read in IPIPANCorpusReader, bypasses nltk.pathsec entirely
NLTK: Symlink-based sandbox bypass in FramenetCorpusReader (bypasses the fix for CVE-2026-54292)
Uses sparse indices to prevent unbounded-allocation denial of service.
Stops quadratic ReDoS in CCG lexicon parsing.
Bounds extraction to prevent exponential denial of service.
Guards against malformed input.
Prevents ReDoS in chunk tag-pattern parsing.
Uses a linear-time implementation to prevent quadratic-time denial of service.
Uses sparse storage to prevent quadratic-memory denial of service.
Validate input lines to prevent crashes on malformed lines.
Caches feature extraction and hardens boundaries.
Corpus readers use defusedxml to block XML entity-expansion denial of service.
Avoids algorithmic-complexity denial of service.
Routes loading through the pathsec sandbox.
Bounds work to prevent quadratic time and memory denial of service.
Bounds the default max_len to prevent unbounded allocation.
Blocks path traversal when accessing frames.
Bounds derivation-expansion steps to prevent unbounded enumeration.
Prevents JVM argument injection.
Bounds recursion depth to prevent uncaught RecursionError.
Relative MaltParser directories are resolved using MALT_PARSER rather than the current working directory.
Prevents process-wide current-working-directory pollution during parsing.
Bounds quantifier-nesting cost to prevent combinatorial denial of service.
Natural Language Toolkit (NLTK): DNS-rebinding SSRF filter bypass in nltk.pathsec.urlopen (nltk.download / nltk.data.load) defeats ENFORCE mode
Natural Language Toolkit (NLTK): Path Traversal in NKJPCorpusReader leads to Arbitrary File Read and bypasses the nltk.pathsec sandbox (ENFORCE=True)
Natural Language Toolkit (NLTK): ReDoS in NLTK ReviewsCorpusReader FEATURES regex
Natural Language Toolkit (NLTK): URL-Encoded Path Traversal in nltk.data.load() Allows Arbitrary Local File Read
nltk: Arbitrary File Read via Path Traversal in nltk.data.load() through Percent-Encoded Sequences
NLTK: Default ENFORCE=False Disables All pathsec Security Controls
NLTK downloader allows cross-package resource and model poisoning
NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol
NLTK network URL validation permits SSRF to RFC 6598 shared-address-space hosts
NLTK: ReDoS in nltk.text.Text.findall() via unvalidated user-supplied regular expressions
NLTK: SSRF Fail-Open in validate_network_url() via DNS Resolution Failure
NLTK: Stable FrameNet and NKJP readers parse outside-root XML
NLTK: StreamBackedCorpusView Bypasses pathsec.ENFORCE - Arbitrary Local File Read
Honors proxy settings and prevents DNS-rebinding SSRF, including IPv6 transition-embedded internal IPv4 bypasses.
Relative ReppTokenizer directories are resolved using REPP_TOKENIZER rather than the current working directory.
Bounds the super-linear n-gram scan.
The binary is no longer run from the current working directory.
Prevents ReDoS in XML fixing.
Cleans temporary files and isolates Java options.
Prevents ReDoS in the paragraph-break regex.
Prevents pickle RCE when loading models and fixes sparse index dtype compatibility with scikit-learn 1.9.
Removes a quadratic scan.
Stops exponential ReDoS in the XML validation regex.
New APIs and options 7
Setting this variable to 1 opts out of the restriction that Java loads jars only from a data root, with a warning.
The extract argument explicitly controls extraction; packages needing access by another account are extracted, and extracted files are found before the archive.
Sets chart_parse's default five-second wall-clock limit; passing max_time=None disables the limit.
The downloader command can explicitly extract downloaded packages with --extract or leave them unextracted with --no-extract.
Adds support for visualizing syntactic trees for RTL languages.
Adds the english-extended stopword list.
Adds an integration for HuggingFace datasets.
Performance 7
The tokenizer handles retried leading regex runs in linear time.
relextract handles retried leading regex runs in linear time.
The tokenizer handles retried leading regex runs in linear time.
ToktokTokenizer handles retried leading regex runs in linear time.
The parser handles retried leading regex runs in linear time.
The tokenizer handles retried leading regex runs in linear time.
Caches WordNet maximum depth lazily.
Behavior and default changes 3
Store reads now use a key manifest, and the store-swap window is closed.
Syntactic tree visualization now supports right-to-left languages.
Uses OMW-2.0 with all WordNet versions.
Fixes and other changes 16
val_load can now read back data written by val_dump.
The client surfaces the server's reason when it returns a non-2xx response.
Cycle detection no longer returns False for every parsed graph.
Prevents IndexError when stemming an empty string.
Requesting punkt now also downloads punkt_tab, preventing a missing-resource failure.
Requesting punkt now ensures punkt_tab is downloaded as well.
Counts all increasing pairs when computing kendall_tau.
Representation is iterative, so deep accepted trees no longer overflow the stack.
Fixes newline handling in ellipsis tokens and prevents the ZWJ emoji pattern from capturing adjacent whitespace.
Fixes perfect-agreement edge cases.
No longer crashes on terminals with siblings.
Honors substituted direction instead of ignoring it.
Fixes the duplicated -l short option.
Uses the lowercased word for irregular forms in NLTK mode and bounds recursion in _is_consonant.
Allows escaped brackets in input strings.
Fixes comparisons against incompatible types.