{"vuln_id":"CVE-2023-0567","aliases":["GHSA-7fj2-8x79-rjf4"],"description":"In PHP 8.0.X before 8.0.28, 8.1.X before 8.1.16 and 8.2.X before 8.2.3, password_verify() function may accept some invalid Blowfish hashes as valid. If such invalid hash ever ends up in the password database, it may lead to an application allowing any password for this entry as valid.","published_at":"2023-02-15T20:37:12Z","modified_at":"2026-10-26T18:01:14.008003Z","first_seen_at":"2026-11-21T19:15:06.076922Z","severity":"medium","severity_source":"cvss","cvss_score":6.2,"cvss_vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","cwe":[],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00925,"epss_percentile":0.61176,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2023-0567"},"matched_alias":null,"items":[{"id":507,"source":{"id":"debian-php","name":"Debian 12 php8.2 (package vulnerabilities)"},"title":"php8.2 (Debian:12): DEBIAN-CVE-2023-0567 / CVE-2023-0567 - In PHP 8.0.X before 8.0.28, 8.1.X before 8.1.16 and 8.2.X before 8.2.3, password_verify() function may accept some invalid Blowfish hashes as valid. If such in…","summary":"In PHP 8.0.X before 8.0.28, 8.1.X before 8.1.16 and 8.2.X before 8.2.3, password_verify() function may accept some invalid Blowfish hashes as valid. If such invalid hash ever ends up in the password database, it may lead to an application allowing any password for this entry as valid.\n\nAffected: Debian:12:php8.2\n\nFixed in: 8.2.4-1\n\nReferences:\nhttps://security-tracker.debian.org/tracker/CVE-2023-0567","url":"https://osv.dev/vulnerability/DEBIAN-CVE-2023-0567","published_at":"2023-03-01T08:15:11.530000Z","updated_at":"2026-10-26T18:01:14.008003Z","fetched_at":"2026-11-21T19:15:05.963764Z","severity":"medium","cvss_score":6.2,"epss":0.00925,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php8.2","vuln_id":"CVE-2023-0567","vuln_ids":["CVE-2023-0567","DEBIAN-CVE-2023-0567","GHSA-7FJ2-8X79-RJF4"],"tags":["package-watch","pkg:php8.2","fix-available"],"cluster_id":391,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/507","html":"https://vulnwatch.ve1ve2.com/item/507"}},{"id":12682,"source":{"id":"gh-php-src","name":"PHP releases (GitHub php/php-src tags)"},"title":"GHSA-7fj2-8x79-rjf4 / CVE-2023-0567: BCrypt hashes erroneously validate if the salt is cut short by `$`","summary":"BCrypt hashes erroneously validate if the salt is cut short by `$` ### Summary Malformatted BCrypt hashes that include a `$` within their salt part will trigger a buffer overread and may erroneously validate any password as valid. ### Details Example: ```php ``` This issue is caused by a PHP specific modification to the crypt_blowfish implementation that is fittingly named “PHP hack”: https://github.com/php/php-src/blob/2740920a392c043b034e2f0e41d819549836712a/ext/standard/crypt_blowfish.c#L374 The “hack” will allow a salt that is cut short by `$` to be detected as valid and allowing it to proceed with the algorithm. At the end the original `setting`, which is properly NUL terminated, will be copied into the output buffer: https://github.com/php/php-src/blob/2740920a392c043b034e2f0e41d819549836712a/ext/standard/crypt_blowfish.c#L763 which is then used to initialize the returned `zend_string` by leveraging `strlen()` and thus cutting the string short after the `setting`: https://github.com/php/php-src/blob/2740920a392c043b034e2f0e41d819549836712a/ext/standard/crypt.c#L137 … thus returning the original input. Furthermore a buffer overread of the `setting` input may be triggered when copying the `setting` into the output buffer, because the `memcpy` uses fixed sizes, even if the `setting` might be too short: https://github.com/php/php-src/blob/2740920a392c043b034e2f0e41d819549836712a/ext/standard/crypt_blowfish.c#L763 ### Suggested Fix The suggested fix would be removing the “PHP Hack” and thus the differences between PHP's crypt_blowfish and Openwall’s implementation which is the basis of PHP’s implementation. The “PHP Hack” exists since the very first version of PHP’s own crypt_blowfish implementation and no clear reasoning is given for its existence in the commentary or commit history. In any case such a hash is not a valid BCrypt hash and it is not generated by `password_hash()`, which is the recommended password hashing API in PHP. While this technically might break backwards compatibility with existing users, the fact that these hashes are never generated by `password_hash()`, are not accepted by other implementations of BCrypt and introduce possible security vulnerabilities in applications, they should be rejected in every supported PHP version. ### PoC Running the following in valgrind: ```php ``` results in: ``` ==423829== Memcheck, a memory error detector ==423829== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==423829== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==423829== Command: sapi/cli/php test3.php ==423829== ==423829== Invalid read of size 2 ==423829== at 0x4840240: memcpy@GLIBC_2.2.5 (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==423829== by 0x591BE9: BF_crypt (crypt_blowfish.c:763) ==4 Patched: 8.0.28, 8.1.16, 8.2.3","url":"https://github.com/php/php-src/security/advisories/GHSA-7fj2-8x79-rjf4","published_at":"2023-02-15T20:37:12Z","updated_at":"2023-02-15T20:37:12Z","fetched_at":"2026-11-22T14:05:37.431205Z","severity":"medium","cvss_score":6.2,"epss":0.00925,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php-src","vuln_id":"CVE-2023-0567","vuln_ids":["CVE-2023-0567","GHSA-7FJ2-8X79-RJF4"],"tags":["repo-advisory","security","repo:php/php-src","stack"],"cluster_id":11795,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/12682","html":"https://vulnwatch.ve1ve2.com/item/12682"}}]}