Summary
In affected @fastify/http-proxy configurations, decoded route parameters can alter the upstream path beyond the prefix intended by the application. An unauthenticated remote attacker may reach unintended upstream locations, potentially enabling SSRF or bypassing authorization in the proxied service.
Affected context
The issue affects applications using @fastify/http-proxy versions 9.0.0 through 11.6.5 with parameterized prefix and rewritePrefix options. It becomes risky when decoded route parameters are incorporated into the rewritten upstream URL without safe encoding, and the upstream relies on the configured path prefix to limit access.
Exploit preconditions
- Attack surface: An HTTP route exposed through the proxy
- Required access: No authentication is required when the affected route is publicly reachable
- Trigger point: Processing a request whose route parameters are substituted into
rewritePrefix - Why exploitation is possible: Decoded separators and URL delimiters can change the resulting upstream path and remove an intended suffix or path constraint
Why this happens
The underlying issue is inconsistent interpretation of URL components: parameter values are URL-decoded and then inserted into a rewritten path without being re-encoded. This can turn data treated as a route parameter into meaningful path, query, or fragment delimiters. It relates to CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-436: Interpretation Conflict, because the proxy and upstream may interpret the resulting URL differently.
Potential impact
- An attacker may reach upstream paths outside the intended prefix
- The proxy may expose upstream functionality that was meant to be restricted
- Depending on upstream behavior, requests could enable server-side request forgery
- Authorization controls in a proxied service could be bypassed
General mitigation guidance
Defensive patterns focus on preserving path boundaries and avoiding trust in decoded route parameters when constructing upstream URLs.
- Prefer fixed, explicitly allowlisted upstream paths over user-influenced path construction
- Encode parameter values appropriately for the URL component where they are used
- Validate route parameters against narrow, expected character sets and formats
- Enforce upstream authorization independently of proxy path restrictions
- Treat proxy path rewriting as a security boundary and test that unexpected delimiters cannot change the destination
The vulnerability description identifies no workaround other than using a fixed release; configuration-only controls should not be assumed to fully address it.
How teams detect issues like this
- Review proxy configuration and code for parameterized
prefixandrewritePrefixcombinations - Use static analysis to flag decoded user-controlled values concatenated into URL paths without context-appropriate encoding
- Add tests that verify path constraints remain intact when route parameters contain reserved URL characters
- Apply policy checks that require explicit upstream destination and path allowlists
- Review proxy and upstream logs for requests reaching paths outside the expected prefix

