Skip to content

[1.x] fix: enforce expiry check on password reset token submission - #4545

Merged
imorland merged 1 commit into
1.xfrom
im/security-password-reset-token-expiry
Apr 11, 2026
Merged

[1.x] fix: enforce expiry check on password reset token submission#4545
imorland merged 1 commit into
1.xfrom
im/security-password-reset-token-expiry

Conversation

@imorland

@imorland imorland commented Apr 11, 2026

Copy link
Copy Markdown
Member

Summary

  • POST /reset accepted any token present in the database without checking expiry, while GET /reset/{token} correctly enforced the 24-hour window
  • An attacker with a stale token (e.g. from a leaked email or DB backup) could use it indefinitely to take over the account
  • Adds a validOrFail scope to PasswordToken matching the existing pattern on EmailToken, and updates SavePasswordController to use it

Test plan

  • PasswordTokenExpiryTest::expired_password_token_is_rejected_by_post_reset — fails before fix, passes after
  • PasswordTokenExpiryTest::valid_password_token_is_accepted_by_post_reset — passes throughout
  • Existing PasswordEmailTokensTest suite — no regressions

@imorland imorland changed the title fix: enforce expiry check on password reset token submission [1.x] fix: enforce expiry check on password reset token submission Apr 11, 2026
@imorland
imorland force-pushed the im/security-password-reset-token-expiry branch from 33fbffc to f913c60 Compare April 11, 2026 11:31
POST /reset accepted any token present in the database without checking
whether it had expired, while GET /reset/{token} correctly enforced the
24-hour window. An attacker with access to a stale token (e.g. from a
leaked email or DB backup) could use it indefinitely.

Adds a `validOrFail` scope to `PasswordToken` matching the existing
pattern on `EmailToken`, and updates `SavePasswordController` to use it.
@imorland
imorland force-pushed the im/security-password-reset-token-expiry branch from f913c60 to 23b80df Compare April 11, 2026 11:37
@imorland imorland added this to the 1.8.16 milestone Apr 11, 2026
@imorland
imorland marked this pull request as ready for review April 11, 2026 12:39
@imorland
imorland requested a review from a team as a code owner April 11, 2026 12:39
@imorland
imorland merged commit 2803058 into 1.x Apr 11, 2026
409 checks passed
@imorland
imorland deleted the im/security-password-reset-token-expiry branch April 11, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant