Junglewise Threat Intelligence

CVE-2026-18504: Fastify schema validation bypass via root primitive coercion mismatch

CVE-2026-18504 · Severity: medium · CVSS 5.4 · Published 2026-09-02

Executive brief

Fastify, a popular Node.js web framework, has a flaw in how it validates and processes primitive request body data. When a route defines a schema expecting a number with size limits, Fastify validates the coerced number but actually passes the original string to the route handler. Applications that rely on the validated type to enforce constraints can be bypassed, potentially allowing unauthorized data to reach business logic. This affects applications using primitive-type request validation with default coercion settings.

Technical details

Fastify before 5.12.1 exhibits improper input validation (CWE-20) in its schema validation layer when handling root-level primitive body schemas with default type coercion enabled. The vulnerability stems from a mismatch between validation and data exposure: the framework coerces a value (e.g., string "10" to number 10), validates the coerced value against the schema (e.g., integer 1–10), but then exposes the original uncoerced value (string "10") to the route handler via request.body. An authenticated attacker can send a JSON request body with a primitive type that passes schema validation but whose uncoerced form violates application-enforced constraints. Object and array schemas are unaffected because they perform in-place coercion on their members. The vulnerability requires network access and authentication (PR:L); impact is limited to confidentiality and integrity (C:L/I:L). Fastify 5.12.1 resolves this by ensuring coerced values are exposed to handlers. Workarounds include wrapping primitives in object schemas or re-validating types in the handler.

Affected products

  • OpenJS Foundation Fastify < 5.12.1

Timeline

  • 2026-08-18: disclosed: Published to National Vulnerability Database
  • 2026-09-02: advisory: GitHub Advisory Database published GHSA-w2qp-rph6-63g4
  • 2026-09-02: patched: Fastify 5.12.1 released with fix

References

Related threats