Skip to content

ext/standard: Validate bcrypt costs - #334

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-cuj9
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-cuj9

Conversation

@iliaal

@iliaal iliaal commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Reject malformed and out-of-range bcrypt cost fields before password verification uses them. The regression tests cover invalid costs and supported valid values.

@iliaal
iliaal force-pushed the fix/aph-cuj9 branch 2 times, most recently from 3f2a42a to 6b3b1dd Compare September 24, 2026 12:59
@iliaal
iliaal changed the base branch from master to PHP-8.4 September 24, 2026 12:59
password_get_info() and password_needs_rehash() identified any 60-byte
"$2y" hash as bcrypt and read its cost with sscanf(), so they reported
costs that crypt() rejects, such as 03 or 32, and overflowed zend_long on a
run of 56 digits. Require exactly two digits in the 04-31 range followed by
'$'. password_verify() is unaffected, as unidentified hashes still go
through crypt().
@iliaal

iliaal commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#24203.

@iliaal iliaal closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant