Skip to content

Keep a password changed during a login when upgrading its encoding - #302

Merged
mraible merged 1 commit into
masterfrom
recheck-stored-password
Nov 17, 2026
Merged

mraible merged 1 commit into
masterfrom
recheck-stored-password

Conversation

@mraible

@mraible mraible commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

A follow-up to #301, from a review of #300.

When a login re-encodes a password stored with an older encoding, RollerUserDetailsService.updatePassword now releases the persistence session, reads the user again and stores the re-encoded password only if the stored password is still the one the login checked. If an administrator changed it in the meantime, that change is kept.

PersistenceSessionFilter now comes first in web.xml, so it releases the persistence session for every request, including the ones Spring Security answers itself, such as login posts. The filter doesn't read the request, so it can come ahead of CharEncodingFilter.

  • PasswordUpgradeTest has a case where the password is reset after the login read the user; it fails without the change.
  • FilterOrderTest checks that PersistenceSessionFilter is the first filter mapping.
  • mvn test passes (749 tests), and the Playwright database-login suite passes against jetty:run (20 run, 3 OIDC tests skipped).
  • On a copy of a production site (Tomcat 11 behind httpd, argon2 with lazyUpgradeFrom=SHA), master with and without this change behaved the same for logins, private-weblog access, comment preview and post, draft and published entry saves, profile saves, and a 1,741-address header sample, with no new errors in the log.
  • On the same stack, a login with the old password and an administrator's password reset were fired 0–200 ms apart, in both orders, for accounts with an unsalted SHA-1 hash. Without this change the re-encoded old password overwrote the reset twice in 12 tries (at 0 and 10 ms); with it, the reset was kept all 12 times. 24 concurrent logins of one account stored the re-encoded password 8 times before the change and once after.

No CHANGES entry: the password upgrade from #301 hasn't been released yet.

When a login re-encodes a password stored with an older encoding, the user is now read again first, and the re-encoded password is stored only if the stored password is still the one the login checked. A password changed in the meantime, for example by an administrator, is kept.

PersistenceSessionFilter now comes first in web.xml, so it releases the persistence session for every request, including the ones Spring Security answers itself, such as logins.
@mraible
mraible force-pushed the recheck-stored-password branch from e8e171e to 3ba1e7c Compare November 17, 2026 05:15

@snoopdave snoopdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mraible
mraible merged commit 7141a41 into master Nov 17, 2026
9 checks passed
@mraible
mraible deleted the recheck-stored-password branch November 17, 2026 15:40
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