CVE-2021-21310: Next auth Token Verification Bug Vulnerability

LOW
Advisory Identifier: GHSA-pg53-56cg-4m8q
CWE-290
Published
Advisory Summary

CVE-2021-21310 is a LOW token verification bug vulnerability (CWE-290: Authentication Bypass by Spoofing) affecting Next auth libraries in the npm ecosystem. The issue involves token verification bug in next-auth. Remediation is available by upgrading affected packages to version 3.3.0.

CVE-2021-21310 at a Glance

CVE Identifier CVE-2021-21310
GHSA Identifier GHSA-pg53-56cg-4m8q
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-290: Authentication Bypass by Spoofing
Affected Product Next auth
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2021-21310

To remediate this vulnerability, upgrade all affected Next auth dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

next-auth fixed: 3.3.0
npm install next-auth@3.3.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls next-auth

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-21310, inspect your project dependencies using npm:

npm ls next-auth

Analyze the terminal output to locate any version of Next auth in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.0), your application is affected.

Note: The npm ls next-auth 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-290: Authentication Bypass by Spoofing, where this attack-focused weakness is caused by incorrectly implemented authentication schemes that are subject to spoofing attacks. In Next auth, 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

### Impact Implementations using the **Prisma database adapter** with the **Email provider** **are impacted**. Implementations using the Prisma database adapter that are not using the Email provider are not impacted. Implementations using the default database adapter (TypeORM) with the Email provider are not impacted. Implementations not using a database are not impacted. ### Patches This issue is fixed in 3.3.0 and newer versions. ### Workarounds Those not able to upgrade can alternatively disable the Email provider as a workaround. ### Description The Prisma database adapter was checking the verification token but not the identifier (the email address associated with the token). This made it possible to use a valid token assigned to one user, to sign in as another user when using the Prima adapter in conjunction with the Email provider. The defect is specific to the community-supported Prisma database adapter in versions <3.3.0 and is not present in the default database adapter (TypeORM). *Note: The current community-supported adapter was not developed by Prisma.* The defect was a problem in the implementation of verification function the adapter and is not directly related to Prisma. The flaw may exist in other third party database adapters that do not check both the identifier and token values. The design of the database adapter API may be revised in future to help reduce the likelyhood of similar defects. ### Timeline On Monday (2021-02-08) we were notified via responsible disclosure by Alessandro Angelino (@AlessandroA) of a flaw in the implementation of the Prisma database adapter included with NextAuth.js. A detailed write up and proof of concept were provided. The following day (2021-02-09) we published a fix in v3.3.0 and confirmed through internal testing, and with Alessandro, that the issue was resolved in the new release and prompted users to upgrade. On 2021-02-10 we received a CVE ID and published this advisory within a few hours of notification. We would like to thank Alessandro for using responsible disclose to allow us to address the issue promptly and publish this advisory once an update was available that resolved the issue and Balázs Orbán (@balazsorban44) for facilitating a timely release of the fix.

CVE-2021-21310 Affected Next auth Versions

1 component(s)
Fixed Versions:
3.3.0
Product / Package Ecosystem Affected Versions Fixed Version
next-auth
npm
< 3.3.0
3.3.0

References

Frequently Asked Questions

What is CVE-2021-21310?
CVE-2021-21310 is a security vulnerability in Next auth involving Token verification bug in next-auth under CWE-290: Authentication Bypass by Spoofing.
Which Next auth versions are affected?
Affected versions include releases prior to 3.3.0 across affected packages: next-auth.
What version fixes CVE-2021-21310?
Upgrading to 3.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is next-auth affected?
Yes, next-auth is affected in releases prior to 3.3.0. Upgrade your dependency to 3.3.0 or later.
What CWE is associated with CVE-2021-21310?
CVE-2021-21310 is classified under CWE-290: Authentication Bypass by Spoofing (This attack-focused weakness is caused by incorrectly implemented authentication schemes that are subject to spoofing attacks.).
How can I check npm dependencies for CVE-2021-21310?
Run the dependency tree command: 'npm ls next-auth'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-pg53-56cg-4m8q",
  "modified" : "2021-02-22T20:43:03Z",
  "published" : "2021-02-11T21:36:24Z",
  "aliases" : [ "CVE-2021-21310" ],
  "summary" : "Token verification bug in next-auth",
  "details" : "### Impact\n\nImplementations using the **Prisma database adapter** with the **Email provider** **are impacted**.\n\nImplementations using the Prisma database adapter that are not using the Email provider are not impacted.\nImplementations using the default database adapter (TypeORM) with the Email provider are not impacted.\nImplementations not using a database are not impacted.\n\n### Patches\n\nThis issue is fixed in 3.3.0 and newer versions.\n\n### Workarounds\n\nThose not able to upgrade can alternatively disable the Email provider as a workaround.\n\n### Description\n\nThe Prisma database adapter was checking the verification token but not the identifier (the email address associated with the token). This made it possible to use a valid token assigned to one user, to sign in as another user when using the Prima adapter in conjunction with the Email provider. The defect is specific to the community-supported Prisma database adapter in versions <3.3.0 and is not present in the default database adapter (TypeORM).\n\n*Note:  The current community-supported adapter was not developed by Prisma.*\n\nThe defect was a problem in the implementation of verification function the adapter and is not directly related to Prisma.\n\nThe flaw may exist in other third party database adapters that do not check both the identifier and token values.\n\nThe design of the database adapter API may be revised in future to help reduce the likelyhood of similar defects.\n\n### Timeline\n\nOn Monday (2021-02-08) we were notified via responsible disclosure by Alessandro Angelino (@AlessandroA) of a flaw in the implementation of the Prisma database adapter included with NextAuth.js. A detailed write up and proof of concept were provided.\n\nThe following day (2021-02-09) we published a fix in v3.3.0 and confirmed through internal testing, and with Alessandro, that the issue was resolved in the new release and prompted users to upgrade.\n\nOn 2021-02-10 we received a CVE ID and published this advisory within a few hours of notification.\n\nWe would like to thank Alessandro for using responsible disclose to allow us to address the issue promptly and publish this advisory once an update was available that resolved the issue and Balázs Orbán (@balazsorban44) for facilitating a timely release of the fix.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "next-auth"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nextauthjs/next-auth/security/advisories/GHSA-pg53-56cg-4m8q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21310"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nextauthjs/next-auth/releases/tag/v3.3.0"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/next-auth"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-290" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-02-11T21:36:12Z",
    "nvd_published_at" : "2021-02-11T22:15:00Z"
  }
}