CVE-2021-21310: Token verification bug in next-auth

next-auth Updated 02 Oct 2025

Summary

11/02/2021
Yes i
Low
Not published

CVE-2021-21310: Token verification bug in next-auth. Affects next-auth versions < 3.3.0. Fixed in 3.3.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

NextAuth.js is an open-source authentication library for Next.js applications. It provides a set of utilities and authentication strategies to simplify the implementation of authentication in web applications. The library supports various authentication providers, including email, social media, and external identity providers. The Prisma database adapter is a community-supported adapter for NextAuth.js that allows integration with the Prisma database ORM. This vulnerability affects NextAuth.js implementations using the Prisma database adapter with the Email provider.

Vulnerability Detail

The Prisma database adapter in NextAuth.js had a token verification bug that allowed an attacker to use a valid token assigned to one user to sign in as another user. This vulnerability was specific to the community-supported Prisma database adapter in versions prior to 3.3.0 and did not affect the default database adapter (TypeORM). The bug was a result of not checking the identifier (email address) associated with the token during verification. This flaw could potentially lead to unauthorized access and privilege escalation in affected applications.

How To Fix

Latest published version: 4.24.15 as of 23 Oct 2026

npm install next-auth@4.24.15

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.3.0

This is the first release that contains the fix.

npm install next-auth@3.3.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the latest version is not immediately feasible, a workaround is to disable the Email provider in NextAuth.js. This can be done by modifying the NextAuth.js configuration to remove the Email provider configuration and related code. However, this workaround should be considered temporary, and upgrading to the latest version is still recommended for a permanent fix.

Conclusion

The token verification bug in the Prisma database adapter of NextAuth.js allowed for unauthorized access and potential privilege escalation. It is crucial for developers to upgrade to version 3.3.0 or newer to fix this vulnerability. Disabling the Email provider can serve as a temporary workaround until the upgrade is performed. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for next-auth →

Share this vulnerability

FAQ

Versions of NextAuth.js prior to 3.3.0 that use the Prisma database adapter with the Email provider are affected.

No, applications using the default database adapter (TypeORM) with the Email provider are not affected by this vulnerability.

No, applications that do not use a database are not affected by this vulnerability.

The Prisma database adapter is the only known affected adapter. However, similar vulnerabilities may exist in other third-party database adapters that do not properly check both the identifier and token values during verification.

The design of the database adapter API may be revised in the future to reduce the likelihood of similar vulnerabilities. However, specific details about the planned revisions are not provided in the advisory.

Related vulnerabilities

Recent vulnerabilities recorded for next-auth.

How To Fix

Latest published version: 4.24.15 as of 23 Oct 2026

npm install next-auth@4.24.15

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.3.0

This is the first release that contains the fix.

npm install next-auth@3.3.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback