NLTK flaw let corpus-reader methods access files beyond a corpus root

  • NLTK
  • symlink
  • sandbox
  • corpus

View methods failed to enforce scoped root path validation

Intermediate symlinks allowed unauthorized file access

Fix implemented in NLTK version 3.10.4

NLTK corpus-reader view methods have a security flaw that can bypass restrictions on access to a corpus directory. The issue affects versions 3.9.4 up to, but not including, 3.10.4, according to the advisory.

The flaw can let a reader access files outside the specified corpus directory but still within NLTK’s globally allowed data directories. It applies when an intermediate-directory symlink inside the corpus points elsewhere within those directories; the global restrictions still prevent access to files outside them.

The advisory says CorpusReader.open() checks that a resolved file path stays within the corpus directory, but some view methods use a different path that does not apply that scoped check. NLTK lists version 3.10.4 as patched.