Summary
An unauthenticated path traversal in devpi-web's documentation route can allow requests to access files outside the documentation directory. Depending on the server's file permissions, exposed files may include the keyfs SQLite database, which contains password hashes.
Affected context
The issue affects devpi-web versions before 5.2.0 in the +doc documentation route. The docs_file_exists and docs_file_path helpers in doczip.py do not confine the resolved relative path to the documentation directory, so specially formed paths may reach files elsewhere on the server.
Exploit preconditions
- Attack surface: The
+docdocumentation route - Required access: No authentication is required to make a request to the route
- Trigger point: Handling a documentation request whose relative path resolves outside the documentation directory
- Why exploitation is possible: The path helpers do not enforce that the resolved file remains within the intended documentation directory
Why this happens
The underlying bug is improper limitation of a pathname to a restricted directory, corresponding to CWE-22: Path Traversal. The route uses a user-influenced relative path without reliably checking that the resulting path stays within the documentation root, allowing access to files beyond the intended area.
Potential impact
- Attackers may read files accessible to the devpi-web process.
- Exposed files could reveal sensitive configuration or application data.
- Disclosure of the keyfs SQLite database may expose stored password hashes.
- Further compromise may be possible if accessible files contain credentials or other secrets.
General mitigation guidance
Defensive approaches focus on confining file access to an explicitly defined documentation root.
- Resolve and canonicalize paths, then verify the result remains within the allowed directory.
- Prefer APIs that safely join paths beneath a trusted root and reject paths that escape it.
- Avoid treating request-provided path components as trusted filesystem locations.
- Run the service with least-privilege filesystem permissions and limit access to sensitive data files.
- Keep sensitive databases and secrets outside directories or permissions reachable by the documentation-serving process.
How teams detect issues like this
- Use static analysis to identify request-controlled paths passed to filesystem operations without canonicalization and containment checks.
- Review route handlers and file-serving helpers for path joins that do not enforce a trusted base directory.
- Add automated tests and policy checks to ensure traversal paths are rejected and resolved paths remain within approved roots.
- Monitor access logs for unusual documentation requests and unexpected attempts to retrieve non-documentation files.

