Vulnerabilities in pkg:npm/fastify-csrf

PACKAGE
Advisory Identifier: GHSA-49wp-qq6x-g2rf
Advisory Summary

CVE-2020-28482 is a HIGH (CVSS 8.8) cross-site request forgery vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Fastify csrf libraries in the npm ecosystem. The issue involves cross-site request forgery in fastify-csrf. Remediation is available by upgrading affected packages to version 3.0.0.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/fastify-csrf

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/fastify-csrf. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-49wp-qq6x-g2rf CVE-2020-28482 HIGH Cross-site Request Forgery in fastify-csrf
GHSA-rc4q-9m69-gqp8 CVE-2021-29624 MODERATE Lack of protection against cookie tossing attacks in fastify-csrf

CVE-2020-28482 at a Glance

CVE Identifier CVE-2020-28482
GHSA Identifier GHSA-49wp-qq6x-g2rf
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-352: Cross-Site Request Forgery (CSRF)
Affected Product Fastify csrf
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.8

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:H/I:H/A:H).

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 High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2020-28482

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.0.0
npm install fastify-csrf@3.0.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-2020-28482, 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.0.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-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 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

The package fastify-csrf before 3.0.0 has a set of issues that affect its ability to do CSRF protection. 1. The generated cookie used insecure defaults, and did not have the httpOnly flag on: `cookieOpts: { path: '/', sameSite: true }` 2. The CSRF token was available in the GET query parameter

CVE-2020-28482 Affected Fastify csrf Versions

1 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
fastify-csrf
npm
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2020-28482?
CVE-2020-28482 is a security vulnerability in Fastify csrf involving Cross-site Request Forgery in fastify-csrf under CWE-352: Cross-Site Request Forgery (CSRF).
Which Fastify csrf versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: fastify-csrf.
What version fixes CVE-2020-28482?
Upgrading to 3.0.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.0.0. Upgrade your dependency to 3.0.0 or later.
What is the CVSS score of CVE-2020-28482?
CVE-2020-28482 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2020-28482?
CVE-2020-28482 is classified under CWE-352: Cross-Site Request Forgery (CSRF) (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.).
How can I check npm dependencies for CVE-2020-28482?
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-49wp-qq6x-g2rf",
  "modified" : "2022-06-29T21:54:32Z",
  "published" : "2021-01-20T21:30:34Z",
  "aliases" : [ "CVE-2020-28482" ],
  "summary" : "Cross-site Request Forgery in fastify-csrf",
  "details" : "The package fastify-csrf before 3.0.0 has a set of issues that affect its ability to do CSRF protection.\n1. The generated cookie used insecure defaults, and did not have the httpOnly flag on: `cookieOpts: { path: '/', sameSite: true }`\n2. The CSRF token was available in the GET query parameter",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fastify-csrf"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-28482"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-csrf/pull/26"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-csrf/commit/3c9de36e9e73ce0eda9207f84f2ac0243e1f5253"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fastify/fastify-csrf"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-FASTIFYCSRF-1062044"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/fastify-csrf"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-352" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-01-20T19:49:01Z",
    "nvd_published_at" : "2021-01-19T15:15:00Z"
  }
}