CVE-2022-39263: @next auth/upstash redis adapter Upstash Adapter Missing Token Verification Vulnerability
MODERATECVE-2022-39263 is a MODERATE (CVSS 6.8) upstash adapter missing token verification vulnerability (CWE-287: Improper Authentication) affecting @next auth/upstash redis adapter libraries in the npm ecosystem. The issue involves upstash adapter missing token verification. Remediation is available by upgrading affected packages to version 3.0.2.
CVE-2022-39263 at a Glance
Security Impact
CVSS: 6.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N).
How to Fix CVE-2022-39263
To remediate this vulnerability, upgrade all affected @next auth/upstash redis adapter 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 @next-auth/upstash-redis-adapter@3.0.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @next-auth/upstash-redis-adapter
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-39263, inspect your project dependencies using npm:
npm ls @next-auth/upstash-redis-adapter
Analyze the terminal output to locate any version of @next auth/upstash redis adapter in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.2), your application is affected.
Note: The npm ls @next-auth/upstash-redis-adapter 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-287: Improper Authentication, where when an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct. In @next auth/upstash redis adapter, 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-2022-39263 Affected @next auth/upstash redis adapter Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@next-auth/upstash-redis-adapter
|
npm |
< 3.0.2
|
3.0.2
|
References
Frequently Asked Questions
What is CVE-2022-39263?
Which @next auth/upstash redis adapter versions are affected?
What version fixes CVE-2022-39263?
Is @next-auth/upstash-redis-adapter affected?
What is the CVSS score of CVE-2022-39263?
What CWE is associated with CVE-2022-39263?
How can I check npm dependencies for CVE-2022-39263?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4rxr-27mm-mxq9",
"modified" : "2022-09-30T05:31:32Z",
"published" : "2022-09-30T05:31:32Z",
"aliases" : [ "CVE-2022-39263" ],
"summary" : "Upstash Adapter missing token verification",
"details" : "### Impact\nApplications that use `next-auth` Email Provider and `@next-auth/upstash-redis-adapter` before v3.0.2 are affected.\n\n### Description\nThe Upstash Redis adapter implementation did not check for both the identifier (email) and the token, but only checking for the identifier when verifying the token in the email callback flow. An attacker who knows about the victim's email could easily sign in as the victim, given the attacker also knows about the verification token's expired duration. \n\n### Patches\nThe vulnerability is patched in v3.0.2.\nTo upgrade, run one of the following:\n```\nnpm i @next-auth/upstash-redis-adapter@latest\n```\n```\nyarn add @next-auth/upstash-redis-adapter@latest\n```\n```\npnpm add @next-auth/upstash-redis-adapter@latest\n```\n\n### Workarounds\nUsing Advanced Initialization, developers can check the requests and compare the query's token and identifier before proceeding. Below is an example of how to do this: (Upgrading is still strongly recommended)\n\n```js\nimport { createHash } from \"crypto\"\nexport default async function auth(req, res) {\n if (req.method === \"POST\" && req.action === \"callback\") {\n const token = req.query?.token\n const identifier = req.query?.email\n function hashToken(token: string) {\n const provider = authOptions.providers.find((p) => p.id === \"email\")\n const secret = authOptions.secret\n return (\n createHash(\"sha256\")\n // Prefer provider specific secret, but use default secret if none specified\n .update(`${token}${provider.secret ?? secret}`)\n .digest(\"hex\")\n )\n }\n const hashedToken = hashToken(token)\n\n const invite = await authOptions.adapter.useVerificationToken?.({\n identifier,\n token: hashedToken,\n })\n if (invite.token !== hashedToken) {\n res.status(400).json({ error: \"Invalid token\" })\n }\n }\n return await NextAuth(req, res, authOptions)\n}\n\n```\n### References\nEmailProvider: https://next-auth.js.org/providers/email\nAdvanced Initialization: https://next-auth.js.org/configuration/initialization#advanced-initialization\nUpstash Redis Adapter: https://next-auth.js.org/adapters/upstash-redis\n\n### For more information\nIf you have any concerns, we request responsible disclosure, outlined here: https://next-auth.js.org/security#reporting-a-vulnerability\n\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@next-auth/upstash-redis-adapter"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nextauthjs/next-auth/security/advisories/GHSA-4rxr-27mm-mxq9"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-39263"
}, {
"type" : "WEB",
"url" : "https://github.com/nextauthjs/next-auth/commit/d16e04848ee703cf797724194d4ad2907fe125a9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nextauthjs/next-auth"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-287" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-09-30T05:31:32Z",
"nvd_published_at" : "2022-09-28T21:15:00Z"
}
}