CVE-2026-16732: Fastify Fastify Vulnerable To X-Forwarded-* Spoofing Vulnerability
MODERATECVE-2026-16732 is a MODERATE (CVSS 6.1) fastify vulnerable to x-forwarded-* spoofing vulnerability (CWE-348: Use of Less Trusted Source) affecting Fastify libraries in the npm ecosystem. The issue involves fastify vulnerable to x-forwarded-* spoofing under trustproxy hop-count. Remediation is available by upgrading affected packages to version 5.12.1.
CVE-2026-16732 at a Glance
Security Impact
CVSS: 6.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N).
How to Fix CVE-2026-16732
To remediate this vulnerability, upgrade all affected Fastify dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install fastify@5.12.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls fastify
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-16732, inspect your project dependencies using npm:
npm ls fastify
Analyze the terminal output to locate any version of Fastify in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.12.1), your application is affected.
Note: The npm ls fastify command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-348: Use of Less Trusted Source, where the product has two different sources of the same data or information, but it uses the source that has less support for verification, is less trusted, or is less resistant to attack. In Fastify, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-16732 Affected Fastify Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastify
|
npm |
≥ 5.8.3
< 5.12.1
|
5.12.1
|
References
Frequently Asked Questions
What is CVE-2026-16732?
Which Fastify versions are affected?
What version fixes CVE-2026-16732?
Is fastify affected?
What is the CVSS score of CVE-2026-16732?
What CWE is associated with CVE-2026-16732?
How can I check npm dependencies for CVE-2026-16732?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3m5p-2c4r-xxw2",
"modified" : "2026-09-02T15:14:06Z",
"published" : "2026-09-02T15:14:06Z",
"aliases" : [ "CVE-2026-16732" ],
"summary" : "fastify vulnerable to X-Forwarded-* spoofing under trustProxy hop-count",
"details" : "## Impact\n\nThe fix for [CVE-2026-3635](https://www.cve.org/CVERecord?id=CVE-2026-3635) ([GHSA-444r-cwp2-x5xf](https://github.com/fastify/fastify/security/advisories/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`.\n\nApplications 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.\n\n## Patches\n\nPatched in fastify 5.12.1. The numeric form of `trustProxy` is now disabled at runtime and removed from the TypeScript type union.\n\n## Workarounds\n\n- 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.\n- Ensure the Fastify origin is only reachable through the trusted proxy chain (no direct network path).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "fastify"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.8.3"
}, {
"fixed" : "5.12.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify/security/advisories/GHSA-3m5p-2c4r-xxw2"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-16732"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify/commit/8acfea7eada05383a7357e3eb21c2628416df280"
}, {
"type" : "WEB",
"url" : "https://cna.openjsf.org/security-advisories.html"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify/releases/tag/v5.12.1"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-348" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-02T15:14:06Z",
"nvd_published_at" : "2026-08-18T21:16:34Z"
}
}