Summary
A routing flaw in http-proxy-middleware allows crafted Host headers to be matched via unanchored substrings against router proxy-table host+path entries.
Under certain configurations, this can cause requests to be proxied to unintended backends, enabling abuse of internal services or bypass of expected routing controls.
Affected context
This vulnerability appears in Node.js applications that rely on http-proxy-middleware's router proxy-table using host+path selectors. It is relevant where upstream routing decisions are made based on the Host header, and multiple backends are configured behind a single entry point. Systems are most exposed when internal or privileged services are reachable via proxy rules that expect exact host+path matches, but do not enforce strict hostname validation or normalization on incoming requests.
Exploit preconditions
- Attack surface: HTTP endpoints fronted by http-proxy-middleware using router proxy-table host+path rules.
- Required access: Ability to send arbitrary HTTP requests to the application, including controlling the Host header and URL path.
- Trigger point: The router logic evaluates the attacker-supplied Host header and path against configured host+path keys using substring matching.
- Why exploitation is possible: The host+path comparison logic is not anchored or normalized, so superstring or partial matches can satisfy routing rules intended for more specific hostnames, causing misrouting to backends not meant for the requester.
Why this happens
The underlying issue is an input validation and comparison flaw in routing logic. The router proxy-table documentation describes host+path selectors as if they were precise identifiers, but the implementation uses unanchored substring matching against attacker-controlled request metadata. This corresponds to CWE-187: Partial Comparison and CWE-20: Improper Input Validation, where untrusted Host headers and paths are not strictly validated or canonicalized before being used for security-sensitive routing decisions. As a result, a request whose Host header merely contains a configured key as a substring can be treated as a valid match.
Potential impact
- Requests may be routed to unintended internal or privileged backends.
- Attackers could access internal admin APIs or microservices indirectly exposed via proxy rules.
- Security controls that rely on hostname-based separation can be bypassed.
- Misrouted traffic can lead to data exposure or modification in backends not meant to serve the attacker.
- Confusion in logging and monitoring due to traffic appearing under unexpected routes.
General mitigation guidance
Effective mitigation focuses on treating routing criteria as security-sensitive inputs and enforcing strict comparisons. Common patterns include:
- Using exact, anchored hostname and path matching rather than substring or partial comparisons.
- Normalizing and validating Host headers and request paths before using them in routing decisions.
- Restricting reliance on client-controlled Host headers when determining backend selection; prefer explicit configuration or trusted headers added by front proxies.
- Designing proxy rules so internal or sensitive backends are not reachable solely based on host+path matching, and applying additional authorization checks.
- Applying defense-in-depth controls such as network segmentation and least-privilege access for backends behind the proxy.
How teams detect issues like this
Detection typically involves reviewing routing and proxy configurations for partial or substring-based matching:
- Static analysis or configuration linting to flag non-anchored matches on Host or path values used for backend selection.
- Code review focused on how http-proxy-middleware's router proxy-table is configured, checking for assumptions of exact matches.
- Security tests that fuzz Host headers and paths to observe whether requests can be routed to unintended backends.
- Policy enforcement that requires strict equality or pattern anchoring for host/path routing rules and discourages direct use of untrusted Host headers.
- Use of automated review tools that understand common Node.js proxy patterns and can highlight unsafe routing logic.

