CVE-2026-18504: fastify vulnerable to schema validation bypass via root primitive coercion mismatch

Published Aug 18, 2026
·
Updated

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.

Other sources

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.

MITRE

Affected Software

3 affected componentsFixes available
npm/fastify<5.12.1
fastify Fastify Node.js<5.12.1
npm/fastify<5.12.1
5.12.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/fastify to a version that resolves this vulnerability.

    Fixed in 5.12.1
  2. Upgrade

    Upgrade fastify to a version that resolves this vulnerability.

    Fixed in 5.12.1
  3. Configuration

    Until upgraded, avoid relying on the validated type of a root primitive request body schema; instead wrap the value in an object schema (e.g., accept {"value":10} and use request.body.value) or re-check the value’s type in the route handler.

    Fastify route body schema design Root primitive body schema usage with type coercion = Avoid (use object wrapper or re-check type in handler)

Event History

Aug 18, 2026
CVE Published
via MITRE·08:19 PM
Data Sourced
via MITRE·08:19 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:16 PM
DescriptionSeverityWeaknessAffected Software
Sep 2, 2026
Advisory Published
via GitHub·03:13 PM
Data Sourced
via GitHub·03:13 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

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.

2

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.

3

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.

4

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203