Summary
WebP Server Go on Windows mishandles path normalization, allowing percent-encoded backslashes to bypass directory restrictions around the configured IMG_PATH.
An unauthenticated attacker can craft HTTP requests that traverse directories and read arbitrary files accessible to the server process outside the intended image root.
Affected context
This vulnerability affects WebP Server Go deployments running on Windows where the server:
- Relies on
path.Clean()or similar logic to sanitize request paths - Exposes HTTP endpoints that map URL paths to files under a configured IMG_PATH
- Runs under an account that has read access to sensitive files on the host
The issue arises from a mismatch between Go's forward-slash-only path cleaning and the Windows filesystem, which treats both forward slashes and backslashes as directory separators.
Exploit preconditions
- Attack surface: Public or internal HTTP interface of WebP Server Go on Windows
- Required access: No authentication required; network reachability to the server is sufficient
- Trigger point: File-serving handlers in
handler/router.gothat: - Decode URL paths
- Pass them through
path.Clean()(or equivalent) - Join the result with IMG_PATH and open files on disk
- Why exploitation is possible: The sanitizer normalizes only forward slashes, but Windows APIs treat decoded backslashes (
\) as path separators. By embedding percent-encoded backslashes (%5C) in the URL, an attacker can construct paths that escape the IMG_PATH directory after cleaning and gain read access to unintended filesystem locations.
Why this happens
The root cause is a path traversal flaw stemming from platform-inconsistent path normalization (CWE-22). The code trusts path.Clean() to enforce containment within a configured root directory, but path.Clean() is designed for slash-separated paths and does not consider backslashes as directory separators.
On Windows, once the percent-encoded backslashes are decoded, the OS-level file APIs interpret them as valid path separators, effectively reintroducing ..-style traversal or cross-directory access that the application believed it had neutralized. This mismatch between application-level sanitization and underlying filesystem semantics creates an insecure pattern where user-controlled paths are insufficiently validated before being used in file operations.
Potential impact
- Attackers may read arbitrary files accessible to the WebP Server Go process, including configuration files and application logs.
- Credentials, tokens, or API keys stored on disk could be disclosed and reused in further attacks.
- Sensitive user data or internal system information (e.g., environment-specific configuration, hostnames, network layout) could be exposed.
- File disclosure may facilitate follow-on attacks such as privilege escalation, lateral movement, or service impersonation.
General mitigation guidance
Effective mitigation focuses on enforcing strict, platform-aware path handling and minimizing the trust placed in user-supplied paths:
- Use path-joining and cleaning APIs that are appropriate for the underlying OS (e.g.,
filepath.Cleanandfilepath.Joinin Go on Windows). - Normalize both forward slashes and backslashes at the earliest point, or reject requests containing unexpected separator characters.
- After computing the target path, verify that it remains within the intended root directory by comparing canonical/absolute paths before allowing access.
- Implement a whitelist-based approach to file access (e.g., serving only from a curated directory tree or a manifest of allowed resources) instead of directly mirroring user-specified paths.
- Run the server with least-privilege filesystem permissions so that even if traversal occurs, the process cannot read highly sensitive system or application files.
How teams detect issues like this
Detection typically combines code-centric and operational approaches:
- Static analysis and code review:
- Flag any use of user-controlled path segments passed into file operations (
os.Open,ioutil.ReadFile, etc.) without explicit root containment checks. - Verify that path normalization uses OS-aware APIs and that both forward slashes and backslashes are considered on Windows.
- Look for path-join patterns that trust
path.Clean()or equivalent without subsequent validation of the resulting absolute path. - Security testing and DAST:
- Use automated scanners or custom test harnesses to probe file-serving endpoints with encoded traversal patterns (e.g.,
%2e%2e%5C,%5C..%5C) and monitor responses for unexpected file contents. - Runtime monitoring:
- Enable logging of requested paths and the resolved filesystem paths, then alert on access attempts outside the configured IMG_PATH.
- Monitor access to unusually sensitive files by the WebP Server Go process, using host-based intrusion detection or EDR tools.

