Vulnerabilities in pkg:npm/@fastify/oauth2
PACKAGECVE-2023-31999 is a HIGH (CVSS 7.4) @fastify/oauth2 vulnerable to cross site vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting @fastify/oauth2 libraries in the npm ecosystem. The issue involves @fastify/oauth2 vulnerable to cross site request forgery due to reused oauth2 state. Remediation is available by upgrading affected packages to version 7.2.0.
pkg:npm/@fastify/oauth2
Vulnerability advisories affecting package pkg:npm/@fastify/oauth2. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-g8x5-p9qc-cf95 | CVE-2023-31999 | HIGH | @fastify/oauth2 vulnerable to Cross Site Request Forgery due to reused Oauth2 state |
| GHSA-hgxv-3497-3hhj | - | MODERATE | Duplicate Advisory: @fastify/oauth2 Oauth2 state parameter reuse |
CVE-2023-31999 at a Glance
Security Impact
CVSS: 7.4
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:C/C:H/I:N/A:N).
How to Fix CVE-2023-31999
To remediate this vulnerability, upgrade all affected @fastify/oauth2 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/oauth2@7.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @fastify/oauth2
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2023-31999, inspect your project dependencies using npm:
npm ls @fastify/oauth2
Analyze the terminal output to locate any version of @fastify/oauth2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.2.0), your application is affected.
Note: The npm ls @fastify/oauth2 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/oauth2, 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-31999 Affected @fastify/oauth2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@fastify/oauth2
|
npm |
< 7.2.0
|
7.2.0
|
References
Frequently Asked Questions
What is CVE-2023-31999?
Which @fastify/oauth2 versions are affected?
What version fixes CVE-2023-31999?
Is @fastify/oauth2 affected?
What is the CVSS score of CVE-2023-31999?
What CWE is associated with CVE-2023-31999?
How can I check npm dependencies for CVE-2023-31999?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-g8x5-p9qc-cf95",
"modified" : "2023-07-06T20:39:29Z",
"published" : "2023-07-05T21:36:56Z",
"aliases" : [ "CVE-2023-31999" ],
"summary" : "@fastify/oauth2 vulnerable to Cross Site Request Forgery due to reused Oauth2 state",
"details" : "### Impact\n\nAll versions of @fastify/oauth2 used a statically generated `state` parameter at startup time and were used across all requests for all users.\nThe 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.\n\n### Patches\n\nv7.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.\n\nNote that this contains a breaking change in the `checkStateFunction` function, which now accepts the full `Request` object.\n\n### Workarounds\n\nThere are no known workarounds.\n\n### References\n\n* [Prevent Attacks and Redirect Users with OAuth 2.0 State Parameters](https://auth0.com/docs/secure/attack-protection/state-parameters)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/oauth2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "7.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-oauth2/security/advisories/GHSA-g8x5-p9qc-cf95"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-35935"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-oauth2/commit/bff756b456cbb769080631af2beb85671ff4c79c"
}, {
"type" : "WEB",
"url" : "https://auth0.com/docs/secure/attack-protection/state-parameters"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-oauth2"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-oauth2/releases/tag/v7.2.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-352" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2023-07-05T21:36:56Z",
"nvd_published_at" : "2023-07-03T17:15:09Z"
}
}