GHSA-v66j-6wwf-jc57
MEDIUMMercurius: Incorrect Content-Type parsing can lead to CSRF attack
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Blast Radius
Weekly download volume for affected packages — a proxy for how broadly this vulnerability is deployed.
mercuriusnpmDescription
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
// 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');
});
// 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
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | mercurius | all versions | 16.4.0 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for mercurius. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update mercurius to 16.4.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-v66j-6wwf-jc57 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-v66j-6wwf-jc57 is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-v66j-6wwf-jc57. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-v66j-6wwf-jc57 in your dependencies?
O3 detects GHSA-v66j-6wwf-jc57 across npm dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.