Summary
A path traversal vulnerability in the knowns Document API allows user-controlled document paths to escape the configured documents directory. When the Management API is reachable and insufficiently protected, an unauthenticated remote attacker may read, create, overwrite, or delete host files ending in .md, and may create directories.
Affected context
The vulnerability occurs in the Document API when supplied document paths are normalized without removing parent-directory traversal sequences. The storage layer then joins the resulting path with the documents directory without confirming that the resolved location remains within that directory. Risk is highest in deployments where the Management API is unauthenticated, exposed beyond a trusted administrative network, and permitted to access a broadly writable or readable filesystem.
Exploit preconditions
- Attack surface: Document API HTTP endpoints, including document creation, retrieval, and deletion operations
- Required access: Network access to the Management API; authentication may not be required in default deployments
- Trigger point: Processing a user-controlled document path and constructing the filesystem target path
- Why exploitation is possible: Parent-directory segments are preserved during normalization, and the resulting path is not verified against the configured documents directory before filesystem operations occur
Why this happens
The underlying bug is insufficient canonicalization and containment validation for user-controlled filesystem paths. The handler removes selected formatting elements but does not neutralize traversal components, while the storage layer uses path joining without resolving the final path and enforcing that it remains beneath the intended base directory. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- An attacker may read sensitive documentation files outside the intended directory
- An attacker could create or overwrite files with a
.mdextension - An attacker may delete accessible matching files
- The application could create arbitrary directories through recursive directory creation
- Documentation for other projects may be exposed or corrupted
- The file-write primitive could be chained with another weakness toward code execution
General mitigation guidance
Mitigation generally focuses on treating document paths as untrusted identifiers rather than filesystem paths.
Common defensive patterns include:
- Resolve candidate paths against a trusted base directory and reject any result outside that directory
- Reject parent-directory components, absolute paths, and platform-specific separator variants
- Prefer opaque document IDs or tightly constrained relative names over user-selected filesystem paths
- Apply strict allowlists for permitted characters, extensions, and directory depth
- Use filesystem permissions and service identities that limit readable and writable locations
- Require authentication and authorization for management operations, and bind administrative APIs to trusted interfaces
- Avoid exposing arbitrary filesystem errors or path details in API responses
These controls reduce both direct traversal risk and the impact of a compromised application process.
How teams detect issues like this
Detection approaches commonly include:
- Static analysis rules for filesystem joins that use request parameters without canonicalization and containment checks
- Code review checks for path handling involving
filepath.Join, path normalization, file deletion, and recursive directory creation - Tests using parent-directory segments, absolute paths, encoded separators, and platform-specific path forms
- Runtime monitoring for document API requests containing traversal indicators or unusual encoded path components
- File-integrity monitoring for unexpected changes outside the configured documents directory
- Policy enforcement requiring authentication, network restrictions, and least-privilege filesystem access for management APIs
Automated code-review and software-composition tools may help identify related path-handling patterns, but should be supplemented with targeted behavioral tests.

