Summary
NLTK versions before 3.10.2 contain a symlink-based path traversal weakness in FramenetCorpusReader. An attacker who can place crafted symlinks in the corpus subdirectory may cause the application to read XML files outside the intended corpus root.
Affected context
The vulnerability occurs in deployments using NLTK's FramenetCorpusReader with a corpus directory that an attacker can modify or influence. Symlink names containing no path separators may pass the reader's path validation, while filesystem resolution redirects access to XML files outside the approved corpus root through methods such as frame_by_name(), _lu_file(), or doc().
Exploit preconditions
- Attack surface: Local filesystem access to an NLTK FrameNet corpus subdirectory
- Required access: Permission to create or modify symlinks within that directory
- Trigger point: Affected corpus-reader methods accessing a symlink-backed XML resource
- Why exploitation is possible: Validation checks the apparent entry name without sufficiently enforcing the resolved target's containment within the corpus root
Why this happens
The underlying bug is an incomplete path containment check. The reader validates a user-controlled filename before fully resolving symbolic links, allowing a permitted-looking directory entry to reference a file elsewhere on the filesystem. This behavior maps to CWE-22, Improper Limitation of a Pathname to a Restricted Directory, because the effective target is not reliably constrained to the intended corpus directory.
Potential impact
- An attacker may read arbitrary accessible XML files outside the corpus root.
- Sensitive application or system information could be disclosed.
- Retrieved data could be used to support further attacks or credential discovery.
- Integrity and confidentiality of corpus-processing workflows could be weakened.
General mitigation guidance
Mitigation generally focuses on enforcing containment after filesystem resolution and reducing trust in corpus contents.
Common defensive patterns include:
- Resolve candidate paths and verify that the canonical target remains beneath the approved corpus root.
- Reject symbolic links or use file-opening mechanisms that prevent traversal through links where appropriate.
- Treat corpus directories as trusted, immutable inputs and restrict who can create or replace entries.
- Run corpus-processing workloads with least-privilege filesystem permissions.
- Store sensitive files outside locations readable by the NLTK process.
- Apply defense-in-depth controls such as isolated workers and read-only corpus mounts.
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis and code review of path validation that occurs before symlink or canonical-path resolution.
- Tests using symlinked files, nested directories, and boundary-prefix path names.
- Runtime monitoring for unexpected file access outside approved corpus directories.
- Filesystem integrity policies that alert on symlink creation or changes in corpus locations.
- Automated security review tools configured to identify path traversal and unsafe file-handling patterns.

