Files
artcraft-services/crates/lib
Dylan M. Taylor a3f7204180 fix: reject passwords longer than bcrypt's 72-byte input (#302)
## What was wrong

bcrypt only uses the first 72 bytes of a password. Account creation,
password change and password reset accepted longer passwords and hashed
them, so everything after byte 72 was silently ignored. A user who
changed only the tail of a long password hadn't really changed it, and a
long passphrase was weaker than it looked.

## What changed

- `password` crate: new `BCRYPT_MAX_PASSWORD_BYTES = 72`.
`bcrypt_hash_password` returns a new
`PasswordHashError::PasswordTooLong` instead of truncating (with a unit
test at 72 and 73 bytes).
- `validate_passwords` (account creation, password change) rejects
longer passwords with a clear 400 message.
- Password reset redemption rejects them with a new `PasswordTooLong`
400 error.

Login (`bcrypt_confirm_password`) is unchanged, so existing accounts
with longer passwords can still sign in; they just can't set a new one
over 72 bytes.

## Checks

- Run: `cargo test -p password` (6 passed); `SQLX_OFFLINE=true cargo
check -p storyteller-web` (exit 0).
- Not run: endpoint tests (need a live MySQL).
2026-11-11 11:21:29 -05:00
..
2026-04-07 00:43:21 -04:00
wip
2026-09-14 15:40:33 -04:00
2025-10-31 04:19:41 -04:00
2026-02-21 05:49:47 +07:00
2026-09-12 12:23:46 -04:00
2026-03-18 20:32:50 -04:00
2026-07-03 02:28:22 -04:00
2026-04-14 01:00:01 -04:00
2025-04-09 20:39:36 -04:00
2026-06-19 23:35:22 -04:00
2025-05-24 23:31:25 -04:00
2026-03-18 20:32:50 -04:00