You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR hardens the plugin’s two-factor authentication flow by binding code verification to a successful password check and adding replay protection and per-user attempt limits.
Changes:
Adds password-step tokens, replay checks, lockout handling, and related login messages.
Strengthens secret and email-code generation and restricts access to activated application secrets.
Adds regression tests for authentication, setup, and rate limiting.
Truncating UA by bytes could split a multibyte character; wpdb rejects
queries with invalid text and the limiter fails open, so the per-user
2FA attempts cap could be bypassed. Keep only printable ASCII.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Concurrent requests with the same step token could overwrite each
other's fail counter and both pass the TOTP replay check. Now each
attempt is reserved by compare-and-swap of the token record before the
code check, and a correct code logs in only if this request deletes
the reserved record. The TOTP time step is marked used after the claim.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid deleting a concurrent login's fresh step token
inc/spbc-auth.php:1416
Both successful authentication branches have already deleted the matching step record with spbc_2fa__step_token_claim(). Calling spbc_2fa__step_token_destroy() here deletes whatever record currently exists for the user, including a fresh token issued by a concurrent password login after that claim. This invalidates the other browser's new challenge. Clear only this browser's step cookie here instead of deleting user meta again.
A step token and e-mail code issued for the old password could still
complete the login after the password reset. Revoke both on
after_password_reset.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The step record is already consumed by the atomic claim, so deleting
user meta again on success could revoke a fresh challenge issued to a
password login in another browser. Clear only this browser's cookie.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix. 2FA. Flow updates.
* Fix. 2FA. Keep user rate limiter UA charset-safe.
Truncating UA by bytes could split a multibyte character; wpdb rejects
queries with invalid text and the limiter fails open, so the per-user
2FA attempts cap could be bypassed. Keep only printable ASCII.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix. 2FA. Atomic step token attempts and claim.
Concurrent requests with the same step token could overwrite each
other's fail counter and both pass the TOTP replay check. Now each
attempt is reserved by compare-and-swap of the token record before the
code check, and a correct code logs in only if this request deletes
the reserved record. The TOTP time step is marked used after the claim.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix. 2FA. Revoke pending challenge on password reset.
A step token and e-mail code issued for the old password could still
complete the login after the password reset. Revoke both on
after_password_reset.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix. 2FA. Keep concurrent login's fresh step token on success.
The step record is already consumed by the atomic claim, so deleting
user meta again on success could revoke a fresh challenge issued to a
password login in another browser. Clear only this browser's cookie.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://app.doboard.com/1/task/60469