Skip to content

Email and recovery code fields invite password managers to fill a TOTP code #1048

Backlog

Description

@dknauss

Describe the bug

Follow-up to #945. #1021 fixes steps 1 and 2 of that issue. This covers step 3.

The emailed code field and the recovery code field both use autocomplete="one-time-code". The TOTP login field uses the same value. A password manager cannot tell which method is shown. If the user has a TOTP entry saved for the site, the manager may fill that code into the email or recovery code field. The code is wrong.

Email and recovery codes are 8 digits by default. A 6-digit TOTP code does not trigger auto-submit in those fields. But the field looks filled, so the user may click Log In without checking. Repeated failures can trigger the rate limit.

Note

On a site that filters the email code to 6 digits (two_factor_email_token_length), auto-submit sends the wrong code at once.

Expected: the email and recovery code fields do not receive a TOTP code.

Steps to Reproduce

  1. In a password manager with built-in TOTP, save a TOTP entry for the site. For example, start authenticator setup and save the QR code, but do not click Verify.
  2. Make sure the user's only two-factor method is Email.
  3. Log out. Log in with username and password.
  4. On the email code screen, the password manager fills its TOTP code into the email code field.
  5. Click Log In. The login fails with an invalid code error.
  6. Repeat. The rate limit is triggered.
  7. The same can happen on the recovery code screen.

Screenshots, screen recording, code snippet

Where

File Input Default length
providers/class-two-factor-email.php two-factor-email-code 8
providers/class-two-factor-backup-codes.php two-factor-backup-code 8
providers/class-two-factor-totp.php login authcode 6

All three use autocomplete="one-time-code". Auto-submit fires only when the digit count matches data-digits (providers/js/two-factor-login-authcode.js).

Trade-off

The same hint helps some users. Safari and iOS can fill a code from a received email. #1017 put the code in the email subject, which may help that. Removing the hint could break it.

Possible directions

  • Test which browsers and password managers fill each field.
  • Keep the hint if email autofill works well and TOTP mix-ups are rare.
  • Otherwise, try a different autocomplete value or field name for the email and recovery code fields.
  • Turn off auto-submit on the email field when its code is 6 digits. Make authcode auto-submit opt-out via data-no-auto-submit #1036 added data-no-auto-submit.
  • When a code fails, mention that a password manager may have filled it.

Testing needed

  • 1Password, Bitwarden, Apple Passwords and Google Password Manager.
  • Safari on macOS and iOS for filling the emailed code.

Environment information

  • Previously tested with the 1Password Chrome extension on macOS.

Please confirm that you have searched existing issues in this repository.

Yes

Please confirm that you have tested with all plugins deactivated except Two-Factor.

Yes

Activity

  1. changed the title [-]Emailed code field invites password managers to fill a TOTP code[/-] [+]Email and recovery code fields invite password managers to fill a TOTP code[/+] on Nov 29, 2026
  2. dknauss commented on Nov 29, 2026

    @dknauss
    ContributorAuthor

    👋 Please add the TOTP, Emailed Codes, and Backup Codes labels since I can't set them. Thanks!

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions