CVE-2021-29624: Fastify csrf Lack Of Protection Against Cookie Vulnerability

MODERATE
Advisory Identifier: GHSA-rc4q-9m69-gqp8
CVSS 6.5
CWE-565 CWE-352
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2021-29624
GHSA Identifier GHSA-rc4q-9m69-gqp8
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-565: Reliance on Cookies without Validation and Integrity Checking
Affected Product Fastify csrf
Package Ecosystem npm
Published Date
Last Updated

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (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.

fastify-csrf fixed: 3.1.0
npm install fastify-csrf@3.1.0
Verify Direct and Transitive Dependencies

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

### Impact Users 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. ### Patches Version 3.1.0 of the fastify-csrf fixes it. See https://github.com/fastify/fastify-csrf/pull/51 and https://github.com/fastify/csrf/pull/2. The 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. ### Workarounds None available. ### References 1. https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html 2. https://owasp.org/www-pdf-archive/David_Johansson-Double_Defeat_of_Double-Submit_Cookie.pdf ### Credits This vulnerability was found by Xhelal Likaj <xhelallikaj20@gmail.com>. ### For more information If you have any questions or comments about this advisory: * Open an issue in [fastify-csrf](https://github.com/fastify/fastify-csrf) * Email us at [hello@matteocollina.com](mailto:hello@matteocollina.com)

CVE-2021-29624 Affected Fastify csrf Versions

1 component(s)
Fixed Versions:
3.1.0
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?
CVE-2021-29624 is a security vulnerability in Fastify csrf involving Lack of protection against cookie tossing attacks in fastify-csrf under CWE-565: Reliance on Cookies without Validation and Integrity Checking.
Which Fastify csrf versions are affected?
Affected versions include releases prior to 3.1.0 across affected packages: fastify-csrf.
What version fixes CVE-2021-29624?
Upgrading to 3.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fastify-csrf affected?
Yes, fastify-csrf is affected in releases prior to 3.1.0. Upgrade your dependency to 3.1.0 or later.
What is the CVSS score of CVE-2021-29624?
CVE-2021-29624 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2021-29624?
CVE-2021-29624 is classified under CWE-565: Reliance on Cookies without Validation and Integrity Checking (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.).
How can I check npm dependencies for CVE-2021-29624?
Run the dependency tree command: 'npm ls fastify-csrf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}