Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS0yY2NmLWZmcmotbTRxd84AAy6-

CSRF token fixation in fastify-passport

The CSRF protection enforced by the @fastify/csrf-protection library, when combined with @fastify/passport, can be bypassed by network and same-site attackers.

Details

fastify/csrf-protection implements the synchronizer token pattern (using plugins @fastify/session and @fastify/secure-session) by storing a random value used for CSRF token generation in the _csrf attribute of a user's session.

The @fastify/passport library does not clear the session object upon authentication, preserving the _csrf attribute between pre-login and authenticated sessions. Consequently, CSRF tokens generated before authentication are still valid. Network and same-site attackers can thus obtain a CSRF token for their pre-session, fixate that pre-session in the victim's browser via cookie tossing, and then perform a CSRF attack after the victim authenticates.

Fix

As a solution, newer versions of @fastify/passport include the configuration options

to clear all the session attributes by default, preserving those explicitly defined in clearSessionIgnoreFields.

Credits

Permalink: https://github.com/advisories/GHSA-2ccf-ffrj-m4qw
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0yY2NmLWZmcmotbTRxd84AAy6-
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 1 year ago
Updated: 6 months ago


CVSS Score: 6.5
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Identifiers: GHSA-2ccf-ffrj-m4qw, CVE-2023-29020
References: Repository: https://github.com/fastify/fastify-passport
Blast Radius: 8.5

Affected Packages

npm:@fastify/passport
Dependent packages: 8
Dependent repositories: 20
Downloads: 54,873 last month
Affected Version Ranges: >= 2.0.0, < 2.3.0, < 1.1.0
Fixed in: 2.3.0, 1.1.0
All affected versions: 1.0.0, 1.0.1, 2.0.0, 2.0.1, 2.1.0, 2.2.0
All unaffected versions: 1.1.0, 2.3.0, 2.4.0