6.1medium
Token verification bug in next-auth
- Severity
- 6.1medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 1.69% (higher than 77% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-pg53-56cg-4m8q
Description
NextAuth.js (next-auth) is am open source authentication solution for Next.js applications. In next-auth before version 3.3.0 there is a token verification vulnerability. Implementations using the Prisma database adapter in conjunction with the Email provider are impacted. Implementations using the Email provider with the default database adapter are not impacted. Implementations using the Prisma database adapter but not using the Email provider are not impacted. The Prisma database adapter was checking the verification token, but was not verifying the email address associated with that token. This made it possible to use a valid token to sign in as another user when using the Prima adapter in conjunction with the Email provider. This issue is specific to the community supported Prisma adapter. This issue is fixed in version 3.3.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| nextauthjs next-auth | < 3.3.0 | CVE List |
| next-auth (npm) | before 3.3.0 | GitHub Advisory Database |
| nextauth.js next-auth | before 3.3.0 | NVD |
All scores
| GitHub_M | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N |
| GitHub | low rating | |
| NVD | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
| NVD | 4.3medium CVSS:2.0 | AV:N/AC:M/Au:N/C:P/I:N/A:N |
Classification
What each source says
CVE List
NextAuth.js (next-auth) is am open source authentication solution for Next.js applications. In next-auth before version 3.3.0 there is a token verification vulnerability. Implementations using the Prisma database adapter in conjunction with the Email provider are impacted. Implementations using the Email provider with the default database adapter are not impacted. Implementations using the Prisma database adapter but not using the Email provider are not impacted. The Prisma database adapter was checking the verification token, but was not verifying the email address associated with that token. This made it possible to use a valid token to sign in as another user when using the Prima adapter in conjunction with the Email provider. This issue is specific to the community supported Prisma adapter. This issue is fixed in version 3.3.0.
GitHub Advisory Database
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.
NVD (es)
NextAuth.js (next-auth) es una solución de autenticación de código abierto para aplicaciones Next.js. En next-auth versiones anteriores a 3.3.0, se presenta una vulnerabilidad de verificación de tokens. Las implementaciones que usa el adaptador de base de datos Prisma en conjunto con el proveedor de correo electrónico están afectadas. Las implementaciones que usa el proveedor de correo electrónico con el adaptador de base de datos predeterminado no están afectadas. Las implementaciones que usa el adaptador de base de datos Prisma pero que no usa el proveedor de correo electrónico no están afectadas. El adaptador de base de datos de Prisma estaba comprobando el token de verificación, pero no verificaba la dirección de correo electrónico asociada con ese token. Esto hizo posible usar un token válido para iniciar sesión como otro usuario cuando se usa el adaptador Prima en conjunto con el proveedor de correo electrónico. Este problema es específico del adaptador Prisma compatible con la comunidad. Este problema es corregido en versión 3.3.0
References
| https://github.com/nextauthjs/next-auth/security/advisories/GHSA-pg53-56cg-4m8q | exploit, third-party-advisory, web | |
| https://www.npmjs.com/package/next-auth | product, third-party-advisory, web | |
| https://github.com/nextauthjs/next-auth/releases/tag/v3.3.0 | third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-21310 | advisory | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-21310 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-pg53-56cg-4m8q changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-21310 changed 2026-06-17 | Public domain |