Skip to content
Heist/ feed
Back to feed
Medium

Bypass of CSRF protection in the presence of predictable userInfo in @fastify/csrf-protection

Type: advisorySources: OSV

@fastify/csrf-protection is a plugin which helps protect Fastify servers against CSRF attacks. The CSRF protection enforced by the @fastify/csrf-protection library in combination with @fastify/cookie can be bypassed from network and same-site attackers under certain conditions. @fastify/csrf-protection supports an optional userInfo parameter that binds the CSRF token to the user. This parameter has been introduced to prevent cookie-tossing attacks as a fix for CVE-2021-29624. Whenever userInfo parameter is missing, or its value can be predicted for the target user account, network and same-site attackers can 1. fixate a _csrf cookie in the victim's browser, and 2. forge CSRF tokens that are valid for the victim's session. This allows attackers to bypass the CSRF protection mechanism. As a fix, @fastify/csrf-protection starting from version 6.3.0 (and v4.1.0) includes a server-defined secret hmacKey that cryptographically binds the CSRF token to the value of the _csrf cookie and the userInfo parameter, making tokens non-spoofable by attackers. This protection is effective as long as the userInfo parameter is unique for each user. This is patched in versions 6.3.0 and v4.1.0. Users are advised to upgrade. Users unable to upgrade may use a random, non-predictable userInfo parameter for each user as a mitigation.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2023-27495
Confirmed fixed CVEs
Not specified
Updated in this feed
7 Nov 2026, 02:23 UTC · Revision 1

Source evidence

Bypass of CSRF protection in the presence of predictable userInfo in @fastify/csrf-protection

core-osv · Original source

Published 20 Apr 2023, 17:05 UTC

@fastify/csrf-protection is a plugin which helps protect Fastify servers against CSRF attacks. The CSRF protection enforced by the @fastify/csrf-protection library in combination with @fastify/cookie can be bypassed from network and same-site attackers under certain conditions. @fastify/csrf-protection supports an optional userInfo parameter that binds the CSRF token to the user. This parameter has been introduced to prevent cookie-tossing attacks as a fix for CVE-2021-29624. Whenever userInfo parameter is missing, or its value can be predicted for the target user account, network and same-site attackers can 1. fixate a _csrf cookie in the victim's browser, and 2. forge CSRF tokens that are valid for the victim's session. This allows attackers to bypass the CSRF protection mechanism. As a fix, @fastify/csrf-protection starting from version 6.3.0 (and v4.1.0) includes a server-defined secret hmacKey that cryptographically binds the CSRF token to the value of the _csrf cookie and the userInfo parameter, making tokens non-spoofable by attackers. This protection is effective as long as the userInfo parameter is unique for each user. This is patched in versions 6.3.0 and v4.1.0. Users are advised to upgrade. Users unable to upgrade may use a random, non-predictable userInfo parameter for each user as a mitigation.

osv:CVE-2023-27495
Complete source record
{
  "id": "16d59473954648a2929e880c037543e43dcaf3406f0d367208aadeccc43e0fe1",
  "url": "https://osv.dev/vulnerability/CVE-2023-27495",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Bypass of CSRF protection in the presence of predictable userInfo in @fastify/csrf-protection",
    "summary": "@fastify/csrf-protection is a plugin which helps protect Fastify servers against CSRF attacks. The CSRF protection enforced by the @fastify/csrf-protection library in combination with @fastify/cookie can be bypassed from network and same-site attackers under certain conditions. @fastify/csrf-protection supports an optional userInfo parameter that binds the CSRF token to the user. This parameter has been introduced to prevent cookie-tossing attacks as a fix for CVE-2021-29624. Whenever userInfo parameter is missing, or its value can be predicted for the target user account, network and same-site attackers can 1. fixate a _csrf cookie in the victim's browser, and 2. forge CSRF tokens that are valid for the victim's session. This allows attackers to bypass the CSRF protection mechanism. As a fix, @fastify/csrf-protection starting from version 6.3.0 (and v4.1.0) includes a server-defined secret hmacKey that cryptographically binds the CSRF token to the value of the _csrf cookie and the userInfo parameter, making tokens non-spoofable by attackers. This protection is effective as long as the userInfo parameter is unique for each user. This is patched in versions 6.3.0 and v4.1.0. Users are advised to upgrade. Users unable to upgrade may use a random, non-predictable userInfo parameter for each user as a mitigation.",
    "evidence": "osv:CVE-2023-27495",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2023-27495",
      "aliases": [
        "CVE-2023-27495",
        "GHSA-qrgf-9gpc-vrxw"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/fastify/csrf-protection",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "42a4f1cec962cc791f33bb190678a3ce4ebce226"
                },
                {
                  "introduced": "ff62a22164dd3d9c352437ce58a0685619e774d1"
                },
                {
                  "fixed": "e746cf735e926330b803112eb439635bb8693c74"
                },
                {
                  "fixed": "be3e5761f37aa05c7c1ac8ed44499c51ecec8058"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:fastify:csrf-protection:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "4.1.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:fastify:csrf-protection:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "5.0.0"
                      },
                      {
                        "fixed": "6.3.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "be3e5761f37aa05c7c1ac8ed44499c51ecec8058"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v4.0.1",
            "v6.2.0",
            "v6.1.0",
            "v6.0.0",
            "v5.1.0",
            "v5.0.0",
            "v4.0.0",
            "v3.1.0",
            "v3.0.1",
            "v3.0.0",
            "v2.0.0",
            "v1.0.4"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-27495.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:49.323498028Z",
      "provider": "osv",
      "references": [
        "https://www.cvedetails.com/cve/CVE-2021-29624",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/27xxx/CVE-2023-27495.json",
        "https://github.com/fastify/csrf-protection/security/advisories/GHSA-qrgf-9gpc-vrxw",
        "https://nvd.nist.gov/vuln/detail/CVE-2023-27495",
        "https://github.com/fastify/csrf-protection/commit/be3e5761f37aa05c7c1ac8ed44499c51ecec8058"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-352"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/27xxx/CVE-2023-27495.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2023-27495",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 517331,
  "published_at": "2023-04-20T17:05:21.515+00:00"
}