Skip to content

Multiple Argon2-related bugfixes and cleanups (libargon2, openssl) - #25353

Open
narfbg wants to merge 1 commit into
php:PHP-8.4from
narfbg:password_argon2_valid
Open

narfbg wants to merge 1 commit into
php:PHP-8.4from
narfbg:password_argon2_valid

Conversation

@narfbg

@narfbg narfbg commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Similar to GH-24302 but for Argon2.

ext/password:

  • password_hash(), password_needs_rehash() no longer accept invalid $options['threads'] (above 255)
  • password_verify() no longer calls libargon2 on malformed hashes
  • password_get_info() no longer parses malformed hashes
  • Cleanups all around, including fewer heap allocations, but didn't touch the salt handling because that's pending in Make password salt generation algo-agnostic and isolate bcrypt-specific logic #24281. A couple more nitpicky things can be improved as well, but didn't want to balloon the patch even more upfront.

ext/openssl:

  • [openssl_]password_hash(), [openssl_]password_needs_rehash() no longer accept invalid $options['threads'] values (above 255)
  • [openssl_]password_verify() no longer triggers computations and/or throws exceptions on hashes with invalid parameters
  • [openssl_]password_verify() no longer accepts obviously invalid hashes such as with invalid versions or empty salt
  • [openssl_]password_hash(), [openssl_]password_needs_rehash() no longer throw exceptions for invalid options, to match ext/password
  • [openssl_]password_hash(), [openssl_]password_verify() no longer confuse the threads option with OpenSSL's internal threads (this might be why --with-openssl-argon2 --enable-zts builds are currently forbidden, but haven't tested)

Also (for both) password_needs_rehash() will return true if it sees an older version hash, not just changed parameters. And tests, lots of tests. 🙂

Most of the work I did in ext/password, and tried to keep ext/openssl changes minimal (sscanf() usage still broken), but I do intend to fully fix it up once some decisions are made - whether the same parser approach is ok, exactly which conditions should warrant a rehash, etc.
libsodium provider is mostly fine - nothing really broken; only a bit rough around the edges with error messages and obscure but valid Argon2 v.1.0 hashes. Will polish it later probably alongside OpenSSL's remaining issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant