CVE-2021-29624: Fastify csrf Lack Of Protection Against Cookie Vulnerability
MODERATECVE-2021-29624 is a MODERATE (CVSS 6.5) lack of protection against cookie vulnerability (CWE-565: Reliance on Cookies without Validation and Integrity Checking) affecting Fastify csrf libraries in the npm ecosystem. The issue involves lack of protection against cookie tossing attacks in fastify-csrf. Remediation is available by upgrading affected packages to version 3.1.0.
CVE-2021-29624 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).
How to Fix CVE-2021-29624
To remediate this vulnerability, upgrade all affected Fastify csrf 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-csrf@3.1.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls fastify-csrf
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-29624, inspect your project dependencies using npm:
npm ls fastify-csrf
Analyze the terminal output to locate any version of Fastify csrf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.0), your application is affected.
Note: The npm ls fastify-csrf 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-565: Reliance on Cookies without Validation and Integrity Checking, where the product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user. In Fastify csrf, 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-2021-29624 Affected Fastify csrf Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastify-csrf
|
npm |
< 3.1.0
|
3.1.0
|
References
Frequently Asked Questions
What is CVE-2021-29624?
Which Fastify csrf versions are affected?
What version fixes CVE-2021-29624?
Is fastify-csrf affected?
What is the CVSS score of CVE-2021-29624?
What CWE is associated with CVE-2021-29624?
How can I check npm dependencies for CVE-2021-29624?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rc4q-9m69-gqp8",
"modified" : "2021-05-17T20:29:48Z",
"published" : "2021-05-17T20:53:30Z",
"aliases" : [ "CVE-2021-29624" ],
"summary" : "Lack of protection against cookie tossing attacks in fastify-csrf",
"details" : "### Impact\n\nUsers that used fastify-csrf with the \"double submit\" mechanism using cookies with an application deployed across multiple subdomains, e.g. \"heroku\"-style platform as a service. \n\n### Patches\n\nVersion 3.1.0 of the fastify-csrf fixes it. \nSee https://github.com/fastify/fastify-csrf/pull/51 and https://github.com/fastify/csrf/pull/2.\n\nThe user of the module would need to supply a `userInfo` when generating the CSRF token to fully implement the protection on their end. This is needed only for applications hosted on different subdomains.\n\n### Workarounds\n\nNone available.\n\n### References\n\n1. https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html\n2. https://owasp.org/www-pdf-archive/David_Johansson-Double_Defeat_of_Double-Submit_Cookie.pdf\n\n### Credits\n\nThis vulnerability was found by Xhelal Likaj <xhelallikaj20@gmail.com>.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [fastify-csrf](https://github.com/fastify/fastify-csrf)\n* Email us at [hello@matteocollina.com](mailto:hello@matteocollina.com)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "fastify-csrf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.1.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-csrf/security/advisories/GHSA-rc4q-9m69-gqp8"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-29624"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/csrf/pull/2"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-csrf/pull/51"
}, {
"type" : "WEB",
"url" : "https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-csrf/releases/tag/v3.1.0"
}, {
"type" : "WEB",
"url" : "https://owasp.org/www-pdf-archive/David_Johansson-Double_Defeat_of_Double-Submit_Cookie.pdf"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352", "CWE-565" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-17T20:29:48Z",
"nvd_published_at" : "2021-05-19T22:15:00Z"
}
}