Skip to content
Path traversal Disclosed report Beginner CVE-2026-65915

NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol

The sandbox check in NLTK's FileSystemPathPointer.open() is dead code because it compares a normalised path against itself, so the guard never triggers. An attacker who can influence the argument to nltk.data.load() or find() can read any file the process can access by supplying a file:// URL.

nltk/nltk

Originally disclosed on huntr

Summary

There's a logic bug in FileSystemPathPointer.open() inside nltk/data.py that makes the sandbox check permanently inert. The guard condition is always False — meaning any file the process can read is accessible by passing a file:// URL to nltk.data.load().


Details

In nltk/data.py, FileSystemPathPointer.open() was patched at some point with a comment saying "SECURITY PATCH ENFORCING SANDBOX", but the check doesn't work:

Python
def open(self, encoding=None):
    path = os.path.normpath(self._path)

    # Block raw absolute reads such as "/" "C:\\Windows" etc.
    if os.path.isabs(path) and path != os.path.normpath(self._path):
        raise ValueError(f"Direct absolute file access blocked: {path}")

    stream = open(self._path, "rb")

path is set to os.path.normpath(self._path) on line 1, then compared against os.path.normpath(self._path) again in the condition. They are always equal. The ValueError never fires.

On top of that, __init__ already calls os.path.abspath() before storing self._path, so it's normalized before open() is even called. Running normpath on it again changes nothing.

The stream = open(self._path, "rb") line is always reached regardless of what path was passed in.


PoC

Tested on Python 3.11, NLTK 3.9.1, Ubuntu 22.04.

Python
import nltk
from nltk.data import FileSystemPathPointer

# direct construction
ptr = FileSystemPathPointer("/etc/passwd")
with ptr.open() as f:
    print(f.read(300))

# via load() using file:// URL
data = nltk.data.load("file:///etc/passwd", format="raw")
print(data[:300])

Both print file contents. No exception is raised.


Impact

Any app that lets users influence the string passed to nltk.data.load() or nltk.data.find() is exposed — web APIs, notebook servers, multi-tenant pipelines. An attacker can read any file the process user has access to: /etc/passwd, .env files, private keys, ~/.aws/credentials, etc.

Suggested Fix

File: nltk/data.py — FileSystemPathPointer.open() (lines 378–390)

What's wrong

Line 387 compares normpath(self._path) against itself — always equal, so the ValueError never fires. The check is dead code. __init__ already calls abspath() on construction, so re-running normpath inside open() changes nothing either.


Fix

Validate against the actual list of permitted data directories instead:

Python
def open(self, encoding=None):
    import nltk.data as _d
    allowed = [os.path.abspath(p) for p in _d.path if p]
    if allowed and not any(
        os.path.commonpath([self._path, r]) == r for r in allowed
    ):
        raise ValueError(
            f"Access outside nltk_data blocked: {self._path!r}"
        )
    stream = open(self._path, "rb")
    if encoding is not None:
        stream = SeekableUnicodeStreamReader(stream, encoding)
    return stream

Why commonpath not startswith

startswith is bypassable by a path that shares a prefix:

/tmp/nltk_data_evil".startswith("/tmp/nltk_data") → True  ✗
commonpath(["/tmp/nltk_data_evil", "/tmp/nltk_data"]) → "/tmp"  ✓

Diff

Diff
-    path = os.path.normpath(self._path)
-    if os.path.isabs(path) and path != os.path.normpath(self._path):
-        raise ValueError(f"Direct absolute file access blocked: {path}")
-
+    import nltk.data as _d
+    allowed = [os.path.abspath(p) for p in _d.path if p]
+    if allowed and not any(
+        os.path.commonpath([self._path, r]) == r for r in allowed
+    ):
+        raise ValueError(f"Access outside nltk_data blocked: {self._path!r}")
     stream = open(self._path, "rb")

From the GitHub Advisory Database (GHSA-72r2-7mfr-5xr9, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

NLTK is a Python library for natural language processing. One of its core facilities is the nltk.data module, which locates and loads data files (corpora, tokenizers, taggers and similar resources) from a set of configured data directories, collectively referred to as nltk_data. The public entry points are nltk.data.load() and nltk.data.find(), and both accept a resource URL. Among the supported schemes is file://, which is handled by FileSystemPathPointer.

FileSystemPathPointer wraps a filesystem path. Its __init__ normalises the supplied path with os.path.abspath() before storing it in self._path, and its open() method is what actually opens the file and returns a stream. Because load() and find() accept a caller-supplied string, any application that passes user input into those functions is effectively passing user input into a file open.

The report describes a logic bug in FileSystemPathPointer.open() in nltk/data.py that makes a sandbox check permanently inert. The guard condition is always False, so any file the process can read is reachable by passing a file:// URL to nltk.data.load().

Setup

The researcher tested on Python 3.11, NLTK 3.9.1 and Ubuntu 22.04. No accounts, roles or special configuration are involved: the precondition is simply that an application lets a user influence the string passed to nltk.data.load() or nltk.data.find(), and that the process user can read the target file.

Finding it

At some point FileSystemPathPointer.open() was patched with a comment reading "SECURITY PATCH ENFORCING SANDBOX". The patched method contains a check that cannot work:

Python
def open(self, encoding=None):
    path = os.path.normpath(self._path)

    # Block raw absolute reads such as "/" "C:\\Windows" etc.
    if os.path.isabs(path) and path != os.path.normpath(self._path):
        raise ValueError(f"Direct absolute file access blocked: {path}")

    stream = open(self._path, "rb")

path is assigned os.path.normpath(self._path) on the first line, and the condition then compares it against os.path.normpath(self._path) again. The two values are always equal, so the ValueError never fires. On top of that, __init__ already calls os.path.abspath() before storing self._path, so the path is normalised before open() is even called, and running normpath on it again changes nothing. The stream = open(self._path, "rb") line is always reached regardless of what path was passed in.

Exploitation

Step 1: construct a pointer directly

The first demonstration bypasses load() entirely and builds a FileSystemPathPointer for a sensitive file:

Python
import nltk
from nltk.data import FileSystemPathPointer

# direct construction
ptr = FileSystemPathPointer("/etc/passwd")
with ptr.open() as f:
    print(f.read(300))

FileSystemPathPointer("/etc/passwd") stores the absolute path, and open() reaches the raw open(self._path, "rb") call without any exception. The first 300 bytes of /etc/passwd are printed.

Step 2: reach the same code through load() with a file:// URL

The second demonstration goes through the public API:

Python
# via load() using file:// URL
data = nltk.data.load("file:///etc/passwd", format="raw")
print(data[:300])

nltk.data.load() accepts the file:// URL and the file contents are returned. The same dead check is passed and the file contents are returned. Both snippets print file contents and no exception is raised.

Root cause

The guard compares a value against itself. path is defined as os.path.normpath(self._path) and the condition tests path != os.path.normpath(self._path), which is always false, so the ValueError branch is unreachable. The check is dead code.

A second, independent reason the check could not have worked is that __init__ already calls os.path.abspath() on construction. By the time open() runs, self._path is already normalised, so re-running normpath inside open() has no effect on the comparison either. The only thing standing between a caller-supplied path and the filesystem was this inert condition, and the raw open(self._path, "rb") call is unconditional.

Impact

Any application that lets users influence the string passed to nltk.data.load() or nltk.data.find() is exposed. The report names web APIs, notebook servers and multi-tenant pipelines as examples. An attacker can read any file the process user has access to, including /etc/passwd, .env files, private keys and ~/.aws/credentials. An attacker can read any file the process user has access to.

Fix

The suggested fix replaces the self-comparison with validation against the actual list of permitted data directories, nltk.data.path:

Python
def open(self, encoding=None):
    import nltk.data as _d
    allowed = [os.path.abspath(p) for p in _d.path if p]
    if allowed and not any(
        os.path.commonpath([self._path, r]) == r for r in allowed
    ):
        raise ValueError(
            f"Access outside nltk_data blocked: {self._path!r}"
        )
    stream = open(self._path, "rb")
    if encoding is not None:
        stream = SeekableUnicodeStreamReader(stream, encoding)
    return stream

The report locates the vulnerable code at nltk/data.py, FileSystemPathPointer.open(), lines 378 to 390, with the faulty comparison on line 387. The corresponding diff is:

Diff
-    path = os.path.normpath(self._path)
-    if os.path.isabs(path) and path != os.path.normpath(self._path):
-        raise ValueError(f"Direct absolute file access blocked: {path}")
-
+    import nltk.data as _d
+    allowed = [os.path.abspath(p) for p in _d.path if p]
+    if allowed and not any(
+        os.path.commonpath([self._path, r]) == r for r in allowed
+    ):
+        raise ValueError(f"Access outside nltk_data blocked: {self._path!r}")
     stream = open(self._path, "rb")

The report also explains why the fix uses commonpath rather than startswith. A prefix check is bypassable by a path that merely shares a prefix with an allowed directory:

Text
/tmp/nltk_data_evil".startswith("/tmp/nltk_data") → True  ✗
commonpath(["/tmp/nltk_data_evil", "/tmp/nltk_data"]) → "/tmp"  ✓

The report shows commonpath returning /tmp for the two paths.

Variants to test

  1. Other URL schemes in the same loader. Try file:// variants with different path forms (relative paths, paths with .. segments, trailing slashes) against nltk.data.load() and nltk.data.find(). A positive result is file contents returned from outside the configured data directories.
  2. Direct pointer construction in library consumers. Look for code that builds FileSystemPathPointer from user input rather than going through load(). A positive result is the same arbitrary read without the URL parsing step.
  3. Prefix-based allowlists elsewhere. Search for startswith checks against directory paths in other loaders and resource resolvers. A positive result is a sibling directory whose name extends an allowed prefix (for example nltk_data_evil next to nltk_data) being accepted.
  4. Self-comparison guards. Grep for conditions that compare a variable against the same expression used to define it, especially in code carrying comments about security patches or sandboxing. A positive result is a guard that can never raise, confirmed by reaching the code path it was meant to block.

Hunting notes

This bug hides in code that looks defended: a comment announcing a security patch, a ValueError with a reassuring message, and a condition that reads plausibly at a glance. The signal during review is any guard whose two sides are derived from the same expression, or any check performed on a value that an earlier stage has already normalised. Security-patch comments added after the fact are worth reading line by line, because a patch that never fires is worse than no patch: it suggests the issue was considered and closed.

The impact depends on whether user input reaches these functions. The researcher showed both the direct construction and the load("file:///etc/passwd", format="raw") path, and both return file contents with no exception. That combination, a dead guard plus a public entry point that accepts a caller-supplied string, is what makes the finding actionable rather than a code-quality note.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

NLTK is a free toolkit for Python programmers who work with human language: it helps a program split text into words, tag parts of speech, or load large collections of example sentences. Those collections of data files live in folders on the computer, and NLTK has a small piece of code whose job is to find and open them. That piece of code is called nltk.data.

At some point the code was patched, with a comment announcing a security patch enforcing a sandbox. The check does not work. It compares a value with itself, so the answer is always "these are the same", and the error that was supposed to stop the read is never raised. The result is that anyone who can influence the text handed to NLTK's loading function can make the program open any file the program is allowed to read, such as the system's list of user accounts or a file of secret keys.

This kind of mistake is called a logic bug: the code runs without crashing, but it does not do what it was written to do. The security consequence here is arbitrary file read, meaning an attacker can choose which file gets read, rather than being limited to the intended data folders.

The pieces involved

Before the details, a few terms that come up constantly.

  • Python is a programming language. A program written in it is a text file that the Python interpreter runs.
  • A library is a bundle of ready-made code that other programs can use, so they do not have to write everything from scratch. NLTK is a library.
  • A function is a named block of code that does one job and can be called by name. nltk.data.load() is a function: you give it a piece of text and it gives you back data.
  • A module is a file of Python code that groups related functions. nltk/data.py is the module that contains the loading code.
  • A path is the address of a file or folder on a computer, such as /etc/passwd on Linux.
  • A URL is an address written in the form a browser understands, such as https://example.com/page. The part before the colon (https) is the scheme, and it tells the software how to interpret the rest.
  • An API is the set of functions a library offers to the programs that use it. When we say "the public API", we mean the functions that outside programs are expected to call, as opposed to internal helpers.

NLTK's data module keeps a list of folders it is allowed to look in, collectively called nltk_data. Two public functions are the entry points:

  • nltk.data.load() takes a resource URL and returns the data.
  • nltk.data.find() takes a resource URL and returns where the resource is.

Both accept a string supplied by whoever calls them. If a web application passes a value typed in by a user straight into one of these functions, then the user is effectively choosing a file path. That is the dangerous situation.

Among the URL schemes NLTK understands is file://, which means "this is a path on the local disk". The code that handles file:// is a class called FileSystemPathPointer.

  • A class is a template for an object: it bundles some data with the functions that operate on that data.
  • An object is one concrete instance made from a class.
  • __init__ is the special function Python runs when an object is created, used to set up its starting data.
  • self._path is the object's stored path. The leading underscore is a convention meaning "internal, not for outside use".

FileSystemPathPointer.__init__ cleans up the path it is given with os.path.abspath() and stores the result in self._path. Its open() method is the one that actually opens the file and hands back a stream for reading.

  • os.path.abspath() turns a path into a full absolute path, starting from the root of the filesystem, and resolves things like . and ...
  • os.path.normpath() tidies up a path's spelling, for example removing doubled slashes.
  • A stream is an object you read bytes from, a bit like a tap you turn on to get water.

Setting the scene

The researcher tested on Python 3.11, NLTK 3.9.1 and Ubuntu 22.04. No accounts, special roles or configuration are needed. The only precondition is that an application lets a user influence the string passed to nltk.data.load() or nltk.data.find(), and that the account running the program is allowed to read the target file. The second condition is the ordinary situation: a program usually runs as some user, and that user can read a lot of files.

Finding it

At some point FileSystemPathPointer.open() was patched, and the patch carried a comment reading "SECURITY PATCH ENFORCING SANDBOX". A sandbox is a restricted area: the idea is that the code should only be able to touch files inside the approved folders, like a child allowed to play only inside a fenced garden.

The patched method contains a check that cannot work:

Python
def open(self, encoding=None):
    path = os.path.normpath(self._path)

    # Block raw absolute reads such as "/" "C:\\Windows" etc.
    if os.path.isabs(path) and path != os.path.normpath(self._path):
        raise ValueError(f"Direct absolute file access blocked: {path}")

    stream = open(self._path, "rb")

Line by line:

  1. def open(self, encoding=None): declares the method. self is the object it belongs to, and encoding is an optional text encoding, defaulting to none.
  2. path = os.path.normpath(self._path) makes a tidied-up copy of the stored path and puts it in a local variable called path.
  3. The comment says the next lines are meant to block raw absolute reads, giving / and C:\Windows as examples of what should be refused.
  4. if os.path.isabs(path) and path != os.path.normpath(self._path): is the guard. os.path.isabs(path) asks "is this an absolute path?", and the second half asks "is path different from the tidied-up stored path?". Both halves must be true for the guard to fire.
  5. raise ValueError(...) is the refusal: it stops the method with an error message saying direct absolute file access was blocked.
  6. stream = open(self._path, "rb") is the real work: it opens the stored path for reading in binary mode ("rb") and keeps the stream.

The flaw is in line 4. path was defined on line 2 as exactly os.path.normpath(self._path), and the condition then compares it against os.path.normpath(self._path) again. The two sides are the same expression, so they are always equal, and path != ... is always false. The ValueError never fires.

There is a second, independent reason the check could not have worked. __init__ already calls os.path.abspath() before storing self._path, so the path is already normalised before open() is even called. Running normpath on it again changes nothing. The stream = open(self._path, "rb") line is always reached, whatever path was passed in.

A useful everyday comparison: imagine a door guard whose instruction is "stop anyone whose name is not the same as their own name". Nobody can ever fail that test, so the guard waves everyone through while looking busy.

Exploitation

Exploitation means actually using the weakness to get a result you should not get. The researcher did it in two ways, to show both the low-level route and the route a real application would expose.

Step 1: construct a pointer directly

The first demonstration skips load() entirely and builds a FileSystemPathPointer for a sensitive file:

Python
import nltk
from nltk.data import FileSystemPathPointer

# direct construction
ptr = FileSystemPathPointer("/etc/passwd")
with ptr.open() as f:
    print(f.read(300))

Line by line:

  1. import nltk loads the NLTK library so its code is available.
  2. from nltk.data import FileSystemPathPointer picks the class out of the data module so it can be used by its short name.
  3. The comment marks the start of the direct construction.
  4. ptr = FileSystemPathPointer("/etc/passwd") creates an object for the file /etc/passwd. On Linux, /etc/passwd is a long-standing system file listing user accounts. It is a classic test target because it exists on almost every Linux machine and is readable by everyone, so reading it proves the read works without needing any special privileges.
  5. with ptr.open() as f: opens the file and gives the stream the name f. The with form automatically closes the file when the block ends, even if something goes wrong.
  6. print(f.read(300)) reads the first 300 bytes and prints them.

FileSystemPathPointer("/etc/passwd") stores the absolute path, and open() reaches the raw open(self._path, "rb") call without any exception. The first 300 bytes of /etc/passwd are printed.

Why do this step at all? Because it isolates the broken method. If this works, we know the guard itself is dead, independently of any URL parsing.

Step 2: reach the same code through load() with a file:// URL

The second demonstration goes through the public API:

Python
# via load() using file:// URL
data = nltk.data.load("file:///etc/passwd", format="raw")
print(data[:300])

Line by line:

  1. The comment says this goes through load() using a file:// URL.
  2. data = nltk.data.load("file:///etc/passwd", format="raw") calls the public loading function with a URL whose scheme is file, meaning "read from the local disk", and whose path is /etc/passwd. The format="raw" argument tells NLTK to return the file as plain data rather than trying to interpret it as a particular kind of corpus.
  3. print(data[:300]) prints the first 300 characters of the returned data.

nltk.data.load() accepts the file:// URL and the file contents are returned. The same dead check is passed and the file contents are returned. Both snippets print file contents and no exception is raised.

Why do this step? Because it goes through the public loading function that applications call. Showing that the same read happens through that door proves the bug matters in practice, not just in a test script.

Root cause

The root cause is the underlying reason the bug exists, as opposed to its symptoms. Here it is a guard that compares a value against itself. path is defined as os.path.normpath(self._path), and the condition tests path != os.path.normpath(self._path), which is always false, so the ValueError branch can never be reached. The check is dead code: code that exists in the file but can never run.

A second, independent reason the check could not have worked is that __init__ already calls os.path.abspath() on construction. By the time open() runs, self._path is already normalised, so re-running normpath inside open() has no effect on the comparison either. The only thing standing between a caller-supplied path and the filesystem was this inert condition, and the raw open(self._path, "rb") call is unconditional.

Impact

Impact is what an attacker gains. Any application that lets users influence the string passed to nltk.data.load() or nltk.data.find() is exposed. The report names web APIs, notebook servers and multi-tenant pipelines as examples.

  • A web API is a service that other software talks to over the network, receiving requests and returning data. If one of its inputs ends up in load(), a remote user can choose the file.
  • A notebook server is a web application that runs code for its users, often shared between several people.
  • A multi-tenant pipeline is a data-processing setup where several customers' jobs run on the same machine. One customer reading another's files is a serious problem.

An attacker can read any file the process user has access to, including /etc/passwd, .env files, private keys and ~/.aws/credentials.

  • A .env file is a small text file where applications commonly keep configuration secrets such as database passwords.
  • A private key is the secret half of a cryptographic key pair, used to prove identity or decrypt data. Leaking one can let an attacker impersonate a server or a user.
  • ~/.aws/credentials is the default file where Amazon Web Services command-line tools store access keys. ~ means the current user's home folder.

An attacker can read any file the process user has access to.

Fix

The suggested fix replaces the self-comparison with validation against the actual list of permitted data directories, nltk.data.path:

Python
def open(self, encoding=None):
    import nltk.data as _d
    allowed = [os.path.abspath(p) for p in _d.path if p]
    if allowed and not any(
        os.path.commonpath([self._path, r]) == r for r in allowed
    ):
        raise ValueError(
            f"Access outside nltk_data blocked: {self._path!r}"
        )
    stream = open(self._path, "rb")
    if encoding is not None:
        stream = SeekableUnicodeStreamReader(stream, encoding)
    return stream

Line by line:

  1. def open(self, encoding=None): is the same method signature as before.
  2. import nltk.data as _d imports the data module under the short name _d, so its list of allowed folders can be read.
  3. allowed = [os.path.abspath(p) for p in _d.path if p] builds a list of the configured data folders, each turned into an absolute path, skipping any empty entries. This is a list comprehension, a compact Python way of writing "for each item, do this and collect the results".
  4. if allowed and not any( starts the guard. It only applies if at least one folder is configured, and it fires when none of the allowed folders matches.
  5. os.path.commonpath([self._path, r]) == r for r in allowed is the matching test, repeated for each allowed folder r. os.path.commonpath() returns the deepest folder that both paths share. If that shared folder is exactly the allowed folder r, the file is inside it.
  6. ): closes the condition.
  7. raise ValueError( begins the refusal.
  8. f"Access outside nltk_data blocked: {self._path!r}" is the message, with the offending path inserted. The !r prints it in a quoted, unambiguous form.
  9. ) closes the call.
  10. stream = open(self._path, "rb") opens the file, now only reached when the path passed the check.
  11. if encoding is not None: checks whether a text encoding was requested.
  12. stream = SeekableUnicodeStreamReader(stream, encoding) wraps the raw byte stream in a reader that decodes text and can be rewound, which NLTK needs for some data formats.
  13. return stream hands the stream back to the caller.

The report locates the vulnerable code at nltk/data.py, FileSystemPathPointer.open(), lines 378 to 390, with the faulty comparison on line 387. The corresponding diff is:

Diff
-    path = os.path.normpath(self._path)
-    if os.path.isabs(path) and path != os.path.normpath(self._path):
-        raise ValueError(f"Direct absolute file access blocked: {path}")
-
+    import nltk.data as _d
+    allowed = [os.path.abspath(p) for p in _d.path if p]
+    if allowed and not any(
+        os.path.commonpath([self._path, r]) == r for r in allowed
+    ):
+        raise ValueError(f"Access outside nltk_data blocked: {self._path!r}")
     stream = open(self._path, "rb")

A diff is a side-by-side view of a change: lines starting with - are removed, lines starting with + are added, and lines with no marker are left alone. Here the two removed lines are the broken guard, and the added lines are the new check against the allowed folders. The final stream = open(...) line is unchanged and stays.

The report also explains why the fix uses commonpath rather than startswith. A prefix check with startswith asks "does this path begin with the allowed folder's name?". That is bypassable by a path that merely shares a prefix with an allowed directory:

Text
/tmp/nltk_data_evil".startswith("/tmp/nltk_data") → True  ✗
commonpath(["/tmp/nltk_data_evil", "/tmp/nltk_data"]) → "/tmp"  ✓

The first line shows a path that shares a prefix with the allowed directory. The cross mark marks that as wrong. The second line shows commonpath returning /tmp for the two paths. The tick marks that as correct. The everyday version: a prefix check is like admitting anyone whose surname starts with "Smith", which lets in "Smithson" too; comparing whole names does not.

Variants to test

These are follow-up ideas for anyone auditing similar code. A variant here means a related place where the same kind of mistake might appear.

  1. Other URL schemes in the same loader. Try file:// variants with different path forms (relative paths, paths with .. segments, trailing slashes) against nltk.data.load() and nltk.data.find(). A positive result is file contents returned from outside the configured data directories. .. in a path means "go up one folder", so it is a common way to climb out of an intended directory.
  2. Direct pointer construction in library consumers. Look for code that builds FileSystemPathPointer from user input rather than going through load(). A positive result is the same arbitrary read without the URL parsing step.
  3. Prefix-based allowlists elsewhere. Search for startswith checks against directory paths in other loaders and resource resolvers. A positive result is a sibling directory whose name extends an allowed prefix (for example nltk_data_evil next to nltk_data) being accepted.
  4. Self-comparison guards. Grep for conditions that compare a variable against the same expression used to define it, especially in code carrying comments about security patches or sandboxing. A positive result is a guard that can never raise, confirmed by reaching the code path it was meant to block. To grep is to search through files for a piece of text.

Hunting notes

This bug hides in code that looks defended: a comment announcing a security patch, a ValueError with a reassuring message, and a condition that reads plausibly at a glance. The signal during review is any guard whose two sides are derived from the same expression, or any check performed on a value that an earlier stage has already normalised. Security-patch comments added after the fact are worth reading line by line, because a patch that never fires is worse than no patch: it suggests the issue was considered and closed.

The impact case here rests on reachability: whether an attacker can actually get their input to the vulnerable code. The researcher showed both the direct construction and the load("file:///etc/passwd", format="raw") path, and both return file contents with no exception. That combination, a dead guard plus a public entry point that accepts a caller-supplied string, is what makes the finding actionable rather than a code-quality note.

Glossary

  • API: the set of functions a library or service offers to the programs that use it.
  • Arbitrary file read: a weakness that lets an attacker choose and read any file the program can access.
  • Class: a template in object-oriented programming that bundles data with the functions that work on it.
  • commonpath: a Python function that returns the deepest folder two paths share.
  • Dead code: code that exists in a file but can never run.
  • Diff: a view of a code change showing removed lines with - and added lines with +.
  • .env file: a text file where applications often store configuration secrets.
  • Exploitation: actually using a weakness to obtain a result you should not get.
  • Filesystem permissions: the operating system's rules about which users may read or write which files.
  • Function: a named block of code that performs one job and can be called by name.
  • Grep: to search through files for a piece of text.
  • Impact: what an attacker gains from a weakness.
  • Library: a bundle of ready-made code that other programs can use.
  • List comprehension: a compact Python syntax for building a list from another collection.
  • Logic bug: a mistake where code runs without crashing but does not do what it was written to do.
  • Module: a file of Python code grouping related functions.
  • Multi-tenant pipeline: a data-processing setup where several customers' jobs run on the same machine.
  • Notebook server: a web application that runs code for its users, often shared between several people.
  • Object: one concrete instance created from a class.
  • os.path.abspath(): a Python function that turns a path into a full absolute path and resolves . and ...
  • os.path.normpath(): a Python function that tidies the spelling of a path.
  • Path: the address of a file or folder on a computer.
  • Prefix check: a test that asks whether a string begins with a given sequence of characters.
  • Private key: the secret half of a cryptographic key pair, used to prove identity or decrypt data.
  • Python: a programming language, and the interpreter that runs programs written in it.
  • Reachability: whether an attacker can actually get their input to the vulnerable code.
  • Root cause: the underlying reason a bug exists, as opposed to its symptoms.
  • Sandbox: a restricted area that code is only allowed to operate within.
  • Scheme: the part of a URL before the colon, such as https or file, that says how to interpret the rest.
  • Stream: an object you read data from, like a tap you turn on.
  • URL: an address in the form software and browsers understand, such as https://example.com/page.
  • Variant: a related place where the same kind of mistake might appear.
  • Web API: a service that other software talks to over the network, receiving requests and returning data.
  • __init__: the special Python function that runs when an object is created, used to set up its starting data.

More from nltk/nltk

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.