/

CVE-2026-15631

Severity:

HIGH RISK

(8.7)

Path Traversal (CWE-22) in Fastify WebSocket Proxy

CVE-2026-15631

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Unauthorized Access to Internal Upstream Endpoints

Severity:

HIGH RISK

(8.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal flaw in @fastify/http-proxy's WebSocket routing allows crafted upgrade requests to bypass the configured rewrite prefix and reach unintended upstream endpoints.

When a non-normalizing WebSocket client or intermediary preserves dot-segment sequences in the request path, attackers may traverse out of the expected proxy scope and access internal services.

Affected context

This vulnerability appears in Node.js applications using @fastify/http-proxy versions 9.4.0 through 11.5.0 to forward WebSocket connections.

It manifests when the proxy is configured with a path rewrite prefix to constrain which upstream paths are exposed, and when upstream paths include sensitive or internal-only routes.

The issue becomes relevant in environments where WebSocket clients or intermediate proxies forward the original request target without normalizing dot-segment sequences (such as ../), potentially allowing escape from the intended rewrite prefix.

Exploit preconditions

  • Attack surface: WebSocket upgrade endpoints fronted by @fastify/http-proxy.
  • Required access: Ability to initiate WebSocket upgrade requests against the proxy (typically network-accessible, potentially unauthenticated).
  • Trigger point: A specially crafted request path containing traversal sequences (e.g., .. segments) sent through a client or downstream proxy that does not normalize the path before forwarding.
  • Why exploitation is possible: The WebSocketProxy.findUpstream logic constructs the upstream URL using the WHATWG URL API, which collapses dot segments. The proxy then fails to revalidate the resolved destination path against the configured rewrite prefix, allowing the normalized path to target upstream routes outside the allowed prefix.

Why this happens

The underlying defect is a path traversal issue where normalization and authorization checks are out of sync.

The WebSocket proxy logic relies on a rewrite prefix to constrain upstream routing, but it computes the destination using the WHATWG URL constructor, which normalizes the path by collapsing . and .. segments.

Because the code does not re-check the normalized path against the configured prefix, an attacker can embed traversal sequences in the original request, which are then resolved to a different upstream path than intended.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where path-based access control is enforced on unnormalized input or is not applied after canonicalization.

Potential impact

  • Attackers could reach upstream HTTP or WebSocket endpoints that were not meant to be exposed through the proxy.
  • Internal-only APIs or admin routes behind the proxy could become accessible from untrusted networks.
  • Security assumptions about path-based isolation and multi-tenant separation may be broken.
  • Unauthorized data access or modification could occur via unintended upstream routes.

General mitigation guidance

Mitigation typically centers on tightening path handling and validation in proxy routing logic.

Useful patterns include:

  • Applying path normalization (including dot-segment removal) before any authorization or prefix-matching logic, and then enforcing prefix checks on the normalized path.
  • Implementing an explicit allowlist of upstream routes or path patterns that the proxy is permitted to forward, rather than relying solely on string-based rewrite prefixes.
  • Treating user-supplied request targets as untrusted input and avoiding direct concatenation into upstream URLs without canonicalization and policy checks.
  • Segregating sensitive upstream endpoints onto separate virtual hosts or ports that are never reachable via general-purpose proxies, reducing exposure even if routing flaws occur.
  • Limiting the privileges of services exposed through the proxy so that unexpected access yields minimal impact.

How teams detect issues like this

Detection involves both code-centric and environment-focused approaches:

  • Static analysis and code review can flag routing logic that performs path rewrites or prefix checks without explicitly normalizing paths first.
  • Review WebSocket proxy implementations for reliance on client-side normalization assumptions, especially when using low-level HTTP upgrade handling.
  • Introduce automated tests that exercise edge-case paths (e.g., /prefix/../admin) through WebSocket endpoints and verify they are rejected or routed safely.
  • Leverage reverse-proxy or gateway policies to normalize paths and deny requests containing suspicious traversal patterns before they reach application code.
  • Use security scanning tools that model path traversal across proxies and WebSocket upgrades, focusing on mismatches between configured prefixes and effective upstream destinations.

Sources

SourceLink
cna.openjsf.orgcna.openjsf.org/security-advisories.html
github.comgithub.com/fastify/fastify-http-proxy/security/advisories/GHSA-7hrw-592w-9wh2

Frequently asked

questions

Yes. If a WebSocket upgrade endpoint using @fastify/http-proxy is exposed over the network and clients can send crafted request paths that are not normalized, an attacker can attempt to exploit the path traversal remotely.

The attacker generally needs only the ability to establish a WebSocket upgrade request to the vulnerable proxy. No application-level authentication is inherently required by the flaw, though existing authentication layers may still gate access to specific upstream routes.

The safest pattern is to normalize request paths (including dot segments) before any routing or prefix enforcement, then validate the canonical path against a strict allowlist or rewrite prefix. Avoid depending on client-side normalization and ensure that the post-normalization path is what governs upstream selection.

To prevent related bugs, design routing and proxy layers with canonicalization-first policies, enforce path-based access control only on normalized paths, and treat all request targets as untrusted. Complement this with automated tests, static checks focused on path handling, and architectural separation of sensitive upstream services from general proxy exposure.

Find out what's already
exploitable in your codebase.