---
id: "CVE-2026-81726"
kind: "vulnerability"
aliases: ["CVE-2026-81726", "GHSA-8mgp-746c-j5xp"]
title: "NLTK: Model-artifact APIs bypass pathsec and touch files outside allowed roots"
severity: "high"
cvss: 8.3
epss: 0.00339
exploited: false
status: "open"
category: "package"
products: [{"name": "nltk", "fixed": ["3.10.4"], "affected": "<= 3.10.3", "ecosystem": "pypi"}, {"name": "nltk", "fixed": ["3.10.3"], "affected": "< 3.10.3", "ecosystem": "vendor"}]
ecosystems: ["pypi", "vendor"]
tags: ["cwe-22", "cwe-59", "cwe-73", "nltk", "package", "pathsec", "python"]
not_affected_if: ["fixed-model-paths", "nltk-not-used-for-model-io", "no-pathsec-reliance"]
published_at: "2026-08-27T17:21:03+00:00"
first_seen_at: "2026-11-02T22:08:14+00:00"
updated_at: "2026-11-02T22:35:43+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-8mgp-746c-j5xp", "first_seen_at": "2026-11-02T22:08:14+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-81726", "first_seen_at": "2026-11-02T22:35:43+00:00"}]
---

# NLTK: Model-artifact APIs bypass pathsec and touch files outside allowed roots

NLTK's model import and export functions (perceptron tagger, transition parser, maxent) use plain file opens on caller-supplied paths, ignoring the pathsec restriction that other helpers enforce. An application that relies on pathsec to contain model file access can have files outside its allowed directories read or overwritten.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:nltk affected <= 3.10.3 fixed 3.10.4
- vendor:nltk affected < 3.10.3 fixed 3.10.3

## How to check

- Check the installed NLTK version with `pip show nltk`; affected versions are `3.10.3` and below.
- Search your code for calls to `TransitionParser.train`, `TransitionParser.parse`, `AveragedPerceptron.save`, `AveragedPerceptron.load`, `PerceptronTagger.save_to_json` or `save_maxent_params`, especially where the path comes from user input or a workflow.
- Check whether `pathsec.ENFORCE` is set to True in your application.

## Fix

- nltk: move to `3.10.4` (the fixed version named in the advisory data).

## Timeline

- 2026-11-02T22:08:14+00:00 ghsa https://github.com/advisories/GHSA-8mgp-746c-j5xp
- 2026-11-02T22:35:43+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-81726

## Documents

- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/nltk/nltk/security-advisories/GHSA-8mgp-746c-j5xp
- [advisory] Maintainer's advisory: github.com https://github.com/nltk/nltk/security/advisories/GHSA-8mgp-746c-j5xp
- [advisory] Third-party advisory: www.vulncheck.com https://www.vulncheck.com/advisories/nltk-through-3.10.3-path-traversal-via-model-artifact-apis
- [fix] Patch: github.com https://github.com/nltk/nltk/pull/3759
- [fix] Patch: github.com https://github.com/nltk/nltk/pull/3813
- [fix] Patch: github.com https://github.com/nltk/nltk/commit/2a92b71827d754ae8920261e7ed0c4bb283ab2d7
- [fix] Patch: github.com https://github.com/nltk/nltk/commit/a44a7af69bca87e92d9c4a701fcbbe4512e8d450
- [fix] Patch: github.com https://github.com/nltk/nltk/commit/cbc98458b43de5f792f0382583c16df39e5c5117
- [fix] Patch: github.com https://github.com/nltk/nltk/pull/3757

## From the sources

### Summary

Several model-artifact APIs still treat caller-controlled model paths as ordinary filenames even when NLTK path security is enforced. The same outside-root paths are rejected by guarded helpers, but these public read and write flows still use raw file APIs.

### Details

- **Vulnerability type:** File sandbox bypass
- **Affected component:** `TransitionParser.train`, `TransitionParser.parse`, `AveragedPerceptron.save`, `AveragedPerceptron.load`, `PerceptronTagger.save_to_json`, `save_maxent_params`
- **Affected versions:** Published `3.9.4` and current source `v3.10.0-rc2` both reproduced.
- **Patched versions:** Not yet patched
- **Root cause:** Model import and export helpers use built-in `open()` on caller-controlled paths instead of pathsec-aware helpers.

`TransitionParser.train()` writes outside allowed roots, `TransitionParser.parse()` reads outside allowed roots, `AveragedPerceptron` bypasses the sandbox in both directions, and adjacent read-side helpers in the same family already show the intended guarded behavior. I confirmed outside-root reads and writes while `pathsec.open()` or the guarded sibling helpers rejected the same paths.

### PoC

**Preconditions**
- The application enables `pathsec` enforcement and lets untrusted workflows choose model import or export paths.

**Steps**
1. Enable `pathsec.ENFORCE=True` and restrict allowed roots to a dedicated sandbox directory.
2. Use public model import or export APIs with paths that point outside that root.
3. Observe the same paths are rejected by negative-control guarded helpers such as `pathsec.open()`, `PerceptronTagger.load_from_json()`, or `load_maxent_params()`.
4. Observe the vulnerable APIs still read or write outside-root files successfully.

**Minimal reproducible excerpt**

```text
transition_train_exists True
transition_parse_loader_read_bytes 13
averaged_load_keys ['bias']
maxent_save wrote ['alwayson.tab', 'labels.txt']
```

### Impact

Consumers that rely on `pathsec` for local containment can be tricked into reading or overwriting files outside approved roots through normal model persistence and loading APIs.

### Remediation

Route all model-path file access through `nltk.pathsec.open()` or existing pathsec-aware helpers, and add regression tests that pair each vulnerable API with a negative control on the same path.

### References

- https://github.com/nltk/nltk/blob/v3.10.0-rc2/nltk/parse/transitionparser.py#L551-L571
- https://github.com/nltk/nltk/blob/v3.10.0-rc2/nltk/tag/perceptron.py#L106-L113
- https://github.com/nltk/nltk/blob/v3.10.0-rc2/nltk/tag/perceptron.py#L262-L273
- https://github.com/nltk/nltk/blob/v3.10.0-rc2/nltk/classify/maxent.py#L1583-L1602

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
