Vulnerabilities in pkg:npm/@fastify/passport
PACKAGECVE-2023-29020 is a MODERATE (CVSS 6.5) csrf token fixation vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting @fastify/passport libraries in the npm ecosystem. The issue involves csrf token fixation in fastify-passport. Remediation is available by upgrading affected packages to version 1.1.0, 2.3.0.
pkg:npm/@fastify/passport
Vulnerability advisories affecting package pkg:npm/@fastify/passport. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-2ccf-ffrj-m4qw | CVE-2023-29020 | MODERATE | CSRF token fixation in fastify-passport |
| GHSA-4m3m-ppvx-xgw9 | CVE-2023-29019 | HIGH | Session fixation in fastify-passport |
CVE-2023-29020 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-2023-29020
To remediate this vulnerability, upgrade all affected @fastify/passport 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/passport@1.1.0
npm install @fastify/passport@2.3.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @fastify/passport
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2023-29020, inspect your project dependencies using npm:
npm ls @fastify/passport
Analyze the terminal output to locate any version of @fastify/passport in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.0), your application is affected.
Note: The npm ls @fastify/passport 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/passport, 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-2023-29020 Affected @fastify/passport Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@fastify/passport
|
npm |
< 1.1.0
|
1.1.0
|
|
@fastify/passport
|
npm |
≥ 2.0.0
< 2.3.0
|
2.3.0
|
References
Frequently Asked Questions
What is CVE-2023-29020?
Which @fastify/passport versions are affected?
What version fixes CVE-2023-29020?
Is @fastify/passport affected?
What is the CVSS score of CVE-2023-29020?
What CWE is associated with CVE-2023-29020?
How can I check npm dependencies for CVE-2023-29020?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-2ccf-ffrj-m4qw",
"modified" : "2023-04-24T15:56:27Z",
"published" : "2023-04-21T22:32:47Z",
"aliases" : [ "CVE-2023-29020" ],
"summary" : "CSRF token fixation in fastify-passport",
"details" : "The [CSRF](https://owasp.org/www-community/attacks/csrf) protection enforced by the `@fastify/csrf-protection` library, when combined with `@fastify/passport`, can be bypassed by network and same-site attackers.\n\n## Details\n`fastify/csrf-protection` implements the [synchronizer token pattern](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#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.\n\nThe `@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](https://canitakeyoursubdomain.name/) 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.\n\n## Fix\nAs a solution, newer versions of `@fastify/passport` include the configuration options\n\n* `clearSessionOnLogin (default: true)` and\n* `clearSessionIgnoreFields (default: ['session'])`\n\nto clear all the session attributes by default, preserving those explicitly defined in `clearSessionIgnoreFields`.\n\n## Credits\n* Pedro Adão (@pedromigueladao), [Instituto Superior Técnico, University of Lisbon](https://tecnico.ulisboa.pt/)\n* Marco Squarcina (@lavish), [Security & Privacy Research Unit, TU Wien](https://secpriv.wien/)",
"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/passport"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.1.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/passport"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.3.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-passport/security/advisories/GHSA-2ccf-ffrj-m4qw"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-29020"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-passport/commit/07c90feab9cba0dd4779e47cfb0717a7e2f01d3d"
}, {
"type" : "WEB",
"url" : "https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#synchronizer-token-pattern"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-passport"
}, {
"type" : "WEB",
"url" : "https://owasp.org/www-community/attacks/csrf"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-04-21T22:32:47Z",
"nvd_published_at" : "2023-04-21T23:15:20Z"
}
}