Repository navigation
fix: run a dummy bcrypt check before rejecting unhashable values in BcryptHasher::verify - #521
Merged
Merged
Conversation
…cryptHasher::verify BcryptHasher::verify() returned false immediately for values over 72 bytes or containing a NUL byte, doing no hashing work. Code calling HashManager directly could tell "rejected for length" from "wrong password" by timing. verify() now checks such a value against a precomputed dummy hash at the configured cost before returning false, mirroring BcryptPasswordHasher in marko/authentication. HashManager::verify() delegates to the active hasher, so it inherits the fix; Argon2Hasher refuses no input and needs no change. Fixes #517 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KyjR4cJTfro54iFZ9CWkv1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BcryptHasher::verify()returnedfalsestraight away for values over 72 bytes or containing a NUL byte, with no hashing work. Code that callsHashManagerdirectly could tell "rejected for length" from "wrong password" by timing.BcryptHashernow builds a dummy hash at the configured cost in its constructor and runspassword_verify()against it (protectedverifyDummy()) before returningfalse. This mirrorsBcryptPasswordHasherinmarko/authentication(fix!: reject bcrypt passwords over 72 bytes or containing nul #467/fix!: rehash passwords on login and back authentication with marko/hashing #508) and reuses the same dummy salt and digest.HashManager::verify()passes the call to the active hasher, so it gets the fix with no change of its own.Argon2Hasheraccepts every input, so it has no rejection path.Test plan
falseand run the dummy verification exactly once (a subclass recordsverifyDummy()calls). Valid inputs never run it.$2y$hash at the configured or default cost, andcrypt()accepts it. A malformed hash would makepassword_verify()return instantly.HashManager::verify()with the bcrypt driver, both refused inputs run the dummy check.composer cigreen locallyFixes #517
🤖 Generated with Claude Code
https://claude.ai/code/session_01KyjR4cJTfro54iFZ9CWkv1