CVE-2025-64166: Mercurius Incorrect Content-Type Parsing Can Lead Vulnerability

MODERATE
Advisory Identifier: GHSA-v66j-6wwf-jc57
CVSS 5.4
CWE-352
Published
Advisory Summary

CVE-2025-64166 is a MODERATE (CVSS 5.4) incorrect content-type parsing can lead vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Mercurius libraries in the npm ecosystem. The issue involves incorrect content-type parsing can lead to csrf attack. Remediation is available by upgrading affected packages to version 16.4.0.

CVE-2025-64166 at a Glance

CVE Identifier CVE-2025-64166
GHSA Identifier GHSA-v66j-6wwf-jc57
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-352: Cross-Site Request Forgery (CSRF)
Affected Product Mercurius
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.4

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:R/S:U/C:L/I:L/A:N).

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

How to Fix CVE-2025-64166

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

mercurius fixed: 16.4.0
npm install mercurius@16.4.0
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 mercurius

How to Check if You Are Affected

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

npm ls mercurius

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

Note: The npm ls mercurius 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-352: Cross-Site Request Forgery (CSRF), where the web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. In Mercurius, 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

### Summary A Cross-Site Request Forgery (CSRF) vulnerability was identified in Mercurius versions 16. The issue arises from incorrect parsing of the `Content-Type` header in requests. Specifically, requests with `Content-Type` values such as `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` could be misinterpreted as `application/json`. This misinterpretation bypasses the preflight checks performed by the `fetch()` API, potentially allowing unauthorized actions to be performed on behalf of an authenticated user. --- ### Impact An attacker could exploit this vulnerability by crafting a malicious request with a `Content-Type` that Fastify incorrectly parses as `application/json`. When such a request is made from a different origin, it bypasses the Cross-Origin Resource Sharing (CORS) protections, leading to a potential CSRF attack. This could result in unauthorized actions being performed on behalf of an authenticated user without their consent. --- ### Proof of Concept ```javascript // Server-side Fastify setup const Fastify = require('fastify'); const mercurius = require('mercurius'); const app = Fastify(); const schema = ` type Query { hello(name: String): String } `; const resolvers = { Query: { hello: (_, { name }) => `Hello ${name || 'World'}!` } }; app.register(mercurius, { schema, resolvers }); app.listen(3000, () => { console.log('Server listening on http://localhost:3000'); }); ``` ```javascript // Malicious client-side code fetch('http://localhost:3000/graphql', { method: 'POST', body: JSON.stringify({ query: '{ hello(name: "attacker") }' }), headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, credentials: 'include' }); ``` In the above example, the malicious request is crafted to exploit the CSRF vulnerability by using a `Content-Type` that Fastify incorrectly parses as `application/json`. --- ### Mitigation To address this vulnerability, CSRF protection has been implemented. ## References * https://github.com/mercurius-js/mercurius/pull/1187

CVE-2025-64166 Affected Mercurius Versions

1 component(s)
Fixed Versions:
16.4.0
Product / Package Ecosystem Affected Versions Fixed Version
mercurius
npm
< 16.4.0
16.4.0

References

Frequently Asked Questions

What is CVE-2025-64166?
CVE-2025-64166 is a security vulnerability in Mercurius involving Incorrect Content-Type parsing can lead to CSRF attack under CWE-352: Cross-Site Request Forgery (CSRF).
Which Mercurius versions are affected?
Affected versions include releases prior to 16.4.0 across affected packages: mercurius.
What version fixes CVE-2025-64166?
Upgrading to 16.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mercurius affected?
Yes, mercurius is affected in releases prior to 16.4.0. Upgrade your dependency to 16.4.0 or later.
What is the CVSS score of CVE-2025-64166?
CVE-2025-64166 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2025-64166?
CVE-2025-64166 is classified under CWE-352: Cross-Site Request Forgery (CSRF) (The web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor.).
How can I check npm dependencies for CVE-2025-64166?
Run the dependency tree command: 'npm ls mercurius'. 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-v66j-6wwf-jc57",
  "modified" : "2026-03-05T20:42:10Z",
  "published" : "2026-03-05T18:18:01Z",
  "aliases" : [ "CVE-2025-64166" ],
  "summary" : "Mercurius: Incorrect Content-Type parsing can lead to CSRF attack",
  "details" : "### Summary\n\nA Cross-Site Request Forgery (CSRF) vulnerability was identified in Mercurius versions 16. The issue arises from incorrect parsing of the `Content-Type` header in requests. Specifically, requests with `Content-Type` values such as `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` could be misinterpreted as `application/json`. This misinterpretation bypasses the preflight checks performed by the `fetch()` API, potentially allowing unauthorized actions to be performed on behalf of an authenticated user.\n\n---\n\n### Impact\n\nAn attacker could exploit this vulnerability by crafting a malicious request with a `Content-Type` that Fastify incorrectly parses as `application/json`. When such a request is made from a different origin, it bypasses the Cross-Origin Resource Sharing (CORS) protections, leading to a potential CSRF attack. This could result in unauthorized actions being performed on behalf of an authenticated user without their consent.\n\n---\n\n### Proof of Concept\n\n```javascript\n// Server-side Fastify setup\nconst Fastify = require('fastify');\nconst mercurius = require('mercurius');\n\nconst app = Fastify();\nconst schema = `\n  type Query {\n    hello(name: String): String\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    hello: (_, { name }) => `Hello ${name || 'World'}!`\n  }\n};\n\napp.register(mercurius, { schema, resolvers });\n\napp.listen(3000, () => {\n  console.log('Server listening on http://localhost:3000');\n});\n```\n\n```javascript\n// Malicious client-side code\nfetch('http://localhost:3000/graphql', {\n  method: 'POST',\n  body: JSON.stringify({ query: '{ hello(name: \"attacker\") }' }),\n  headers: {\n    'Content-Type': 'application/x-www-form-urlencoded'\n  },\n  credentials: 'include'\n});\n```\n\nIn the above example, the malicious request is crafted to exploit the CSRF vulnerability by using a `Content-Type` that Fastify incorrectly parses as `application/json`.\n\n---\n\n### Mitigation\n\nTo address this vulnerability, CSRF protection has been implemented.\n\n## References\n\n* https://github.com/mercurius-js/mercurius/pull/1187",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mercurius"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "16.4.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 16.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mercurius-js/mercurius/security/advisories/GHSA-v66j-6wwf-jc57"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-64166"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mercurius-js/mercurius/pull/1187"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mercurius-js/mercurius/commit/962d402ec7a92342f4a1b7f5f04af01776838c3c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mercurius-js/mercurius"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-352" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-05T18:18:01Z",
    "nvd_published_at" : "2026-03-05T16:16:11Z"
  }
}