David Johnson created ROL-2187:
----------------------------------
Summary: Lazy password upgrade never runs: SHA-1/MD5 hashes are
never re-encoded as bcrypt
Key: ROL-2187
URL: https://issues.apache.org/jira/browse/ROL-2187
Project: Apache Roller
Issue Type: Bug
Reporter: David Johnson
Fix For: 7.0.0
{{passwds.encryption.lazyUpgradeFrom}} (default {{SHA}}) lets passwords from
older Roller versions verify, but Roller never re-encodes them. Users keep
their unsalted SHA-1 or MD5 hash permanently, so sites that upgrade from
5.x/6.x stay exposed to fast offline cracking if their database leaks.
{{RollerContext.createPasswordEncoder()}} registers the legacy digest encoder
under the {{null}} id, so {{DelegatingPasswordEncoder}} verifies unprefixed
hashes and {{upgradeEncoding()}} returns true for them.
{{DaoAuthenticationProvider}} saves an upgraded hash only when a
{{UserDetailsPasswordService}} is set. {{RollerContext}} (around line 284)
configures the provider's encoder but never sets that service, so the upgrade
is skipped.
Seen on rollerweblogger.org running master at {{4ee8ce35a}}: SHA-1 logins work,
but the stored hash stays SHA-1. 17 enabled accounts there still have
40-character SHA-1 hashes.
*Proposed fix*
* Implement {{UserDetailsPasswordService}} over {{UserManager}}.
{{updatePassword(user, newEncodedPassword)}} stores the already-encoded value
and does not encode it again.
* Register it with {{provider.setUserDetailsPasswordService(...)}} next to the
existing {{setPasswordEncoder}} call.
* Test: after a successful login with an unprefixed SHA-1 hash, the stored
value starts with {{\{bcrypt\}}}, and a second login still works.
No schema change or migration is needed. A rehashing migration is not possible
without plaintext passwords, and wrapping the old hashes (bcrypt over SHA-1)
would break downgrades.
*Release note:* lazy upgrade covers only users who log in. Admins should find
accounts whose password hash has no {{\{id\}}} prefix and either disable them
or force a password reset.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)