Improper Validation of Specified Type of Input Affecting fastify package, versions <5.12.1


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.31% (25th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-FASTIFY-18965901
  • published19 Aug 2026
  • disclosed18 Aug 2026
  • creditvelgusgus599

Introduced: 18 Aug 2026

NewCVE-2026-18504  (opens in a new tab)
CWE-1287  (opens in a new tab)

How to fix?

Upgrade fastify to version 5.12.1 or higher.

Overview

fastify is an overhead web framework, for Node.js.

Affected versions of this package are vulnerable to Improper Validation of Specified Type of Input via the request validation path in lib/validation.js. An attacker can bypass body schema type enforcement by sending a root-level primitive JSON body such as "10" to a route that expects an integer. Fastify validates the coerced primitive value but leaves request.body as the original uncoerced string when the handler runs. Applications that trust the validated type can then apply business rules to the wrong type, breaking input limits and other request-body checks.

Workarounds

  • Wrap the value in an object schema instead of using a root primitive body, for example accept { "value": 10 } and read request.body.value; this keeps coercion in-place and prevents the handler from seeing an uncoerced root string.
  • Re-check the type in the route handler before applying business rules; this prevents trust in a root primitive body value that may not match the validated type.

CVSS Base Scores

version 4.0
version 3.1