CVE-2022-41919: Fastify Incorrect Content-Type Parsing Can Lead Vulnerability
MODERATECVE-2022-41919 is a MODERATE (CVSS 4.2) incorrect content-type parsing can lead vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Fastify 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 4.10.2, 3.29.4.
CVE-2022-41919 at a Glance
Security Impact
CVSS: 4.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N).
How to Fix CVE-2022-41919
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.
npm install fastify@4.10.2
npm install fastify@3.29.4
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-2022-41919, 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 4.10.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-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 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
CVE-2022-41919 Affected Fastify Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastify
|
npm |
≥ 4.0.0
< 4.10.2
|
4.10.2
|
|
fastify
|
npm |
≥ 3.0.0
< 3.29.4
|
3.29.4
|
References
Frequently Asked Questions
What is CVE-2022-41919?
Which Fastify versions are affected?
What version fixes CVE-2022-41919?
Is fastify affected?
What is the CVSS score of CVE-2022-41919?
What CWE is associated with CVE-2022-41919?
How can I check npm dependencies for CVE-2022-41919?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3fjj-p79j-c9hh",
"modified" : "2022-11-28T16:17:34Z",
"published" : "2022-11-21T22:28:11Z",
"aliases" : [ "CVE-2022-41919" ],
"summary" : "Fastify: Incorrect Content-Type parsing can lead to CSRF attack ",
"details" : "### Impact\n\nThe attacker can use the incorrect `Content-Type` to bypass the `Pre-Flight` checking of `fetch`. `fetch()` requests with Content-Type’s [essence](https://mimesniff.spec.whatwg.org/#mime-type-essence) as \"application/x-www-form-urlencoded\", \"multipart/form-data\", or \"text/plain\", could potentially be used to invoke routes that only accepts `application/json` content type, thus bypassing any [CORS protection](https://fetch.spec.whatwg.org/#simple-header), and therefore they could lead to a Cross-Site Request Forgery attack.\n\n### Patches\nFor `4.x` users, please update to at least `4.10.2`\nFor `3.x` users, please update to at least `3.29.4`\n\n### Workarounds\n\nImplement Cross-Site Request Forgery protection using [`@fastify/csrf`](https://www.npmjs.com/package/@fastify/csrf).\n\n### References\n\nCheck out the HackerOne report: https://hackerone.com/reports/1763832.\n\n### For more information\n\n[Fastify security policy](https://github.com/fastify/fastify/security/policy)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "fastify"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "4.10.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "fastify"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.29.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify/security/advisories/GHSA-3fjj-p79j-c9hh"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-41919"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify/commit/62dde76f1f7aca76e38625fe8d983761f26e6fc9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/@fastify/csrf"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-11-21T22:28:11Z",
"nvd_published_at" : "2022-11-22T20:15:00Z"
}
}