8000 VERIFY_EMAIL cooldown allows concurrent requests to send multiple emails · Issue #55405 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

VERIFY_EMAIL cooldown allows concurrent requests to send multiple emails #55405

Description

@ucchishta-dd

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

The VERIFY_EMAIL resend cooldown does not reliably prevent concurrent requests from sending multiple verification emails for the same user.

The explicit resend flow checks the cooldown and creates the cooldown entry as separate operations:

  1. processAction() checks the existing cooldown.
  2. If no cooldown is found, it calls process().
  3. process() creates the cooldown entry and sends the email.

Two requests arriving at nearly the same time can both complete the check before either creates the cooldown entry. Both requests may then send an email.

This is a follow-up to:

The pull request addresses sequential fresh-session sends, but intentionally leaves concurrent admission as a separate issue.
The check-then-write sequence is present on main at commit 994ee7e.

Version

26.6.4

Regression

  • The issue is a regression

Expected behavior

For a single user, only one verification email request should be admitted during the cooldown period, even when requests arrive concurrently.

This should apply when requests are made through:

  • Two concurrent explicit resend requests.
  • Two concurrent automatic verification email sends.
  • An automatic send and an explicit resend at the same time.
  • Different Keycloak nodes.

Requests for different users should remain independent.

After the cooldown expires, a new request should be allowed to send another verification email.

Actual behavior

Reading the cooldown entry and creating it are separate operations.
Multiple requests can therefore observe that no cooldown exists before any request creates it. Each request may then send a verification email.

How to Reproduce?

  1. Configure Keycloak with a working SMTP server.
  2. Enable email verification for the realm.
  3. Create a user with:
    • A valid email address.
    • A known password.
    • emailVerified=false.
  4. Sign in and open the email verification page in two or more independent sessions.
  5. Wait until any existing resend cooldown has expired, then record the current number of received emails.
  6. Send explicit resend requests from those sessions at nearly the same time.
  7. Inspect the recipient mailbox or SMTP server.

Depending on request timing, two or more requests can pass the cooldown check and each send a verification email.

A deterministic integration test could synchronize two requests after they read the cooldown entry but before either creates it.

The test should also be repeated with two Keycloak nodes, sending one request to each node.

Anything else?

Relevant code:

A possible solution is to use one shared atomic per-user admission operation for both automatic sends and explicit resends. SingleUseObjectProvider.putIfAbsent() may provide the required operation, subject to verifying its behavior with both embedded and remote Infinispan.

Suggested tests:

  • Two concurrent explicit resend requests for the same user.
  • An automatic send racing an explicit resend.
  • Requests handled by different Keycloak nodes.
  • Concurrent requests for different users.
  • Retry after the cooldown expires.

The behavior after EmailException also needs an explicit policy:

  • Keeping the cooldown protects the rate limit when SMTP delivery is uncertain, but delays retry after a confirmed failure.
  • Removing the cooldown permits immediate retry, but SMTP may already have accepted the first email.

Activity

  1. added theissue type on Nov 20, 2026
  2. added
    kind/bug
    on Nov 20, 2026
  3. added
    area/authentication
    on Nov 20, 2026
  4. added 2 commits that reference this issue on Dec 3, 2026
    9f56432
    ae1e52b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/authenticationkind/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

    0