CVE-2022-41919: CWE-352: Cross-Site Request Forgery (CSRF) in fastify fastify
Fastify is a web framework with minimal overhead and plugin architecture. The attacker can use the incorrect `Content-Type` to bypass the `Pre-Flight` checking of `fetch`. `fetch()` requests with Content-Type’s 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, and therefore they could lead to a Cross-Site Request Forgery attack. This issue has been patched in version 4.10.2 and 3.29.4. As a workaround, implement Cross-Site Request Forgery protection using `@fastify/csrf'.
AI Analysis
Technical Summary
CVE-2022-41919 is a Cross-Site Request Forgery (CSRF) vulnerability affecting the Fastify web framework versions 3.0.0 up to but not including 3.29.4, and 4.0.0 up to but not including 4.10.2. Fastify is a Node.js web framework designed for high performance and extensibility via plugins. The vulnerability arises due to improper handling of the Content-Type header in HTTP requests, specifically in the context of CORS (Cross-Origin Resource Sharing) pre-flight checks. Normally, browsers enforce CORS policies to prevent unauthorized cross-origin requests, and pre-flight OPTIONS requests are used to verify permissions for certain content types such as application/json. However, in Fastify, an attacker can craft fetch() requests with Content-Type headers set to "application/x-www-form-urlencoded", "multipart/form-data", or "text/plain". These content types are considered simple and do not trigger pre-flight checks, allowing the attacker to bypass CORS protections that restrict routes to only accept application/json content types. This bypass enables an attacker to perform CSRF attacks by tricking authenticated users into submitting unintended requests to the vulnerable Fastify server, potentially causing unauthorized actions on behalf of the user. The vulnerability does not require user interaction beyond visiting a malicious site and does not require authentication to exploit, assuming the victim is already authenticated to the target application. The issue has been addressed in Fastify versions 3.29.4 and 4.10.2 by correcting the handling of Content-Type and CORS pre-flight checks. As a mitigation, developers are advised to implement explicit CSRF protection using the @fastify/csrf plugin, which provides token-based validation to prevent unauthorized cross-site requests. There are no known exploits in the wild reported to date, but the vulnerability poses a risk to applications relying on Fastify versions within the affected range without additional CSRF protections.
Potential Impact
For European organizations, this vulnerability could lead to unauthorized actions performed on web applications built with vulnerable Fastify versions. Potential impacts include unauthorized data modification, transaction manipulation, or privilege escalation within the context of the affected web application. Since Fastify is used in various sectors including e-commerce, finance, healthcare, and government services, exploitation could compromise sensitive personal data protected under GDPR, leading to regulatory penalties and reputational damage. The bypass of CORS protections increases the attack surface by allowing cross-origin requests that were previously blocked, making it easier for attackers to exploit CSRF without complex social engineering. The vulnerability could also facilitate lateral movement or persistence in multi-tenant environments if exploited in internal applications. Although no active exploits are known, the ease of exploitation via crafted web requests and the widespread use of Fastify in modern web applications make this a significant risk. Organizations with public-facing APIs or web portals using affected Fastify versions are particularly at risk, especially if they have not implemented additional CSRF defenses.
Mitigation Recommendations
1. Upgrade Fastify to version 3.29.4 or 4.10.2 or later immediately to apply the official patch addressing this vulnerability. 2. Implement the @fastify/csrf plugin to enforce token-based CSRF protection, ensuring that all state-changing requests include a valid CSRF token. 3. Review and tighten CORS policies to explicitly specify allowed origins, methods, and headers, minimizing the risk of unauthorized cross-origin requests. 4. Conduct a thorough audit of all routes accepting JSON content types to verify that they enforce proper authentication and authorization checks. 5. Employ Content Security Policy (CSP) headers to restrict the sources of executable scripts and reduce the risk of malicious script injection that could facilitate CSRF attacks. 6. Monitor web application logs for unusual or unexpected cross-origin requests, particularly those with Content-Type headers set to simple types that could bypass pre-flight checks. 7. Educate developers on secure handling of CORS and CSRF protections, emphasizing the limitations of relying solely on content-type restrictions for security. 8. For internal applications, consider network segmentation and additional access controls to reduce exposure to cross-site attacks. These steps go beyond generic advice by focusing on specific Fastify versions, plugin usage, and detailed CORS policy management.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Italy, Spain, Poland, Belgium, Finland
CVE-2022-41919: CWE-352: Cross-Site Request Forgery (CSRF) in fastify fastify
Description
Fastify is a web framework with minimal overhead and plugin architecture. The attacker can use the incorrect `Content-Type` to bypass the `Pre-Flight` checking of `fetch`. `fetch()` requests with Content-Type’s 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, and therefore they could lead to a Cross-Site Request Forgery attack. This issue has been patched in version 4.10.2 and 3.29.4. As a workaround, implement Cross-Site Request Forgery protection using `@fastify/csrf'.
AI-Powered Analysis
Technical Analysis
CVE-2022-41919 is a Cross-Site Request Forgery (CSRF) vulnerability affecting the Fastify web framework versions 3.0.0 up to but not including 3.29.4, and 4.0.0 up to but not including 4.10.2. Fastify is a Node.js web framework designed for high performance and extensibility via plugins. The vulnerability arises due to improper handling of the Content-Type header in HTTP requests, specifically in the context of CORS (Cross-Origin Resource Sharing) pre-flight checks. Normally, browsers enforce CORS policies to prevent unauthorized cross-origin requests, and pre-flight OPTIONS requests are used to verify permissions for certain content types such as application/json. However, in Fastify, an attacker can craft fetch() requests with Content-Type headers set to "application/x-www-form-urlencoded", "multipart/form-data", or "text/plain". These content types are considered simple and do not trigger pre-flight checks, allowing the attacker to bypass CORS protections that restrict routes to only accept application/json content types. This bypass enables an attacker to perform CSRF attacks by tricking authenticated users into submitting unintended requests to the vulnerable Fastify server, potentially causing unauthorized actions on behalf of the user. The vulnerability does not require user interaction beyond visiting a malicious site and does not require authentication to exploit, assuming the victim is already authenticated to the target application. The issue has been addressed in Fastify versions 3.29.4 and 4.10.2 by correcting the handling of Content-Type and CORS pre-flight checks. As a mitigation, developers are advised to implement explicit CSRF protection using the @fastify/csrf plugin, which provides token-based validation to prevent unauthorized cross-site requests. There are no known exploits in the wild reported to date, but the vulnerability poses a risk to applications relying on Fastify versions within the affected range without additional CSRF protections.
Potential Impact
For European organizations, this vulnerability could lead to unauthorized actions performed on web applications built with vulnerable Fastify versions. Potential impacts include unauthorized data modification, transaction manipulation, or privilege escalation within the context of the affected web application. Since Fastify is used in various sectors including e-commerce, finance, healthcare, and government services, exploitation could compromise sensitive personal data protected under GDPR, leading to regulatory penalties and reputational damage. The bypass of CORS protections increases the attack surface by allowing cross-origin requests that were previously blocked, making it easier for attackers to exploit CSRF without complex social engineering. The vulnerability could also facilitate lateral movement or persistence in multi-tenant environments if exploited in internal applications. Although no active exploits are known, the ease of exploitation via crafted web requests and the widespread use of Fastify in modern web applications make this a significant risk. Organizations with public-facing APIs or web portals using affected Fastify versions are particularly at risk, especially if they have not implemented additional CSRF defenses.
Mitigation Recommendations
1. Upgrade Fastify to version 3.29.4 or 4.10.2 or later immediately to apply the official patch addressing this vulnerability. 2. Implement the @fastify/csrf plugin to enforce token-based CSRF protection, ensuring that all state-changing requests include a valid CSRF token. 3. Review and tighten CORS policies to explicitly specify allowed origins, methods, and headers, minimizing the risk of unauthorized cross-origin requests. 4. Conduct a thorough audit of all routes accepting JSON content types to verify that they enforce proper authentication and authorization checks. 5. Employ Content Security Policy (CSP) headers to restrict the sources of executable scripts and reduce the risk of malicious script injection that could facilitate CSRF attacks. 6. Monitor web application logs for unusual or unexpected cross-origin requests, particularly those with Content-Type headers set to simple types that could bypass pre-flight checks. 7. Educate developers on secure handling of CORS and CSRF protections, emphasizing the limitations of relying solely on content-type restrictions for security. 8. For internal applications, consider network segmentation and additional access controls to reduce exposure to cross-site attacks. These steps go beyond generic advice by focusing on specific Fastify versions, plugin usage, and detailed CORS policy management.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-09-30T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9846c4522896dcbf4ae4
Added to database: 5/21/2025, 9:09:26 AM
Last enriched: 6/22/2025, 1:38:56 PM
Last updated: 8/17/2025, 2:17:47 PM
Views: 14
Related Threats
CVE-2025-53948: CWE-415 Double Free in Santesoft Sante PACS Server
HighCVE-2025-52584: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-46269: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-54862: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumCVE-2025-54759: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.