Summary
A path traversal vulnerability in @fastify/http-proxy allows specially crafted backslash-based dot-segments to bypass the path boundary defined by proxy prefix and rewritePrefix settings. An unauthenticated network attacker may use this behavior to access upstream endpoints that were intended to remain hidden behind the proxy.
Affected context
The issue can occur in deployments using @fastify/http-proxy for plain HTTP forwarding when proxied request paths are validated incompletely. The vulnerable handling is relevant when the proxy relies on prefix or rewritePrefix boundaries and the upstream forwarding library rejects forward-slash traversal but does not equivalently reject backslash-based dot-segments.
Exploit preconditions
- Attack surface: Network-accessible HTTP proxy endpoint
- Required access: No authentication may be required when the proxy route is publicly reachable
- Trigger point: Processing and forwarding of a request containing backslash-based dot-segments
- Why exploitation is possible: Plain HTTP path validation does not consistently normalize or reject traversal variants before the request reaches the upstream
Why this happens
The vulnerability results from incomplete canonicalization and validation of proxied request paths. The plain HTTP request handler permits backslash-based dot-segments, while downstream validation recognizes only forward-slash traversal, allowing the effective path to escape the boundary established by proxy routing and rewriting rules. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because attacker-controlled path syntax can address resources outside the intended path scope.
Potential impact
- Unauthorized access to internal upstream routes
- Disclosure of administrative or diagnostic endpoint responses
- Exposure of sensitive application or service data
- Circumvention of proxy routing and access-control assumptions
- Increased risk of follow-on attacks against reachable upstream functionality
General mitigation guidance
Mitigation generally focuses on enforcing consistent path canonicalization and boundary validation before forwarding requests.
Common defensive patterns include:
- Normalize equivalent path separators and dot-segments before authorization and proxy rewriting
- Reject ambiguous traversal forms rather than relying on downstream components to interpret them
- Apply the same validation policy across plain HTTP and WebSocket request paths
- Define explicit allowlists for externally reachable upstream routes
- Avoid exposing administrative or internal endpoints through broadly accessible proxy routes
- Run upstream services with least privilege and limit sensitive endpoint access independently of the proxy
- Use maintained releases containing the relevant validation correction
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis and dependency review rules covering proxy path normalization and traversal checks
- Code review signals such as validation that handles forward slashes but not alternate separators
- Tests covering encoded, mixed-separator, and dot-segment path variants at every proxy boundary
- Integration tests verifying that prefix and rewritePrefix settings cannot reach unintended upstream paths
- Web application firewall or gateway policies that reject ambiguous traversal patterns
- Monitoring for unusual requests containing repeated dot-segments, alternate separators, or unexpected upstream route access

