GitHub advisory · PyPI
NLTK: Corpus Reader Sandbox Bypass
Description
NLTK corpus-reader constructors can still reach outside-root file and database reads before the nltk.pathsec sandbox boundary is enforced.
The PoC shows the safe path blocked by pathsec.open, then LinThesaurusCorpusReader and PanLexLiteCorpusReader succeeding in the same process.
nltk.corpus.reader constructors3.10.2474af1f5a94b1b8d53fc2b6defec3a2ce7633b74 / PyPI nltkLinThesaurusCorpusReader(root) and PanLexLiteCorpusReader(root)nltk.pathsecENFORCE=TrueCorpusReader.__init__() turns a string root into a FileSystemPathPointer without any pathsec validation, and these readers then use builtin open() or sqlite3.connect() directly on derived paths. The constructor path therefore never hits the sandbox guard that pathsec.open() enforces.
if zipfile:
root = ZipFilePathPointer(zipfile, zipentry)
else:
root = FileSystemPathPointer(root)
with open(path) as lin_file:
...
self._c =…
Manual fix · PyPI
pip install --upgrade "nltk>=3.10.3"Sources