CVE-2026-18504: Fastify Fastify Vulnerable To Schema Validation Vulnerability

MODERATE
Advisory Identifier: GHSA-w2qp-rph6-63g4
CVSS 5.4
CWE-20
Published
Advisory Summary

CVE-2026-18504 is a MODERATE (CVSS 5.4) fastify vulnerable to schema validation vulnerability (CWE-20: Improper Input Validation) affecting Fastify libraries in the npm ecosystem. The issue involves fastify vulnerable to schema validation bypass via root primitive coercion mismatch. Remediation is available by upgrading affected packages to version 5.12.1.

CVE-2026-18504 at a Glance

CVE Identifier CVE-2026-18504
GHSA Identifier GHSA-w2qp-rph6-63g4
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-20: Improper Input Validation
Affected Product Fastify
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-18504

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.

fastify fixed: 5.12.1
npm install fastify@5.12.1
Verify Direct and Transitive Dependencies

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-18504, 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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

### Impact `fastify` before 5.12.1, when a route uses a root-level primitive body schema (for example an integer with a minimum and maximum) and the default type coercion, validates the coerced value but exposes the original, uncoerced value to the route handler. For example, a JSON body `"10"` is coerced to the number `10` and passes an integer 1 to 10 schema, but `request.body` stays the string `"10"`. An application that trusts the validated type is handed a value that did not satisfy the schema, which can bypass limits the application enforces on that typed value. Object and array body schemas are not affected, they coerce their members in place. ### Patches Upgrade to `fastify` 5.12.1. ### Workarounds Until you can upgrade, avoid relying on the validated type of a root primitive body. Wrap the value in an object schema (object properties are coerced in place), for example accept `{ "value": 10 }` and read `request.body.value`, or re-check the type in the handler.

CVE-2026-18504 Affected Fastify Versions

1 component(s)
Fixed Versions:
5.12.1
Product / Package Ecosystem Affected Versions Fixed Version
fastify
npm
< 5.12.1
5.12.1

References

Frequently Asked Questions

What is CVE-2026-18504?
CVE-2026-18504 is a security vulnerability in Fastify involving fastify vulnerable to schema validation bypass via root primitive coercion mismatch under CWE-20: Improper Input Validation.
Which Fastify versions are affected?
Affected versions include releases prior to 5.12.1 across affected packages: fastify.
What version fixes CVE-2026-18504?
Upgrading to 5.12.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fastify affected?
Yes, fastify is affected in releases prior to 5.12.1. Upgrade your dependency to 5.12.1 or later.
What is the CVSS score of CVE-2026-18504?
CVE-2026-18504 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2026-18504?
CVE-2026-18504 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check npm dependencies for CVE-2026-18504?
Run the dependency tree command: 'npm ls fastify'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w2qp-rph6-63g4",
  "modified" : "2026-09-02T15:13:23Z",
  "published" : "2026-09-02T15:13:23Z",
  "aliases" : [ "CVE-2026-18504" ],
  "summary" : "fastify vulnerable to schema validation bypass via root primitive coercion mismatch",
  "details" : "### Impact\n\n`fastify` before 5.12.1, when a route uses a root-level primitive body schema (for example an integer with a minimum and maximum) and the default type coercion, validates the coerced value but exposes the original, uncoerced value to the route handler. For example, a JSON body `\"10\"` is coerced to the number `10` and passes an integer 1 to 10 schema, but `request.body` stays the string `\"10\"`. An application that trusts the validated type is handed a value that did not satisfy the schema, which can bypass limits the application enforces on that typed value. Object and array body schemas are not affected, they coerce their members in place.\n\n### Patches\n\nUpgrade to `fastify` 5.12.1.\n\n### Workarounds\n\nUntil you can upgrade, avoid relying on the validated type of a root primitive body. Wrap the value in an object schema (object properties are coerced in place), for example accept `{ \"value\": 10 }` and read `request.body.value`, or re-check the type in the handler.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fastify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.12.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify/security/advisories/GHSA-w2qp-rph6-63g4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-18504"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify/commit/1ef8a60c87e94f42f666aa15ad68957772a83655"
  }, {
    "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-20" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-02T15:13:23Z",
    "nvd_published_at" : "2026-08-18T21:16:34Z"
  }
}