Skip to content

Conversation

@monkeyiq
Copy link
Contributor

Given that this touches the admin login route directly, some more eyes to review are appreciated.

The code uses the result of password_get_info and if the algo is null then we know the auth.adminpassword from config.php is not set to a hashed password. At that stage the new lines do a direct string compare in the same way that pwValid does in 2.2 and used to in 2.3. More explicitly:

return $hash === $password;

This is the intent of the code. Admins can again put plaintext passwords in config.php for auth.adminpassword if desired. Hashing is recommended but not required any more and functionality returns to that of v2.2.

We can see a null for the password for example in the following test

php > var_dump(password_get_info("123"));
array(3) {
  ["algo"]=>
  NULL
  ["algoName"]=>
  string(7) "unknown"
  ["options"]=>
  array(0) {
  }
}

This was requested here #2216 (comment)

More information about the changes around the admin password hashing and how we got where we are in 2.3 is at #2212 (comment)

Copy link
Member

@tvdijen tvdijen left a comment

Choose a reason for hiding this comment

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

This looks good @monkeyiq !
I would like to add a deprecation warning to the logs when the password is plain-text, and the upgrade notes need a touch up.

@thijskh
Copy link
Member

thijskh commented Aug 28, 2024

Would it be better to use hash_equals() instead of ===?

@monkeyiq
Copy link
Contributor Author

I was thinking about using something like hash_equals. The first PR is using the same thing that 2.2 uses to do the comparison. I think if we want to improve that then we probably want to move to hash_equals in 2.2, 2.3+ as a logical unit.

@monkeyiq
Copy link
Contributor Author

The deprecation warning is a great idea. It is much better to continue to work and offer a suggestion to improve security and at some stage remove the old acceptance of plain password from config.php.

@monkeyiq
Copy link
Contributor Author

I think I'll make the deprecation warning and upgrade notes PR separate linking back to this.

@monkeyiq monkeyiq merged commit 5930652 into simplesamlphp:simplesamlphp-2.3 Aug 28, 2024
@codecov
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.92%. Comparing base (b46c8da) to head (fbb290e).
Report is 1 commits behind head on simplesamlphp-2.3.

Additional details and impacted files
@@                   Coverage Diff                   @@
##             simplesamlphp-2.3    #2222      +/-   ##
=======================================================
- Coverage                44.92%   44.92%   -0.01%     
- Complexity                3892     3893       +1     
=======================================================
  Files                      162      162              
  Lines                    12972    12974       +2     
=======================================================
  Hits                      5828     5828              
- Misses                    7144     7146       +2     

@monkeyiq
Copy link
Contributor Author

I was about the cherry pick this forward to master but I am not sure we want it that far out?

@monkeyiq
Copy link
Contributor Author

I picked it into 2.4

@tvdijen
Copy link
Member

tvdijen commented Aug 28, 2024

No, master is where we break stuff and force hashed passwords!

@monkeyiq
Copy link
Contributor Author

sounds good!

@monkeyiq
Copy link
Contributor Author

ok, I'll take a look at another PR for deprecation warning and release notes update.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants