Description
NextAuth.js is an open source authentication solution for Next.js applications. `next-auth` applications using OAuth provider versions before `v4.20.1` have been found to be subject to an authentication vulnerability. A bad actor who can read traffic on the victim's network or who is able to social engineer the victim to click a manipulated login link could intercept and tamper with the authorization URL to **log in as the victim**, bypassing the CSRF protection. This is due to a partial failure during a compromised OAuth session where a session code is erroneously generated. This issue has been addressed in version 4.20.1. Users are advised to upgrade. Users unable to upgrade may using Advanced Initialization, manually check the callback request for state, pkce, and nonce against the provider configuration to prevent this issue. See the linked GHSA for details.
Remediation
References
https://github.com/nextauthjs/next-auth/security/advisories/GHSA-7r7x-4c4q-c4qf
https://danielfett.de/2020/05/16/pkce-vs-nonce-equivalent-or-not/
https://www.rfc-editor.org/rfc/rfc6749#section-10.12
https://next-auth.js.org/configuration/initialization#advanced-initialization
https://authjs.dev/reference/core/providers#checks
https://next-auth.js.org/configuration/providers/oauth
https://security.netapp.com/advisory/ntap-20230420-0006/