GHSA-8mgp-746c-j5xp: Path Traversal
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.savetojson, savemaxentparams - 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.loadfromjson(), or loadmaxentparams(). 4. Observe the vulnerable APIs still read or write outside-root files successfully.
Minimal reproducible excerpt
text transitiontrainexists True transitionparseloaderreadbytes 13 averagedloadkeys ['bias'] maxentsave 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.
Affected Software
Event History
Frequently Asked Questions
Which versions are confirmed affected?
The issue was reproduced in the published 3.9.4 release and in current source v3.10.0-rc2. No patched version is listed.
Which model-artifact operations can bypass the intended path restrictions?
Affected flows include TransitionParser.train and TransitionParser.parse; AveragedPerceptron.save and AveragedPerceptron.load; PerceptronTagger.save_to_json; and save_maxent_params. The impacted operations include both reading from and writing to paths outside the allowed roots.
How can an environment determine whether it is affected?
Test an affected API with a model path outside the permitted roots while NLTK path security is enabled. An affected implementation permits the read or write through its raw file handling even though pathsec.open() or guarded sibling helpers reject the same path.
What can be done before a patch is available?
Do not allow untrusted callers to control model import or export paths for the affected APIs. Restrict supplied paths to approved locations and use guarded, pathsec-aware helpers where the application can do so.