Skip to content

Since 26.7.0, the original tab can't continue after the verification email is confirmed in another browser (400 "Restart login cookie not found") #55287

Description

@gdsmith

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

authentication

Bug Description

A user registers in browser A and is shown the "Email verification" page. They open the verification link in a different browser, B, and confirm it there. Up to 26.6, reloading the page in A then finished the login and redirected to the client with an authorization code. Since 26.7.0, A gets HTTP 400 "Restart login cookie not found" instead, and the login can't be completed there.

This is bad for email on a different device, but is a real problem in a native app where the app runs registration in an embedded WebView (browser A), and the mail app opens the link in system browser (browser B). B never redirects to the app, and from 26.7.0 the app's own tab can't continue either. The user has verified their email but isn't signed in anywhere, and has to sign in again from scratch. A theme can't recover the original tab, because only the client can start a new authorization request: it holds the PKCE verifier.

It happens with both registration variants in 26.7+:

  • the new default, where the password is set after verification: B is taken through Update password, then A gets the 400
  • with Always set password on register form switched on, which the 26.7.0 upgrading guide offers for the old behaviour: B just shows "Email address verified", and A still gets the 400

So the deprecated switch doesn't bring the old behaviour back for this case.

Version

26.8.2. Also reproduced on 26.7.0, 26.7.1 and nightly (999.0.0-SNAPSHOT, image built 2026-11-17).As in 26.6: once the email has been verified in browser B, reloading or continuing in browser A completes the login. A redirects to the client's redirect_uri with an authorization code, and the browser gets KEYCLOAK_IDENTITY and KEYCLOAK_SESSION. With the 26.7 default flow, where the password is set after verification, any of these would do: - A continues to the credential setup step itself - A restarts to a login page with the email as login_hint - A redirects to the client with an error the client can act on, rather than showing a dead-end 400

Regression

  • The issue is a regression

Expected behavior

As in 26.6: once the email has been verified in browser B, reloading or continuing in browser A completes the login. A redirects to the client's redirect_uri with an authorization code, and the browser gets KEYCLOAK_IDENTITY and KEYCLOAK_SESSION.

With the 26.7 default flow, where the password is set after verification, any of these would do:

  • A continues to the credential setup step itself
  • A restarts to a login page with the email as login_hint
  • A redirects to the client with an error the client can act on, rather than showing a dead-end 400

Actual behavior

Browser A, reload after B has verified (26.7.0, 26.7.1, 26.8.2, nightly):

  • HTTP 400, page: "We are sorry... Restart login cookie not found. It may have expired; it may have been deleted or cookies are disabled in your browser."
  • event: type="CUSTOM_REQUIRED_ACTION_ERROR", error="cookie_not_found"
  • A still holds AUTH_SESSION_ID and KC_AUTH_SESSION_HASH, so the cookies haven't gone. The authentication session they point to can't be continued any more.

How to Reproduce?

  1. Start a stock Keycloak and a mail catcher on one network, for example quay.io/keycloak/keycloak:26.8.2 start-dev --import-realm and axllent/mailpit, and import this realm:

    {
      "realm": "repro",
      "enabled": true,
      "registrationAllowed": true,
      "registrationEmailAsUsername": true,
      "verifyEmail": true,
      "smtpServer": { "host": "mailpit", "port": "1025", "from": "keycloak@example.com" },
      "clients": [
        {
          "clientId": "native-app",
          "publicClient": true,
          "standardFlowEnabled": true,
          "redirectUris": ["com.example.app:/auth"],
          "attributes": { "pkce.code.challenge.method": "S256" }
        }
      ]
    }
  2. Browser A: open
    http://localhost:8080/realms/repro/protocol/openid-connect/registrations?client_id=native-app&response_type=code&scope=openid&redirect_uri=com.example.app:/auth&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256
    and submit the form. A shows "Email verification".

  3. Browser B (another browser or a private window): open the link from the verification email, then "Click here to proceed". On 26.7+ with the default flow, set a password when asked.

  4. Browser A: reload the "Email verification" page.

    • 26.4.7, 26.5.0, 26.6.0: redirects to com.example.app:/auth?...&code=...
    • 26.7.0, 26.7.1, 26.8.2, nightly: 400 "Restart login cookie not found"
  5. Optional: on 26.7+, turn on Always set password on register form (registration flow, Password validation) and repeat. The result is still 400.

Steps were run with two independent curl cookie jars against each image. The same behaviour shows in an iOS app's WKWebView with Safari opening the email link.

Anything else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/authenticationAuth flows, authenticators, required actions, OTP, password policies, brute forcekind/bugCategorizes a PR related to a bugstatus/triageteam/core-authn

    Type

    Fields

    No fields configured for bug.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions