Fastify vulnerable to invalid content-type parsing, which could lead to validation bypass
Published 18 Apr 2025 · Updated 8 Jul 2026
Affected packages
- Affected
- >=5.0.0 <5.3.2
- Fixed in
- 5.3.2
npm install fastify@5.3.2- Affected
- >=4.29.0 <4.29.1
- Fixed in
- 4.29.1
npm install fastify@4.29.1Details
Impact
In applications that specify different validation strategies for different content types, it's possible to bypass the validation by providing a _slightly altered_ content type such as with different casing or altered whitespacing before ;.
Users using the the following pattern are affected:
fastify.post('/', {
handler(request, reply) {
reply.code(200).send(request.body)
},
schema: {
body: {
content: {
'application/json': {
schema: {
type: 'object',
properties: {
'foo': {
type: 'string',
}
},
required: ['foo']
}
},
}
}
}
})User using the following pattern are not affected:
fastify.post('/', {
handler(request, reply) {
reply.code(200).send(request.body)
},
schema: {
body: {
type: 'object',
properties: {
'foo': {
type: 'string',
}
},
required: ['foo']
}
}
})Patches
This was patched in v5.3.1, but unfortunately it did not cover all problems. This has been fully patched in v5.3.2. Version v4.9.0 was also affected by this issue. This has been fully patched in v4.9.1.
Workarounds
Do not specify multiple content types in the schema.
References
_Are there any links users can visit to find out more?_
https://hackerone.com/reports/3087928
Is GHSA-mg2h-6x62-wpwc in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected fastify, and gives you the command that fixes it.
References
- Linkgithub.com/fastify/fastify/security/advisories/GHSA-mg2h-6x62-wpwc
- Advisorynvd.nist.gov/vuln/detail/CVE-2025-32442
- Linkgithub.com/fastify/fastify/commit/436da4c06dfbbb8c24adee3a64de0c51e4f47418
- Linkgithub.com/fastify/fastify/commit/f3d2bcb3963cd570a582e5d39aab01a9ae692fe4
- Linkhackerone.com/reports/3087928
- Packagegithub.com/fastify/fastify
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.