Fix bcrypt password verification and enforce bcrypt for all new password storage#439
Open
Copilot wants to merge 3 commits into
Open
Fix bcrypt password verification and enforce bcrypt for all new password storage#439Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…ll new passwords Agent-Logs-Url: https://github.com/Alanaktion/phproject/sessions/3f1b38d8-6ce2-4863-beaa-8ad14ae1e6f7 Co-authored-by: Alanaktion <236490+Alanaktion@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix bcrypt login issue with legacy salt verification
Fix bcrypt password verification and enforce bcrypt for all new password storage
May 13, 2026
|
looks good |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates password verification and storage paths so bcrypt hashes are verified even when legacy salt metadata is inconsistent, and several password update flows now generate bcrypt hashes directly.
Changes:
- Added bcrypt hash prefix detection in
Helper\Security::verifyPassword(). - Updated account, admin, password reset, and forced-reset password write paths to use bcrypt hash output.
- Added a regression test for bcrypt verification when the stored salt is legacy-looking.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
app/helper/security.php |
Detects bcrypt hashes by prefix during password verification. |
app/controller/user.php |
Stores bcrypt output for user-initiated password changes. |
app/controller/index.php |
Stores bcrypt output for reset and forced-reset flows. |
app/controller/admin.php |
Stores bcrypt output for admin-set temporary/permanent passwords. |
tests/stringTest.php |
Adds regression coverage for mismatched bcrypt hash and salt metadata. |
Comments suppressed due to low confidence (1)
app/controller/index.php:300
- Mandatory: this forced-reset path also writes the full bcrypt hash into
user.password, which is still declared aschar(40)in the database schemas. The stored hash can be truncated or rejected, leaving users unable to complete the forced reset/login flow until the schema is updated.
$hashResult = $security->hash($f3->get("POST.password1"));
$user->salt = $hashResult["salt"];
$user->password = $hashResult["hash"];
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/Alanaktion/phproject/sessions/cb79f960-fc93-46d9-944d-b66e0944bc0e Co-authored-by: Alanaktion <236490+Alanaktion@users.noreply.github.com>
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.
verifyPassword()routed topassword_verify()only when$salt === "bcrypt", but several write paths stored bcrypt hashes while leavingsaltas an MD5 string — causing login to silently fall through to SHA1 comparison and always fail.Changes
app/helper/security.phpisBcryptHash()to detect bcrypt hashes by prefix ($2y$,$2b$,$2a$)verifyPassword()now uses bcrypt path when the hash is bcrypt, regardless of salt valueapp/controller/user.php,app/controller/admin.php,app/controller/index.phphash($password, $salt)with a non-null salt, hitting the SHA1 path instead of bcrypthash($password)(no salt) and unpack the returned["salt" => "bcrypt", "hash" => "..."]arraysalt = nullto preserve forced-reset-on-login behaviour; the bcrypt hash is still correctly verified via prefix detectioninstall.phphash()without a salt so new installs store a bcrypt hash from the starttests/stringTest.phptestVerifyBcryptPasswordWithMismatchedSalt()covering the exact failure case: bcrypt hash stored alongside an MD5 salt