/

CVE-2026-54293

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in NLTK nltk.data.load() URLs

CVE-2026-54293

Modified

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal flaw in NLTK's nltk.data.load() allows attackers to bypass regex-based path safety checks by using URL-encoded traversal sequences in the custom nltk: URL scheme.

When an application trusts attacker-controlled nltk: URLs, this bug can lead to arbitrary file reads from the local filesystem, exposing configuration data, secrets, or other sensitive content.

Affected context

This vulnerability appears in Python applications that use NLTK's nltk.data.load() with the nltk: URL scheme and rely on its documented path safety protections.

It is relevant when the URL passed to nltk.data.load() can be influenced by external input (such as user-supplied paths, configuration, or network-provided resource identifiers) and the environment exposes sensitive files readable by the NLTK process.

Exploit preconditions

  • Attack surface: Any code path that calls nltk.data.load() with an nltk: URL derived from untrusted or semi-trusted input.
  • Required access: Ability to supply or modify the nltk: URL string (e.g., via HTTP parameters, API fields, plug-in configuration, or job definitions in a system embedding NLTK).
  • Trigger point: Invocation of nltk.data.load() where the unsafe-path regex runs before url2pathname() decoding, allowing encoded traversal segments to pass.
  • Why exploitation is possible: The validation logic checks for traversal patterns on the still-encoded URL value; after validation, url2pathname() decodes %xx sequences, turning previously hidden separators and ".." segments into a real filesystem path that is then opened.

Why this happens

The bug stems from performing security checks on data in a different representation than the one ultimately used for filesystem access.

NLTK's unsafe-path regex is applied to the raw nltk: URL string, which still contains percent-encoded characters (%2f for '/', %2e for '.', etc.).

Once validation passes, url2pathname() decodes these sequences, transforming apparently safe input into paths containing directory separators and traversal segments.

This encode-then-check-then-decode pattern maps to CWE-22, where insufficient path sanitization enables directory traversal, and more broadly to a classic "decode-after-check" / time-of-check to time-of-use discrepancy in input validation logic.

Potential impact

  • An attacker may read arbitrary files accessible to the NLTK-running process.
  • Sensitive configuration files (keys, tokens, database credentials) could be exposed.
  • Application-level secrets and private data stores can be disclosed indirectly via NLTK-powered features.
  • Local file disclosure may be chained into further compromise, such as credential reuse against other services.

General mitigation guidance

Effective mitigation patterns center on treating paths and URLs as untrusted input and normalizing them before enforcing security checks.

Common strategies include:

  • Performing decoding, normalization, and canonicalization before any path validation or allow/deny decisions.
  • Ensuring path checks operate on resolved filesystem paths with traversal sequences removed or strictly confined to an expected base directory.
  • Restricting file access to whitelisted directories or resource identifiers, rather than relying solely on blacklist-style regex checks.
  • Avoiding direct use of user-controlled path fragments and instead mapping external identifiers to internal resource names via lookup tables.
  • Running NLTK-consuming components with least-privilege filesystem access to constrain the blast radius of any path traversal.

How teams detect issues like this

Organizations can identify similar traversal issues by:

  • Applying static analysis rules that flag decode-after-check patterns (e.g., validation on encoded URLs followed by decoding and filesystem access).
  • Reviewing calls to nltk.data.load() and other resource loaders that accept URL-like strings, focusing on paths influenced by external input.
  • Enforcing secure coding policies that require path normalization and base-directory confinement before opening files.
  • Using security-focused code review checklists to ask whether any path validation operates on a different representation than the one actually used.
  • Employing automated application security testing tools that attempt encoded traversal payloads against endpoints using NLTK-backed resource loading.

Sources

SourceLink
github.comgithub.com/nltk/nltk/pull/3575
github.comgithub.com/nltk/nltk/security/advisories/GHSA-p4gq-832x-fm9v
access.redhat.comaccess.redhat.com/errata/RHSA-2026:42644
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-54293
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2491486
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-54293.json

Frequently asked

questions

Exploitability depends on how an application integrates nltk.data.load(). It becomes risky when untrusted input can influence nltk: URLs; in tightly controlled environments where all URLs are hard-coded, the practical exposure is much lower.

Not necessarily. If a web API, microservice, or batch job accepts path-like values or resource identifiers from remote users and passes them into nltk.data.load(), then remote, unauthenticated attackers may be able to exploit the flaw. Otherwise, exploitation may be constrained to authenticated or internal users.

The most robust approach is to ensure all URL decoding and path normalization happen before validation and to enforce that any resolved path is strictly confined to a known base directory or mapped from an internal whitelist of resources, instead of trusting arbitrary caller-supplied paths.

Treat all paths and URLs as untrusted data, design loaders around whitelisted resource identifiers, normalize and canonicalize paths before checking them, adopt secure coding standards for filesystem access, and integrate static analysis and code review practices that explicitly look for traversal patterns and decode-after-check logic.

Find out what's already
exploitable in your codebase.