WordPress / WordPress/two-factor

Email provider "Resend Code" button remains visible and interactive while user is rate-limited

Open
#920 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
825
Forks
187
Avg merge
2d 11h
Merged PRs (30d)
17

Description

Problem

When the rate limiter blocks a POST submission, login_html() re-renders the 2FA form by calling authentication_page(). The email provider's authentication_page() always renders the "Resend Code" submit button (providers/class-two-factor-email.php line 374–376), so the button is visible and clickable even while the user is locked out.

The user sees:

  • An error: "Too many invalid verification codes, try again in X minutes"
  • A prompt: "A verification code has been sent to your email"
  • A "Resend Code" button that appears functional

Clicking "Resend Code" while rate-limited produces the same rate-limit error again (since PR #917 moves the gate before pre_process_authentication()). No new email is sent, but the user has no way to know that — the form just reloads with the same error. A user who sees a "Resend Code" button will naturally try it when they think they didn't receive their code or their code expired, and hitting the same wall repeatedly with no explanation is confusing.

Expected behaviour

While the user is rate-limited, the "Resend Code" button should either:

  1. Not be renderedauthentication_page() could receive or check the rate-limited state and omit the resend UI, or
  2. Be rendered as disabled — visible but clearly unavailable, ideally with a label indicating when it will become active again

Notes

  • authentication_page() currently has no awareness of rate-limit state; adding a check for Two_Factor_Core::is_user_rate_limited() inside the provider would couple it to core, which may not be desirable
  • An alternative is to pass a flag through login_html()authentication_page() indicating that the form is in a locked state
  • The "A verification code has been sent" prompt (line 360) is also shown unconditionally and may be misleading in this state

Related

  • Issue #918 — rate-limit error message wording
  • PR #917 — rate-limit gate ordering fix

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing login_html() into authentication_page() in providers/class-two-factor-email.php, especially lines 360 and 374–376, and inspect how the rate-limited state is available. Decide how the locked state should reach the provider without an undesirable core coupling. Done means a rate-limited form no longer offers an apparently usable resend action and does not misleadingly claim a code was sent.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.