Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Security] Replace Argon2*PasswordEncoder by SodiumPasswordEncoder#31019
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
3581d68 to2d73bcaComparesrc/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
a8a6f27 to686fe0eCompare| if (\function_exists('sodium_crypto_pwhash_str_verify')) { | ||
| $valid =\sodium_crypto_pwhash_str_verify($encoded,$raw); | ||
| \sodium_memzero($raw); |
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.
copy-on-write makes this useless to me - it should be done on the original value, outside of the method
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.
indeed, all removed
This reverts commitdc95a6f.
fabpot commentedApr 9, 2019
Thank you@chalasr. |
…swordEncoder (chalasr)This PR was merged into the 4.3-dev branch.Discussion----------[Security] Replace Argon2*PasswordEncoder by SodiumPasswordEncoder| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets |#31016| License | MIT| Doc PR | todosymfony/symfony-docs#11368See fixed ticket, much simpler/secure/maintainable.Commits-------529211d [Security] Replace Argon2*PasswordEncoder by SodiumPasswordEncoder
teohhanhui commentedApr 9, 2019
I think this is really bad. The user should have control over which algorithm is used. |
teohhanhui commentedApr 9, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Implementation wise, it's possible to usesodium_crypto_pwhash instead, as I've discussed with@chalasr extensively about this. |
chalasr commentedApr 9, 2019
@teohhanhui Allowing to specify the algorithm involves to rely on implementation details and to make strong assumptions that may be wrong at some point or don’t fit for all platforms. The result felt a bit hackish tbh.
Our role as a framework is to always provide the most secure alternative, that is what |
teohhanhui commentedApr 10, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
My plea to the Symfony team: please hold your horses on the deprecation of using specific password hashing algorithms. This deserves more input / feedback from the community, as it entails taking away control from the application developer.
Of course, it's good to have I will try working on implementations that use |
nicolas-grekas commentedApr 10, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Honestly, I think we should adopt the recommended practice and stop allowing ppl to choose the algo. Sticking to one algowill be broken in the future, because that's the life of hash algos. I'm all for deprecating the existing encoders that are bound to one algo. |
teohhanhui commentedApr 11, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If we're taking that route, then it should be done similar to this? So that passwords using old algorithms could be transparently re-hashed (upon password validation and detecting that a rehash is needed). It'll be invaluable for so many projects. (But IMO, actually the developer should still be able to configure which algorithms should be used.) https://docs.spring.io/spring-security/site/docs/5.1.5.RELEASE/reference/html5/#pe-dpe I see there's#30914 |
| * Added`Argon2idPasswordEncoder` | ||
| * Deprecated using`Argon2iPasswordEncoder` while only the`argon2id` algorithm | ||
| is supported, use`Argon2idPasswordEncoder` instead | ||
| * deprecated`Argon2iPasswordEncoder`, use`SodiumPasswordEncoder` instead |
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.
should we actually deprecate it ? It can use the native API of PHP 7.2+ (and Argon2idPasswordEncoder could as well, giving control over the variant). SodiumPasswordEncoder is only based on the sodium extension.
IMO, we should only deprecated the sodium-based fallback in the Argon encoders, not deprecate the encoders themselves.
nicolas-grekasApr 17, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Having encoders bound to one algo is a bad practice. The documented best practice is to have a progressive encoder that knows how to verify old passwords while using the best available algo to encode new ones. So yes: this should be deprecated with this reasoning.
Of course, there is one missing step: rehashing. See#31139
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 documented best practice is to have a progressive encoder that knows how to verify old passwords while using the best available algo to encode new ones.
The chain / delegating encoder should be composed of encoders using specific algorithms. At least, that's the case in Spring Security (see links above).
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 chain / delegating encoder should be composed of encoders using specific algorithms
PHP is a glue language while Java implements everything itself. The situation in PHP is thatpassword_hash()/Sodium\crypto_pwhash_str already embed the chain and there is zero need to expose the individual algos as encoders.
I agree a chain encoder would be nice to provide a migration path from Pbkdf2/MessageDigest/Plaintext to Native/Sodium thought. But we need#31139 first.
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 situation in PHP is that password_hash()/Sodium\crypto_pwhash_str already embed the chain and there is zero need to expose the individual algos as encoders.
Having a default (like withpassword_hash) / fallback (like withsodium_crypto_pwhash_str) mechanism does not create a "chain" (to be understood as for the purpose of rehashing). Anyway, I don't understand that argument of PHP vs Java, when it's been pointed out that it's indeed possible to provide encoders for specific algorithms (with extra effort in the case ofsodium_crypto_pwhash).
cur53se commentedMay 10, 2019
Hi, I think this might cause a problem when I hash passwords on the machine with different Argon implementation and validate them on another one. I run app in php 7.2 on Debian but sometimes I need to run CLI command which add user from the machine which runs on 7.3 on MacOS with the different sodium library. Means that I $passwordEncoder->isPasswordValid(...) will not validate the password when I generated on different machine? |
nicolas-grekas commentedMay 10, 2019
I agree this might be a problem. Yet the outcome is ok: you won't be able to log in. I can't imagine how we could do better while still providing state of the art security practices (always using the best possible hash algo) |
teohhanhui commentedMay 11, 2019
But it's at least forward-compatible, right? |
Uh oh!
There was an error while loading.Please reload this page.
See fixed ticket, much simpler/secure/maintainable.