{"id":"CVE-2023-29020","published":"2023-04-21T22:31:56Z","modified":"2025-02-04T19:38:09Z","title":"Cross site request forgery token fixation in fastify-passport","vendor":"fastify","product":"fastify-passport","tier":"tail","description":{"text":"@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`.","provenance":"source","from":"CVE.org"},"cvss":{"score":6.5,"severity":"MEDIUM","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00384,"percentile":0.33312,"provenance":"source"},"cwes":[{"id":"CWE-384","name":"Session Fixation"},{"id":"CWE-352","name":"Cross-Site Request Forgery"}],"references":[{"url":"https://github.com/fastify/fastify-passport/security/advisories/GHSA-2ccf-ffrj-m4qw","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/fastify/fastify-passport/commit/07c90feab9cba0dd4779e47cfb0717a7e2f01d3d","tags":["x_refsource_MISC"]},{"url":"https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#synchronizer-token-pattern","tags":["x_refsource_MISC"]},{"url":"https://owasp.org/www-community/attacks/csrf","tags":["x_refsource_MISC"]}],"priority":{"score":11.2,"factors":[{"name":"EPSS percentile","points":6.66},{"name":"CVSS severity","points":4.55}]},"vendorSlug":"fastify","affectedVersions":[{"vendor":"fastify","product":"fastify-passport","versions":["< 1.1.0",">= 2.0.0, < 2.3.0"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"partial","timestamp":"2025-02-04T19:38:02.383186Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"npm","package":"@fastify/passport","vulnerableRanges":["<1.1.0",">=2.0.0, <2.3.0"],"patched":["1.1.0","2.3.0"],"from":["GHSA-2ccf-ffrj-m4qw"],"provenance":"source"}],"euvd":{"id":"EUVD-2023-1154","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-fastify-passport-cve-2023-29019","parents":[{"from":"CVE-2023-29019","to":"CVE-2023-29020","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["src/session-managers/SecureSessionManager.ts"],"commits":["https://github.com/fastify/fastify-passport/commit/43c82c321db58ea3e375dd475de60befbfcf2a11","https://github.com/fastify/fastify-passport/commit/07c90feab9cba0dd4779e47cfb0717a7e2f01d3d"],"basis":"rarely changed file"},{"kind":"similar","provenance":"machine","score":0.56,"basis":"same product + CWE + description similarity"}]}]}}