NLTK has Arbitrary File Read via Absolute Path Input in nltk.util.filestring()
The filestring() function in nltk.util opens files based on user-supplied paths without validation, allowing an attacker to read arbitrary files by providing absolute or traversal paths. This could expose sensitive system files when the function is used in web APIs or other interfaces that accept user input.
nltk/nltk
Originally disclosed on huntr
A vulnerability in the filestring() function of the nltk.util module in nltk version 3.9.2 allows arbitrary file read due to improper validation of input paths. The function directly opens files specified by user input without sanitization, enabling attackers to access sensitive system files by providing absolute paths or traversal paths. This vulnerability can be exploited locally or remotely, particularly in scenarios where the function is used in web APIs or other interfaces that accept user-supplied input.
From the GitHub Advisory Database (GHSA-h8wq-7xc4-p3qx, 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 filestring() function directly opens the user-supplied path without validating or restricting it to a safe directory.
Impact
An attacker could read sensitive system files, potentially leading to information disclosure, especially if the function is exposed through a web API.
What the attacker needed
User input reaches filestring(); function used in an accessible interface
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 function in a Python library takes a file path from the user and opens it without checking whether the path is safe. An attacker can give a path to a sensitive file on the server, such as a password file, and the function will read it. This is dangerous when the function is used in a web service that accepts input from users.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.