Summary
DeepCode contains a path traversal vulnerability in the SPA catch-all route that allows unauthenticated attackers to read arbitrary files on the server.
By sending percent-encoded path segments to the GET /{full_path:path} endpoint, an attacker can bypass Starlette's path normalization and access files outside the intended FRONTEND_DIST directory, potentially exposing sensitive credentials and configuration data.
Affected context
This vulnerability affects deployments of DeepCode that:
- Expose the new UI backend with the SPA catch-all route defined in
new_ui/backend/main.py - Serve frontend assets from a directory (FRONTEND_DIST) using a dynamic
{full_path:path}parameter - Construct filesystem paths from HTTP request paths without robust normalization or validation
The risk is highest on servers where application processes have read access to sensitive files such as SSH keys, TLS certificates, environment configuration, or secrets mounted in the filesystem.
Exploit preconditions
- Attack surface: Public HTTP endpoint
GET /{full_path:path}on the DeepCode backend. - Required access: No authentication required; the issue is reachable by any network client able to send HTTP requests to the service.
- Trigger point: An HTTP GET request containing percent-encoded traversal sequences (e.g.,
%2Ffor/,%2E%2Efor..) in thefull_pathparameter. - Why exploitation is possible: The server joins the user-supplied path segments with the FRONTEND_DIST directory but relies on Starlette's normalization, which is bypassed by percent-encoded characters. As a result, the final resolved path can escape the intended directory and point to arbitrary readable files on the host.
Why this happens
The core issue is insufficient validation and normalization of user-controlled path input before using it in filesystem operations, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
The SPA catch-all route accepts a flexible {full_path:path} parameter and constructs a file path based on this value to serve static assets. Instead of strictly enforcing that the resulting path remains within the FRONTEND_DIST directory, the code assumes that Starlette's routing and basic normalization are sufficient. Because the implementation does not canonicalize the path after decoding percent-encoded characters and does not enforce a directory boundary check (e.g., via realpath comparison), encoded traversal sequences like %2F and %2E%2E allow the computed path to navigate above the root assets directory and into arbitrary filesystem regions. This insecure pattern—concatenating or joining filesystem paths with untrusted path fragments without post-join validation—is a classic directory traversal bug.
Potential impact
- Disclosure of SSH private keys readable by the application user, which may enable lateral movement or host impersonation.
- Exposure of TLS private keys and certificates used by the application or co-located services.
- Leakage of application configuration files, environment files, or secret mounts containing database credentials, API keys, and tokens.
- Access to source code, templates, or internal configuration, aiding further exploitation and vulnerability discovery.
- Potential disclosure of user data or logs if they are stored in readable locations accessible by the process.
General mitigation guidance
Effective mitigation focuses on strict path handling, directory boundary enforcement, and principle of least privilege:
- Constrain path resolution to a known root:
- After decoding and joining the requested path with FRONTEND_DIST, canonicalize the result (e.g., resolve symlinks and
..segments) and verify that the final absolute path is still within the expected base directory. - Reject any request where the resolved path falls outside the allowed directory or points to directories rather than expected asset files.
- Avoid manual path concatenation with untrusted input:
- Use framework- or library-provided static file serving mechanisms that implement safe path normalization and traversal protections by default.
- If a custom handler is necessary, restrict allowable paths to a whitelist of known patterns or file extensions (e.g.,
.html,.js,.css) rather than accepting arbitrary paths. - Normalize and validate after decoding:
- Decode percent-encoded characters early, then normalize the path and re-run traversal checks on the canonical representation, not on the raw string.
- Treat any traversal-related sequences (
.., absolute paths, or device paths) as invalid input and respond with a generic error. - Reduce filesystem exposure:
- Run the application under a dedicated, low-privilege account with limited read access, ensuring that highly sensitive files (SSH keys, TLS keys, secrets) are not readable by the DeepCode process.
- Isolate sensitive material in directories not shared with the web application, and avoid mounting such directories into the application container when possible.
How teams detect issues like this
Detection typically combines code-centric and operational approaches:
- Static analysis and code review:
- Flag uses of
{path}-style parameters that are passed intoos.path.join,Path(), or similar APIs without: - Canonicalization of the resulting path, and
- An explicit check that the canonical path remains under a configured base directory.
- Look for manual implementations of SPA catch-all routes or static file serving that do not use hardened framework middleware.
- Add linting rules or secure coding guidelines that prohibit raw file access from user-controlled paths without a boundary check.
- Dynamic testing and fuzzing:
- Incorporate security tests that probe endpoints with path parameters using encoded traversal sequences (e.g.,
%2F,%5C,%2E%2E) and confirm that files outside the intended static directory are not accessible. - Use DAST tools or custom scripts to attempt retrieval of well-known sensitive files (
/etc/passwd, private keys, environment files) through the catch-all route. - Operational monitoring:
- Monitor access logs for suspicious patterns such as repeated requests containing
%2E%2E,%2F, or references to system directories. - Configure WAF or API gateways with rules that block or alert on obvious directory traversal signatures, including encoded variants.

