NLTK has a Path Traversal issue
Several NLTK corpus reader classes do not validate file paths, so an attacker who controls a file path can read files outside the intended corpus directory. This could expose sensitive files such as SSH keys and API tokens, and may lead to remote code execution when combined with other flaws.
nltk
Originally disclosed on huntr
A vulnerability in NLTK versions up to and including 3.9.2 allows arbitrary file read via path traversal in multiple CorpusReader classes, including WordListCorpusReader, TaggedCorpusReader, and BracketParseCorpusReader. These classes fail to properly sanitize or validate file paths, enabling attackers to traverse directories and access sensitive files on the server. This issue is particularly critical in scenarios where user-controlled file inputs are processed, such as in machine learning APIs, chatbots, or NLP pipelines. Exploitation of this vulnerability can lead to unauthorized access to sensitive files, including system files, SSH private keys, and API tokens, and may potentially escalate to remote code execution when combined with other vulnerabilities.
From the GitHub Advisory Database (GHSA-68j8-pq59-fqgm, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the corpus reader classes join user-supplied paths to a base directory without normalising or restricting the result to that directory.
Impact
An attacker could read sensitive files such as SSH private keys and API tokens, and this may escalate to remote code execution when combined with other vulnerabilities.
What the attacker needed
User-controlled file path passed to a reader
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A path traversal bug lets someone use a file path like '../../secret.txt' to escape the folder the program meant to read from. Here, NLTK's corpus readers accept such paths without checking them, so a program that passes user input into these readers can be tricked into reading any file the server can access.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.