{"id":"CVE-2023-29020","summary":"Cross site request forgery token fixation in fastify-passport","details":"@fastify/passport is a port of passport authentication library for the Fastify ecosystem. The CSRF (Cross-Site Request Forger) protection enforced by the `@fastify/csrf-protection` library, when combined with `@fastify/passport` in affected versions, can be bypassed by network and same-site attackers. `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. As a solution, newer versions of `@fastify/passport` include the configuration options: `clearSessionOnLogin (default: true)` and `clearSessionIgnoreFields (default: ['passport', 'session'])` to clear all the session attributes by default, preserving those explicitly defined in `clearSessionIgnoreFields`.","aliases":["GHSA-2ccf-ffrj-m4qw"],"modified":"2026-08-12T03:51:26.421545523Z","published":"2023-04-21T22:31:56.768Z","database_specific":{"cwe_ids":["CWE-352","CWE-384"],"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/29xxx/CVE-2023-29020.json","cna_assigner":"GitHub_M"},"references":[{"type":"WEB","url":"https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#synchronizer-token-pattern"},{"type":"WEB","url":"https://owasp.org/www-community/attacks/csrf"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/29xxx/CVE-2023-29020.json"},{"type":"ADVISORY","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":"FIX","url":"https://github.com/fastify/fastify-passport/commit/07c90feab9cba0dd4779e47cfb0717a7e2f01d3d"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://github.com/fastify/fastify-passport","events":[{"introduced":"0"},{"fixed":"628664a0c86f489def6fd2303990ba059cca5417"},{"introduced":"673e5abc3f342170e65669c023cebb1f5f4b3784"},{"fixed":"30843bc2f201879950311ad422bc57747a98f35f"},{"fixed":"07c90feab9cba0dd4779e47cfb0717a7e2f01d3d"}],"database_specific":{"cpe":"cpe:2.3:a:fastify:passport:*:*:*:*:*:node.js:*:*","extracted_events":[{"introduced":"0"},{"fixed":"1.1.0"},{"introduced":"2.0.0"},{"fixed":"2.3.0"}],"source":["CPE_RANGE","REFERENCES"]}}],"versions":["v1.0.1","v2.2.0","v2.1.0","v2.0.1","v2.0.0","v1.0.0","v0.5.0","v0.4.1","v0.3.0","v0.2.0","v0.1.0"],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-29020.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"}]}