CVE-2025-32442: Fastify Fastify Vulnerable To Invalid Content-type Vulnerability

HIGH
Advisory Identifier: GHSA-mg2h-6x62-wpwc
CVSS 7.5
CWE-1287
Published
Advisory Summary

CVE-2025-32442 is a HIGH (CVSS 7.5) fastify vulnerable to invalid content-type vulnerability (CWE-1287: Improper Validation of Specified Type of Input) affecting Fastify libraries in the npm ecosystem. The issue involves fastify vulnerable to invalid content-type parsing, which could lead to validation bypass. Remediation is available by upgrading affected packages to version 5.3.2, 4.29.1.

CVE-2025-32442 at a Glance

CVE Identifier CVE-2025-32442
GHSA Identifier GHSA-mg2h-6x62-wpwc
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1287: Improper Validation of Specified Type of Input
Affected Product Fastify
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2025-32442

To remediate this vulnerability, upgrade all affected Fastify dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

fastify fixed: 5.3.2
npm install fastify@5.3.2
fastify fixed: 4.29.1
npm install fastify@4.29.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls fastify

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2025-32442, inspect your project dependencies using npm:

npm ls fastify

Analyze the terminal output to locate any version of Fastify in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.3.2), your application is affected.

Note: The npm ls fastify command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1287: Improper Validation of Specified Type of Input, where the product receives input that is expected to be of a certain type, but it does not validate or incorrectly validates that the input is actually of the expected type. In Fastify, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```js 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: ```js 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

CVE-2025-32442 Affected Fastify Versions

2 component(s)
Fixed Versions:
5.3.24.29.1
Product / Package Ecosystem Affected Versions Fixed Version
fastify
npm
≥ 5.0.0
< 5.3.2
5.3.2
fastify
npm
≥ 4.29.0
< 4.29.1
All 1 versions
4.29.0
4.29.1

References

Frequently Asked Questions

What is CVE-2025-32442?
CVE-2025-32442 is a security vulnerability in Fastify involving Fastify vulnerable to invalid content-type parsing, which could lead to validation bypass under CWE-1287: Improper Validation of Specified Type of Input.
Which Fastify versions are affected?
Affected versions include releases prior to 5.3.2, 4.29.1 across affected packages: fastify.
What version fixes CVE-2025-32442?
Upgrading to 5.3.2, 4.29.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fastify affected?
Yes, fastify is affected in releases prior to 5.3.2, 4.29.1. Upgrade your dependency to 5.3.2, 4.29.1 or later.
What is the CVSS score of CVE-2025-32442?
CVE-2025-32442 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2025-32442?
CVE-2025-32442 is classified under CWE-1287: Improper Validation of Specified Type of Input (The product receives input that is expected to be of a certain type, but it does not validate or incorrectly validates that the input is actually of the expected type.).
How can I check npm dependencies for CVE-2025-32442?
Run the dependency tree command: 'npm ls fastify'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mg2h-6x62-wpwc",
  "modified" : "2025-05-29T21:04:54Z",
  "published" : "2025-04-18T15:02:41Z",
  "aliases" : [ "CVE-2025-32442" ],
  "summary" : "Fastify vulnerable to invalid content-type parsing, which could lead to validation bypass",
  "details" : "### Impact\n\nIn 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 `;`.\n\nUsers using the the following pattern are affected:\n\n```js\nfastify.post('/', {\n  handler(request, reply) {\n    reply.code(200).send(request.body)\n  },\n  schema: {\n    body: {\n      content: {\n        'application/json': {\n          schema: {\n            type: 'object',\n            properties: {\n              'foo': {\n                type: 'string',\n              }\n            },\n            required: ['foo']\n          }\n        },\n      }\n    }\n  }\n})\n```\n\nUser using the following pattern are **not** affected:\n\n```js\nfastify.post('/', {\n  handler(request, reply) {\n    reply.code(200).send(request.body)\n  },\n  schema: {\n    body: {\n      type: 'object',\n      properties: {\n        'foo': {\n          type: 'string',\n        }\n      },\n      required: ['foo']\n    }\n  }\n})\n```\n\n### Patches\n\nThis was patched in v5.3.1, but unfortunately it did not cover all problems. This has been fully patched in v5.3.2.\nVersion v4.9.0 was also affected by this issue. This has been fully patched in v4.9.1.\n\n### Workarounds\n\nDo not specify multiple content types in the schema.\n\n### References\n_Are there any links users can visit to find out more?_\n\nhttps://hackerone.com/reports/3087928",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fastify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.3.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.3.1"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fastify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.29.0"
      }, {
        "fixed" : "4.29.1"
      } ]
    } ],
    "versions" : [ "4.29.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify/security/advisories/GHSA-mg2h-6x62-wpwc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-32442"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify/commit/436da4c06dfbbb8c24adee3a64de0c51e4f47418"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify/commit/f3d2bcb3963cd570a582e5d39aab01a9ae692fe4"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/3087928"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fastify/fastify"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1287" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-04-18T15:02:41Z",
    "nvd_published_at" : "2025-04-18T16:15:23Z"
  }
}