GitHub advisory · PyPI
NLTK: Corpus readers follow symlinks outside trusted roots despite pathsec enforcement
Description
Several corpus readers still step outside NLTK's symlink-aware trusted-root model. They derive in-root paths from trusted corpus state, convert those paths back into plain strings, and reopen them with built-in open() rather than nltk.pathsec.open().
nltk.corpus.reader.ipipan, nltk.corpus.reader.crubadan, nltk.corpus.reader.lin3.9.4 and current source v3.10.0-rc2 both reproduced.open() without preserving the trusted-root boundary.IPIPANCorpusReader opens header.xml derived from morph.xml, CrubadanCorpusReader opens table.txt directly, and LinThesaurusCorpusReader opens simN.lsp paths returned from its own root helpers. Under pathsec.ENFORCE=True, a symlink placed inside the trusted corpus root can point outside the root and still be parsed successfully. It was confirmed parsed outside-root content is returned through public methods such as channels(), domains(), categories(), langs(), crubadan_to_iso(), synonyms(), and scored_synonyms().
Preconditions
Steps
pathsec.ENFORCE=True with that root allowlisted.header.xml, table.txt, or simN.lsp inside the root and point them to external files.pathsec.open() blocks the same symlink targets.Minimal reproducible excerpt
{'ipipan': ['LEAK', 'TOPSECRET', 'CLASSIFIED'], 'crubadan': ['LEAK'], 'lin': [('LEAK', 9.5)]}
An…
Manual fix · PyPI
pip install --upgrade "nltk>=3.10.3"Sources