Summary
Zephyr's HTTP server static-filesystem handler concatenates attacker-controlled URL paths directly with a configured root directory without normalizing ./.. segments.
When a static FS resource is registered, an unauthenticated remote client can issue crafted HTTP/1 or HTTP/2 requests that traverse outside the web root and read arbitrary files from the mounted filesystem.
Affected context
This vulnerability appears in Zephyr-based systems that:
- Enable
CONFIG_FILE_SYSTEMand mount a filesystem (e.g., LittleFS, FAT) - Register an HTTP static-filesystem resource (
HTTP_RESOURCE_TYPE_STATIC_FS) - Use the built-in HTTP/1 or HTTP/2 front-ends without additional path validation
In such deployments, HTTP requests are processed by the static FS handler when wildcard or leading-directory matching routes the request path to that resource.
Exploit preconditions
- Attack surface: HTTP server endpoint exposed by a Zephyr-based device or application.
- Required access: Remote network reachability to the HTTP server; no authentication or TLS is required by default.
- Trigger point: A crafted URL path such as
/prefix/../../sensitive_filesent via HTTP/1GETor HTTP/2:pathheader. - Why exploitation is possible: The HTTP server copies the raw request path into
client_url_bufferand concatenates it with the configured static FS root usingsnprintk("%s%s", fs_path, client_url_buffer). The filesystem (fs_open) then resolves..segments, allowing traversal outside the intended web root.
Why this happens
The bug stems from treating the incoming URL path as a trusted, already-canonical filesystem path and failing to remove or normalize dot segments before resource lookup.
This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-23: Relative Path Traversal, where user-supplied relative paths (including ../) are concatenated with a base directory and handed to the filesystem.
The underlying pattern is direct string-based path construction from unvalidated input, relying on the filesystem to interpret and normalize the path instead of enforcing an application-level boundary.
Potential impact
- An attacker may read arbitrary readable files on the mounted volume.
- Sensitive configuration data, credentials, or keys could be exposed.
- Internal application logs and debugging information can be disclosed.
- Information leakage may enable further attacks against the device or backend services.
General mitigation guidance
Mitigation focuses on enforcing strict path canonicalization and directory boundaries before accessing the filesystem.
Common defensive patterns include:
- Canonicalizing URL paths by removing dot segments (
.and..) before routing or file resolution. - Rejecting requests that resolve outside the configured web root after normalization.
- Using high-level APIs that perform safe path joining and boundary checks rather than manual string concatenation.
- Limiting what is stored on or exposed via the mounted volume, and segregating sensitive data from web-served content.
- Applying least-privilege filesystem permissions so the HTTP server process can read only the minimum set of files required.
How teams detect issues like this
Organizations can detect similar path traversal issues through:
- Static analysis rules that flag direct concatenation of user-controlled paths with filesystem roots (e.g.,
base + user_pathbeforeopen/fs_open). - Code review checklists that require explicit path normalization and boundary checks for any file-serving or download endpoints.
- Unit and integration tests that send
../and./../sequences in request paths to confirm they are safely rejected or constrained. - Policy enforcement in CI pipelines to ensure HTTP and filesystem handlers always apply canonicalization routines and restrict traversal.

