CVE-2026-18504: fastify vulnerable to schema validation bypass via root primitive coercion mismatch
fastify is a fast and low overhead web framework for Node.js. Versions of fastify before 5.12.1 are affected by a schema validation bypass when a request body schema targets a root primitive value. When the schema validates a top-level primitive such as an integer, Ajv can coerce a JSON string into the expected type during validation, but Fastify does not replace the root request body with the coerced value, so the route handler receives the original unvalidated string. As a result, a request that should have failed validation can reach application logic with a value that does not satisfy the schema, which can undermine integrity and access-control checks that rely on the validated type. Users should upgrade to fastify 5.12.1, which fixes the mismatch. No known workarounds are available.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
fastifyto a version that resolves this vulnerability.Fixed in 5.12.1
Event History
Frequently Asked Questions
Which routes are most relevant to triage?
Applications using Fastify versions before 5.12.1 are exposed when a route validates its request body as a top-level primitive, such as an integer. Routes whose security or integrity decisions rely on the body having the validated primitive type are the relevant attack surface.
What does an attacker need to exploit this issue?
An attacker needs network access to a vulnerable route and the ability to send a JSON string where the route expects a root primitive value. The request can pass validation after Ajv coercion, while the handler receives the original string instead of the coerced primitive.
What remediation is available?
Upgrade Fastify to version 5.12.1. The advisory states that no known workarounds are available if upgrading cannot be done immediately.
How can we identify potentially affected application code?
Review routes that use request-body schemas with a top-level primitive type and determine whether handlers assume the received value has that validated type. Affected versions are Fastify releases before 5.12.1.