Summary
In affected Fastify proxy modules, client-supplied Connection headers are processed after the proxy has already added its own routing and security headers.
This enables attackers to selectively strip proxy-added headers from upstream requests, weakening access control, authentication, and other security logic whenever these headers are trusted.
Affected context
This vulnerability occurs in Node.js applications that use the Fastify ecosystem's proxy plugins (@fastify/reply-from and @fastify/http-proxy) to forward HTTP requests to upstream services.
It is relevant when the proxy injects headers for routing decisions, tenant isolation, authentication, or security checks, and relies on those headers being preserved.
In such deployments, client-controlled Connection headers are interpreted late in the pipeline, allowing them to influence which headers are ultimately sent to upstream servers.
Exploit preconditions
- Attack surface: HTTP interfaces fronted by Fastify using @fastify/reply-from or @fastify/http-proxy as reverse or service proxies.
- Required access: Ability to send crafted HTTP requests to the proxy, including custom Connection header values.
- Trigger point: The proxy's header rewriting stage, where it adds headers and then processes the client's Connection header afterward.
- Why exploitation is possible: The implementation allows the Connection header to declare hop-by-hop headers after the proxy has added them, causing those headers to be stripped before the request reaches the upstream.
Why this happens
The underlying issue is a misordering of header processing logic that mishandles hop-by-hop semantics for HTTP headers.
The proxy adds its own headers (for routing and security) and only afterwards interprets the client's Connection header, which can mark previously added headers as hop-by-hop and remove them.
This aligns with CWE-644: Improper Control of Hop-by-hop Messages, where intermediaries fail to correctly handle headers that should not be controlled by end clients, and CWE-444: Inconsistent Interpretation of HTTP Requests, since clients can influence how different components perceive and act on header state.
Potential impact
- Clients may bypass proxy-enforced authentication or authorization that relies on injected headers.
- Attackers could evade tenant or service routing constraints by stripping routing metadata headers.
- Upstream applications can be tricked into believing requests are internal or trusted when trust headers are removed or altered.
- Security monitoring, rate limiting, or audit mechanisms that depend on proxy-added headers can be weakened or misled.
General mitigation guidance
Mitigation centers on re-establishing strict control of hop-by-hop and security-critical headers at the proxy boundary.
Common defensive patterns include:
- Treating the Connection header as fully controlled by the proxy, ignoring or normalizing client-supplied Connection values.
- Performing header sanitization and hop-by-hop handling before adding security or routing headers, ensuring client input cannot retroactively affect them.
- Clearly separating user-controllable headers from proxy-managed headers, and avoiding trust in any header that a client can directly or indirectly influence.
- Designing security controls to rely on server-side context (such as authenticated identity) rather than only on injectable headers where feasible.
How teams detect issues like this
Organizations can detect this class of vulnerability by:
- Reviewing proxy middleware and plugins for logic that applies client-supplied Connection headers after adding internal headers.
- Using static analysis or linting rules that flag manipulation of hop-by-hop headers (e.g., Connection, Keep-Alive, Proxy-Authorization) based on untrusted input.
- Implementing code review checklists that require explicit handling of hop-by-hop headers and validation of security-related headers.
- Employing automated HTTP fuzzing or integration tests that send crafted Connection headers to verify that proxy-added security headers remain intact.

