Skip to content

Harden email factor revoke and sign-in links - #493

Merged
Peterburnett merged 1 commit into
TOTARA_19from
t19-harden-email-revoke
Dec 1, 2026
Merged

Peterburnett merged 1 commit into
TOTARA_19from
t19-harden-email-revoke

Conversation

@jaypha

@jaypha jaypha commented Dec 1, 2026

Copy link
Copy Markdown

Previously the "this wasn't me" revoke link only needed the tool_mfa instance ID. IDs are sequential, so anyone could revoke a user's email factor and end all of their sessions without authenticating.

Revoke link (factor/email/email.php, renderer.php):

  • Include the emailed code in the revoke link and require it (secret is now a required param).
  • Limit guesses on the unauthenticated revoke form.
  • Reject expired codes before an attempt is counted.
  • Check the user exists and isn't deleted before revoking.
  • Suspend accounts with user_suspend_user() instead of a raw set_field, so user_updated/user_suspended events fire

Email-link sign-in (pass=1):

  • Only accept pending, unrevoked email codes.
  • Reject expired codes.
  • Load the lock state from the DB before checking for the locked state, so a fresh session can't get around the lockout.

Both:

  • Compare codes with hash_equals() on strings (constant time, no type juggling).

Other:

  • Add a test that the revoke link in the email includes the code.
  • Version bumps.

Previously the "this wasn't me" revoke link only needed the
tool_mfa instance ID. IDs are sequential, so anyone could revoke a
user's email factor and end all of their sessions without
authenticating.

Revoke link (factor/email/email.php, renderer.php):
- Include the emailed code in the revoke link and require it
  (secret is now a required param).
- Limit guesses on the unauthenticated revoke form.
- Reject expired codes before an attempt is counted.
- Check the user exists and isn't deleted before revoking.
- Suspend accounts with user_suspend_user() instead of a raw
  set_field, so user_updated/user_suspended events fire

Email-link sign-in (pass=1):
- Only accept pending, unrevoked email codes.
- Reject expired codes.
- Load the lock state from the DB before checking for the locked
  state, so a fresh session can't get around the lockout.

Both:
- Compare codes with hash_equals() on strings (constant time, no
  type juggling).

Other:
- Add a test that the revoke link in the email includes the code.
- Version bumps.
@Peterburnett
Peterburnett merged commit 76e3f28 into TOTARA_19 Dec 1, 2026
@Peterburnett
Peterburnett deleted the t19-harden-email-revoke branch December 1, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants