Summary
DeepWiki-Open contains an unauthenticated arbitrary file read vulnerability in the GET /codemap/file endpoint. An attacker may bypass path containment checks by supplying a non-URL value through repo_url, allowing access to files readable by the API process.
Affected context
The issue occurs in DeepWiki-Open deployments exposing the /codemap/file endpoint when the endpoint accepts attacker-controlled repo_url values and applies inconsistent validation based on whether the value resembles a URL. If path containment checks are bypassed, the API process may access files outside the intended repository or codemap directory.
Exploit preconditions
- Attack surface: The unauthenticated HTTP GET
/codemap/fileendpoint - Required access: Network access to the exposed API; authentication is not required
- Trigger point: Processing of the
repo_urlparameter during file lookup - Why exploitation is possible: Non-URL input can avoid expected repository-path validation, allowing absolute paths to reach file-access logic
Why this happens
The underlying bug is improper validation and normalization of an externally controlled file location. The endpoint applies path containment protections conditionally, so input that does not match the expected URL form can bypass those protections. This maps to CWE-73: External Control of File Name or Path, where attacker-controlled data influences filesystem access without consistently enforcing an approved directory boundary.
Potential impact
- Sensitive application, configuration, or source files may be disclosed
- Credentials, tokens, or private keys stored on the host may be exposed
- Internal deployment details may be revealed
- Retrieved information could support further compromise of the API host or connected systems
General mitigation guidance
Mitigation generally focuses on making file access explicitly allowlisted and independent of attacker-controlled path semantics.
Common defensive patterns include:
- Resolve and canonicalize paths before access, then enforce a single approved root directory
- Reject absolute paths, traversal components, and non-canonical representations by default
- Validate repository identifiers against trusted server-side metadata rather than accepting arbitrary paths
- Avoid conditional validation based solely on URL or input formatting
- Run the API with least-privilege filesystem permissions and minimize access to sensitive locations
- Apply authentication and authorization controls to file-serving endpoints where appropriate
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying filesystem APIs that consume request parameters
- Code review checks for missing canonicalization and inconsistent path-boundary enforcement
- Tests covering absolute paths, traversal sequences, URL-like and non-URL inputs, and symlink behavior
- Web-application monitoring for unusual file-read requests and repeated path-validation failures
- Policy enforcement requiring approved-root checks before filesystem access
Automated security review tools may help identify externally controlled path flows, but findings should be verified against deployment-specific filesystem permissions.

