@fastify/oauth2 vulnerable to Cross Site Request Forgery due to reused Oauth2 state
Impact
All versions of @fastify/oauth2 used a statically generated state parameter at startup time and were used across all requests for all users.
The purpose of the Oauth2 state parameter is to prevent Cross-Site-Request-Forgery attacks. As such, it should be unique per user and should be connected to the user's session in some way that will allow the server to validate it.
Patches
v7.2.0 changes the default behavior to store the state in a cookie with the http-only and same-site=lax attributes set. The state is now by default generated for every user.
Note that this contains a breaking change in the checkStateFunction function, which now accepts the full Request object.
Workarounds
There are no known workarounds.
References
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | @fastify/oauth2 | < 7.2.0 | 7.2.0 |
References
- https://github.com/fastify/fastify-oauth2/security/advisories/GHSA-g8x5-p9qc-cf95
- https://nvd.nist.gov/vuln/detail/CVE-2023-35935
- https://github.com/fastify/fastify-oauth2/commit/bff756b456cbb769080631af2beb85671ff4c79c
- https://auth0.com/docs/secure/attack-protection/state-parameters
- https://github.com/fastify/fastify-oauth2
- https://github.com/fastify/fastify-oauth2/releases/tag/v7.2.0
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N- Weakness (CWE)
CWE-352- Platform
- npm
- Package
@fastify/oauth2- Disclosed
- 05.07.2023
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-g8x5-p9qc-cf95 - CC BY 4.0
Vulnerability history: @fastify/oauth2
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
This is the only known vulnerability of this package.
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.