Wysoka

Missing proper state, nonce and PKCE checks for OAuth authentication

  • Ujawniono: 13.03.2023
  • Aktualizacja: 11.10.2026 10:22

Impact

next-auth applications using OAuth provider versions before v4.20.1 are affected.

A bad actor who can spy on the victim's network or 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.

As an example, an attack can happen in the following scenario.

TL;DR: The attacker steals the victim's authenticated callback by intercepting and tampering with the authorization URL created by next-auth.

  1. The victim attempts to log in to the next-auth site. For example https://next-auth-example.vercel.app/

  2. next-auth sets the checks cookies according to how the OAuth provider is configured. In this case, state and pkce are set by default for the Google Provider. <img width="1971" alt="Screen Shot 2023-03-03 at 09 54 26" src="https://user-images.githubusercontent.com/31528554/222619750-a2062bb8-99eb-4985-a75c-d75acd3da67e.png">

  3. The attacker intercepts the returned authorization URL, strips away the OAuth check (nonce, state, pkce), and returns the URL without the check to the victim's browser. For example: From https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?client_id=client_id&scope=openid%20email%20profile&response_type=code&redirect_uri=https%3A%2F%2Fnext-auth-example.vercel.app%2Fapi%2Fauth%2Fcallback%2Fgoogle&state=state&code_challenge=code_challenge&code_challenge_method=S256&service=lso&o2v=2&flowName=GeneralOAuthFlow to https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?client_id=client_id&scope=openid%20email%20profile&response_type=code&redirect_uri=https%3A%2F%2Fnext-auth-example.vercel.app%2Fapi%2Fauth%2Fcallback%2Fgoogle&service=lso&o2v=2&flowName=GeneralOAuthFlow. Notice the parameters state, code_challenge and code_verifier are removed from the victim's address bar.

  4. The victim attempts to log in using their OAuth account.

  5. The Authorization Server logs the victim in and calls back to the next-auth api/auth/callback/:providerIdendpoint. 5.1. The attacker intercepts and logs this callback URL for later use. 5.2. next-auth checks the callback call from OAuth Authorization Server (doesn't have checks) and compares the checks with the cookies set (has checks) at step 2. This check will fail, resulting in the victim isn't logged in. However, at this step, the Authorization Server has already accepted the victim's request to log in and generated/sent a code in the URL.

  6. The attacker now has an authorization URL with the code that the AS will exchange for valid access_token/id_token and can log in as the victim automatically. They can open a new browser window and paste in the URL logged at step 5.1 and log in as the victim.

Patches

We patched the vulnerability in next-auth v4.20.1 To upgrade, run one of the following:

bash
npm i next-auth@latest
bash
yarn add next-auth@latest
bash
pnpm add next-auth@latest

Workarounds

Upgrading to latest is the recommended way to fix this issue. However, using Advanced Initialization, developers can manually check the callback request for state, pkce, and nonce against the provider configuration, and abort the sign-in process if there is a mismatch. Check out the source code for help.

References

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka npm next-auth < 4.20.1 4.20.1

Odnośniki

Ocena CVSS 8.1/10
Wektor CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
Słabość (CWE)
CWE-352
Platforma
npm
Paczka
next-auth
Ujawniono
13.03.2023
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-7r7x-4c4q-c4qf - CC BY 4.0

Historia podatności: next-auth

Wszystkie opisane podatności tej paczki (Paczka npm), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkie (14) w archiwum
Wszystkich wpisów
14
Pierwsza → ostatnia
02.2021 07.2026
Bez poprawki
0
Wykorzystywana w atakach
0

Rozkład istotności

  • Krytyczna 3
  • Wysoka 4
  • Średnia 5
  • Niska 2

Ujawnienia w latach

  1. 2021: 1
  2. 2022: 6
  3. 2023: 2
  4. 2024: 0
  5. 2025: 1
  6. 2026: 4
Istotność:
  1. Wysoka · 7.5 CVE-2026-73418 >= 5.0.0-beta.0, < 5.0.0-beta.32, >= 4.0.6, < 4.24.15 5.0.0-beta.32, 4.24.15
  2. Krytyczna CVE-2026-73420 >= 4.10.3, < 4.24.15, >= 5.0.0-beta.1, < 5.0.0-beta.32 4.24.15, 5.0.0-beta.32
  3. Missing proper state, nonce and PKCE checks for OAuth authentication ten wpis
    Wysoka · 8.1 CVE-2023-27490 < 4.20.1 4.20.1
  4. Krytyczna · 9.1 CVE-2022-35924 >= 4.0.0, < 4.10.3, < 3.29.10 4.10.3, 3.29.10
  5. Wysoka · 7.1 CVE-2022-31127 < 3.29.8, >= 4.0.0, < 4.9.0 3.29.8, 4.9.0
  6. Wysoka · 7.5 CVE-2022-31093 < 3.29.5, >= 4.0.0, < 4.5.0 3.29.5, 4.5.0

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.