CVE-2022-41919
JSON

4.2medium

Fastify vulnerable to Cross-Site Request Forgery (CSRF) attack via incorrect content type

Severity
4.2medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.51% (higher than 37% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-3fjj-p79j-c9hh

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'.

Affected

Product or packageVersionsReported by
fastify fastify>= 4.0.0, < 4.10.2, >= 3.0.0, < 3.29.4, from 3.0.0 before 3.29.4, from 4.0.0 before 4.10.2CVE List, NVD
fastify (npm)from 4.0.0 before 4.10.2, from 3.0.0 before 3.29.4GitHub Advisory Database

All scores

GitHub_M4.2medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N
GitHub4.2medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N
NVD8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Classification

CWE-352

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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'.

GitHub Advisory Database
Impact

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.

Patches

For 4.x users, please update to at least 4.10.2 For 3.x users, please update to at least 3.29.4

Workarounds

Implement Cross-Site Request Forgery protection using @fastify/csrf.

References

Check out the HackerOne report: https://hackerone.com/reports/1763832.

For more information

Fastify security policy

NVD (es)

Fastify es un framework web con una arquitectura de complementos y gastos generales mínimos. El atacante puede utilizar el "Content-Type" incorrecto para omitir la comprobación "Pre-Flight" de "fetch". Las solicitudes `fetch()` con la esencia de Content-Type como "application/x-www-form-urlencoded", "multipart/form-data" o "text/plain", podrían usarse potencialmente para invocar rutas que solo acepta el tipo de contenido `application/json`, evitando así cualquier protección CORS y, por lo tanto, podría provocar un ataque de Cross-Site Request Forgery (CSRF). Este problema se solucionó en las versiones 4.10.2 y 3.29.4. Como workaround, implemente la protección contra Cross-Site Request Forgery (CSRF) utilizando `@fastify/csrf'.

References

Sources

SourceRecordLicence
CVE ListCVE-2022-41919 changed 2025-04-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-3fjj-p79j-c9hh changed 2023-11-08CC-BY-4.0
NVDCVE-2022-41919 changed 2026-06-17Public domain