Summary
NLTK through version 3.10.3 contains a path traversal vulnerability in model-artifact APIs that can bypass pathsec enforcement when raw file operations use caller-controlled paths. An attacker who can influence these paths may read or write files outside the intended sandbox roots.
Affected context
The issue can occur in NLTK deployments that enable pathsec protections while using model-artifact APIs such as TransitionParser, AveragedPerceptron, PerceptronTagger, or maxent parameter handling. Risk is higher when application-controlled or externally influenced path values reach raw filesystem operations without being normalized and verified against the permitted root.
Exploit preconditions
- Attack surface: NLTK model and parameter file APIs
- Required access: Ability to supply or influence a file path consumed by an affected API
- Trigger point: A model load, save, or parameter operation that performs filesystem access
- Why exploitation is possible: Raw file operations may use caller-controlled paths without consistently applying pathsec root restrictions
Why this happens
The vulnerability results from inconsistent enforcement of filesystem path boundaries. A security control may define approved sandbox roots, but affected code paths can perform direct file operations using an attacker-influenced path before or without applying equivalent canonicalization and containment checks. This maps to CWE-73: External Control of File Name or Path, in which untrusted input influences filesystem locations.
Potential impact
- An attacker may read sensitive files outside the intended model directory
- An attacker could overwrite application configuration or model artifacts
- Runtime behavior may be altered through unauthorized file modification
- Credentials, tokens, or other local secrets could be exposed
- Downstream applications may consume tampered model data
General mitigation guidance
Mitigation generally focuses on making filesystem boundaries consistent across every model-artifact operation.
Common defensive patterns include:
- Resolving and canonicalizing paths before access
- Enforcing containment within explicitly approved roots after resolution
- Using secure-by-default APIs that accept trusted directory handles or validated artifact identifiers instead of arbitrary paths
- Reducing input trust by treating model paths and parameters as untrusted at every boundary
- Rejecting traversal components, unexpected path forms, and symbolic-link escapes where appropriate
- Applying least-privilege filesystem permissions to the process and artifact directories
- Separating writable artifact locations from sensitive application and credential paths
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying raw file operations fed by external, configuration-derived, or API-provided paths
- Code review checks for missing canonicalization, root-containment validation, or symbolic-link handling
- Tests that verify every model-artifact API rejects paths outside its permitted directory
- Runtime monitoring for unexpected reads or writes outside approved model roots
- Policy enforcement requiring centralized path-validation helpers for filesystem access
- Automated security review tools that flag externally controlled filename and path flows

