{"id":"CVE-2025-64166","aliases":["CVE-2025-64166","GHSA-v66j-6wwf-jc57"],"related":[],"kind":"vulnerability","state":"published","title":"Mercurius: Incorrect Content-Type parsing can lead to CSRF attack","summary":"Mercurius is a GraphQL adapter for Fastify. Prior to version 16.4.0, a cross-site request forgery (CSRF) vulnerability was identified. 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. This issue has been patched in version 16.4.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Mercurius is a GraphQL adapter for Fastify. Prior to version 16.4.0, a cross-site request forgery (CSRF) vulnerability was identified. 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. This issue has been patched in version 16.4.0.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"Mercurius es un adaptador GraphQL para Fastify. Antes de la versión 16.4.0, se identificó una vulnerabilidad de falsificación de petición en sitios cruzados (CSRF). El problema surge del análisis incorrecto del encabezado Content-Type en las peticiones. Específicamente, las peticiones con valores de Content-Type como application/x-www-form-urlencoded, multipart/form-data o text/plain podrían ser malinterpretadas como application/json. Esta mala interpretación omite las comprobaciones previas realizadas por la API fetch(), lo que podría permitir que se realicen acciones no autorizadas en nombre de un usuario autenticado. Este problema ha sido parcheado en la versión 16.4.0.","source":"nvd"}],"published":"2026-03-05T15:31:45.641Z","modified":"2026-06-17T09:53:56.630Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"}],"cwes":["CWE-352"],"affected":[{"ranges":[{"version":"< 16.4.0","status":"affected"}],"vendor":"mercurius-js","product":"mercurius","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"16.4.0"}],"ecosystem":"npm","package":"mercurius","purl":"pkg:npm/mercurius","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"16.4.0"}],"vendor":"mercurius_project","product":"mercurius","cpe":"cpe:2.3:a:mercurius_project:mercurius:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/mercurius-js/mercurius/security/advisories/GHSA-v66j-6wwf-jc57","tags":["exploit","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mercurius-js/mercurius/pull/1187","tags":["issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mercurius-js/mercurius/commit/962d402ec7a92342f4a1b7f5f04af01776838c3c","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-64166","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mercurius-js/mercurius","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-03-05T16:34:32.783Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-64166","url":"https://www.cve.org/CVERecord?id=CVE-2025-64166","licence":"CVE Terms of Use","modified":"2026-03-05T16:34:35.585Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-v66j-6wwf-jc57","url":"https://github.com/advisories/GHSA-v66j-6wwf-jc57","licence":"CC-BY-4.0","modified":"2026-03-05T20:46:36.485Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-64166","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-64166","licence":"Public domain","modified":"2026-06-17T09:53:56.630Z"}],"updatedAt":"2026-11-25T22:59:11.850Z","epss":{"score":0.00181,"percentile":0.08005,"date":"2026-12-01T12:00:22.000Z"}}