Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[Security] Do not mix password_*() API with libsodium one #29863
+3
−1
Conversation
chalasr
added
Security
Bug
labels
Jan 12, 2019
chalasr
added this to the 3.4 milestone
Jan 12, 2019
carsonbot
added
Status: Needs Review
Status: Reviewed
and removed
Status: Needs Review
labels
Jan 12, 2019
javiereguiluz
approved these changes
Jan 14, 2019
Thanks for the insightful explanation and the fix! |
chalasr
merged commit d6cfde9
into
symfony:3.4
Jan 18, 2019
added a commit
that referenced
this pull request
Jan 18, 2019
chalasr
deleted the
chalasr:fix-argon2i-verif
branch
Jan 19, 2019
Jan 29, 2019
This was referenced
Merged
Merged
Merged
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.
chalasr commentedJan 12, 2019
Argon2IPasswordEncoder uses native
password_hash()
andpassword_verify()
functions if the current PHP installation embeds Argon2 support (>=7.2, compiled--with-password-argon2
).Otherwise, it fallbacks to the libsodium extension.
This was fine at time the encoder was introduced, but meanwhile libsodium changed the algorithm used by
sodium_crypto_pwhash_str()
which is now argon2id, that goes outside of the scope of the encoder which was designed to deal withargon2i
only.Nothing we can do as databases may already contain passwords hashed with argon2id, the encoder must keep validating those.
However, the PHP installation may change as time goes by, and could suddenly embed the Argon2 core integration. In this case, the encoder would use the
password_verify()
function which would fail in case the password was not hashed using argon2i.This PR prevents it by detecting that argon2id was used, avoiding usage of
password_verify()
.See jedisct1/libsodium-php#194 and #28093 for references.
Patch cannot be tested as it is platform dependent.
Side note: I'm currently working on a new implementation for 4.3 that will properly supports argon2id (which has been added to the PHP core sodium integration in 7.3) and argon2i, distinctively.