Summary
A path sandbox bypass in NLTK corpus-reader constructors allows attacker-controlled corpus root paths to escape the intended data directory. When untrusted paths reach the affected readers, attackers may read arbitrary filesystem content, including SQLite database files accessible to the process.
Affected context
The vulnerability occurs in NLTK deployments that use the affected corpus readers and allow corpus root paths to be influenced by untrusted input or externally controlled configuration. Risk depends on the permissions of the NLTK process and whether the selected paths are accessible outside the intended corpus data root.
Exploit preconditions
- Attack surface: Applications or services that invoke
LinThesaurusCorpusReaderorPanLexLiteCorpusReader - Required access: Ability to supply or influence a corpus root path
- Trigger point: Construction or use of an affected corpus reader
- Why exploitation is possible: Path validation does not reliably contain attacker-selected locations within the intended sandbox boundary
Why this happens
The underlying bug is improper control of externally influenced file paths. A corpus-reader constructor accepts a root path and uses it to locate files without enforcing a robust containment relationship with the approved data directory. This maps to CWE-73: External Control of File Name or Path, because input-controlled path values can direct filesystem operations outside their intended scope.
Potential impact
- Attackers may read sensitive application files
- Credentials, configuration data, or secrets may be disclosed
- SQLite databases outside the corpus directory could be accessed
- Information gathered from readable files could support further compromise
- Data confidentiality may be reduced for the affected host or container
General mitigation guidance
Mitigation generally focuses on reducing trust in path inputs and enforcing filesystem boundaries before any file operation occurs.
Common defensive patterns include:
- Accepting corpus locations only from trusted, fixed configuration
- Using an allowlist of permitted corpus directories or resources
- Canonicalizing paths and verifying that resolved paths remain under the approved root
- Rejecting absolute paths, traversal components, and unexpected path schemes where appropriate
- Applying strict schema and type validation before constructing corpus readers
- Running the application with least-privilege filesystem permissions
- Isolating corpus data and sensitive databases from the process when they are not required
How teams detect issues like this
Organizations can identify similar risks through:
- Static analysis rules for filesystem APIs receiving constructor arguments or request-derived paths
- Code review checks for missing canonicalization and root-containment validation
- Tests using absolute paths, traversal-like components, symlinks, and alternate path representations
- Runtime policies that restrict process access to approved data directories
- File-access monitoring for unexpected reads outside designated corpus roots
- Automated security review tools that flag externally controlled path construction

