-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Support hashing the hashed password using crc32c when putting the user in the session #59562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e45fa9e
to
b8f77ae
Compare
src/Symfony/Component/Security/Core/Tests/Authentication/Token/Fixtures/CustomUser.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/Firewall/ContextListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/Firewall/ContextListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
Outdated
Show resolved
Hide resolved
46faf11
to
d1ee5c4
Compare
d1ee5c4
to
53a1aab
Compare
53a1aab
to
2dcb3d9
Compare
PR ready /cc @symfony/mergers |
9cab9e1
to
7f7247b
Compare
(PR rebased) |
7f7247b
to
05f606b
Compare
8243e9a
to
f6742c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a question in tests.
src/Symfony/Component/Security/Http/Firewall/ContextListener.php
Outdated
Show resolved
Hide resolved
@@ -303,7 +307,7 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa | |||
return true; | |||
} | |||
|
|||
if ($originalUser instanceof LegacyPasswordAuthenticatedUserInterface && $refreshedUser instanceof LegacyPasswordAuthenticatedUserInterface && $originalUser->getSalt() !== $refreshedUser->getSalt()) { | |||
if ($originalUser instanceof LegacyPasswordAuthenticatedUserInterface && $originalUser->getSalt() !== $refreshedUser->getSalt()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The psalm false-positive is reported vimeo/psalm#9956
…ing the user in the session
f6742c6
to
a4f8a76
Compare
Thank you @nicolas-grekas. |
This PR builds on #59539 following the discussion that happened there.
Here is what I added to PasswordAuthenticatedUserInterface to explain what this PR enables:
crc32c is selected because its probability to change when the password hash changes is high, so that the invalidation of sessions is effective. But it's also selected because there are many possible valid password hashes that generate the same crc32c. This protects against brute-forcing the password hash: let's say one is able to find a password hash that has the same crc32c as the real password hash: one would still be unable to confirm that this password hash is the correct one. To do so, they would have to brute-force the password hash itself, and this would require brute-forcing bcrypt et al. The cost of doing so on one bcrypted-password is already prohibitive. Doing so with a very high number of possible candidates (as collisions are generated) would be even more prohibitive.
Note that to generate a collision, one just needs to generate a random string that's formatted as a real hash, like this line for a bcrypted-password:
(one could likely create a crc32c-aware collision generator for this purpose, but that wouldn't reduce the difficulty of validating the generated hashes).
On the contrary, using a more collision resistant hashing algorithm would make it too easy to validate that a generated hash is the real hash.