MediumGHSA-3m5p-2c4r-xxw2CVE-2026-16732

fastify vulnerable to X-Forwarded-* spoofing under trustProxy hop-count

Published 2 Sept 2026 · Updated 2 Sept 2026

Is your project on an affected fastify?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Affected package

Affected
>=5.8.3 <5.12.1
Fixed in
5.12.1
Update to the fixed version for your release line, for example:npm install fastify@5.12.1

Details

Impact

The fix for CVE-2026-3635 (GHSA-444r-cwp2-x5xf) added a proxyFn(socket.remoteAddress, 0) guard on the X-Forwarded-* reads in request.host, request.protocol, request.hostname, request.ip, and request.ips. That guard closes the IP, CIDR, and custom-function forms of trustProxy correctly because those forms compile to predicates that inspect the connecting address. The hop-count form (trustProxy: <number>) compiles to a predicate that structurally ignores the address argument, so the guard reduces to 0 < tp, always true for any tp >= 1.

Applications configured with trustProxy: <number> (documented as "behind N reverse proxies", trustProxy: 1 being the canonical single-proxy setting) remain vulnerable. An attacker who can reach the Fastify origin directly, bypassing the front-facing proxy, can spoof the request fields exactly as in the unpatched version. Impact class matches the parent CVE-2026-3635: host injection in generated URLs, HTTPS-enforcement bypass, secure-cookie / CSRF-origin bypass, host-based routing and cache poisoning.

Patches

Patched in fastify 5.12.1. The numeric form of trustProxy is now disabled at runtime and removed from the TypeScript type union.

Workarounds

  • Migrate to an IP / CIDR / custom-function trustProxy value that validates the connecting address. Custom functions must inspect the address argument, not only the hop index.
  • Ensure the Fastify origin is only reachable through the trusted proxy chain (no direct network path).

Is GHSA-3m5p-2c4r-xxw2 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected fastify, and gives you the command that fixes it.

More advisories for fastify

  • LowCVE-2026-107832fastify is vulnerable to header validation bypass via case-sensitive propertyNames · 22 Oct 2026
  • MediumCVE-2026-92081fastify vulnerable to Denial of Service via unhandled exception on HTTP/2 trailer responses · 30 Sept 2026
  • HighCVE-2026-84504fastify vulnerable to request body replacement via an async validation result collision · 30 Sept 2026
  • HighCVE-2026-76169fastify vulnerable to authentication bypass via malformed URLs reaching encapsulated not-found handlers · 30 Sept 2026
  • HighCVE-2026-84469fastify vulnerable to request validation bypass via skipped boolean false schemas · 30 Sept 2026
  • HighCVE-2026-84428fastify vulnerable to header validation bypass via incomplete schema case normalization · 30 Sept 2026
All 18 advisories for fastify

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.