Repository navigation
Description
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
- 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.
- Make sure the user's only two-factor method is Email.
- Log out. Log in with username and password.
- On the email code screen, the password manager fills its TOTP code into the email code field.
- Click Log In. The login fails with an invalid code error.
- Repeat. The rate limit is triggered.
- 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
autocompletevalue 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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
[-]Emailed code field invites password managers to fill a TOTP code[/-][+]Email and recovery code fields invite password managers to fill a TOTP code[/+]dknauss commentedon Nov 29, 2026
👋 Please add the TOTP, Emailed Codes, and Backup Codes labels since I can't set them. Thanks!