Executive brief
NextAuth.js is an authentication library for Next.js applications that supports sign-in via email verification links. A flaw in the Prisma database adapter's token verification logic allowed attackers to reuse a valid verification token issued to one user to sign in as a different user. This affects only implementations using both the Prisma adapter and the Email provider, potentially enabling account takeover attacks.
Technical details
The vulnerability is an insecure authentication token verification flaw (CWE-290) in the Prisma database adapter of NextAuth.js versions prior to 3.3.0. The adapter was validating the verification token but failing to validate the identifier (email address) associated with that token. This allows an attacker with a valid token intended for one email address to authenticate as a different user by submitting the same token. The attack requires knowledge of a valid token and network access to the application; no additional authentication is required. The vulnerability is specific to implementations using both the Prisma adapter and the Email provider—users of the default TypeORM adapter or other authentication methods are unaffected. The issue was patched in version 3.3.0 (released 2021-02-09).
Affected products
- NextAuth.js next-auth < 3.3.0
Timeline
- 2021-02-08: disclosed: Vulnerability reported via responsible disclosure
- 2021-02-09: patched: Fix released in version 3.3.0
- 2021-02-10: advisory: CVE-2021-21310 assigned
- 2021-02-11: advisory: Public advisory published