Summary
Network-AI's InputSanitizer.sanitizePath() can incorrectly accept paths that share a string prefix with the intended base directory. If an attacker can provide a path to this check, they may be able to read, list, or write files outside the sandbox.
Affected context
The issue occurs in path validation performed by InputSanitizer.sanitizePath(). It becomes risky when attacker-controlled paths are checked against a sandbox directory using an unanchored string-prefix test, rather than verifying that the normalized path is actually contained within the base directory. The available description identifies Network-AI versions before 5.15.5 as affected.
Exploit preconditions
- Attack surface: A Network-AI feature or interface that accepts paths and passes them to
InputSanitizer.sanitizePath() - Required access: Ability to submit or influence a path; authentication requirements depend on the interface and deployment
- Trigger point: Path validation before a file is read, listed, or written
- Why exploitation is possible: A sibling-directory path can share the base directory's string prefix and pass an unanchored
startsWithcheck despite being outside the intended directory
Why this happens
The underlying bug is improper path containment validation, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). A string-prefix comparison does not establish directory ancestry: a path in a sibling directory may begin with the same characters as the permitted base path. Validation should account for normalized path components and confirm containment using path-aware operations.
Potential impact
- An attacker may read files outside the sandbox, subject to the process's permissions.
- An attacker could list directory contents beyond the intended boundary.
- An attacker may write or modify files outside the sandbox if the process has write access.
- Exposure or alteration of accessible files could affect application confidentiality or integrity.
General mitigation guidance
Defensive patterns focus on enforcing directory containment with filesystem-aware checks rather than raw string-prefix comparisons.
- Normalize and resolve candidate paths, then verify they remain within the intended base using component-aware path operations.
- Prefer APIs that accept a trusted directory handle or otherwise constrain file access to an approved root.
- Apply allowlists for expected paths where practical, and treat user-supplied path components as untrusted.
- Account for symbolic links and filesystem changes when designing containment checks.
- Run the application with least-privilege filesystem permissions so a path-validation failure has limited impact.
How teams detect issues like this
- Use static analysis to flag path validation based on raw
startsWithor similar string-prefix comparisons. - Review file-access flows for user-controlled paths and check whether validation occurs before reads, listings, and writes.
- Add tests for sibling directories with names sharing a prefix with the permitted base, as well as normalized paths and symbolic-link cases.
- Enforce code-review or CI policies requiring path-aware containment checks for sandboxed file operations.

