{"vuln_id":"CVE-2023-3824","aliases":["CVE-2023-3823","CVE-2024-2756","CVE-2024-3096","GHSA-jqcx-ccgc-xwhv"],"description":"php8.2 - security update","published_at":"2023-08-05T04:14:59Z","modified_at":"2026-11-20T01:19:09.968468Z","first_seen_at":"2026-11-21T19:15:06.060535Z","severity":"critical","severity_source":"cvss","cvss_score":9.8,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","cwe":["CWE-120","CWE-121","CWE-122","CWE-126"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.21786,"epss_percentile":0.97682,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2023-3824"},"matched_alias":null,"items":[{"id":484,"source":{"id":"debian-php","name":"Debian 12 php8.2 (package vulnerabilities)"},"title":"php8.2 (Debian:12): DSA-5661-1 / CVE-2023-3823 - php8.2 - security update","summary":"Affected: Debian:12:php8.2\n\nFixed in: 8.2.18-1~deb12u1","url":"https://osv.dev/vulnerability/DSA-5661-1","published_at":"2024-04-15T00:00:00Z","updated_at":"2026-11-20T01:19:09.968468Z","fetched_at":"2026-11-21T19:15:05.963731Z","severity":"critical","cvss_score":9.8,"epss":0.38115,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php8.2","vuln_id":"CVE-2023-3823","vuln_ids":["CVE-2022-31629","CVE-2023-3823","CVE-2023-3824","CVE-2024-2756","CVE-2024-3096","DSA-5661-1","GHSA-3QRF-M4J2-PCRR","GHSA-C43M-486J-J32P","GHSA-H746-CJRR-WFMR","GHSA-JQCX-CCGC-XWHV","GHSA-WPJ3-HF5J-X4V4"],"tags":["package-watch","pkg:php8.2","fix-available"],"cluster_id":379,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/484","html":"https://vulnwatch.ve1ve2.com/item/484"}},{"id":503,"source":{"id":"debian-php","name":"Debian 12 php8.2 (package vulnerabilities)"},"title":"php8.2 (Debian:12): DEBIAN-CVE-2023-3824 / CVE-2023-3824 - In PHP version 8.0.* before 8.0.30,  8.1.* before 8.1.22, and 8.2.* before 8.2.8, when loading phar file, while reading PHAR directory entries, insufficient le…","summary":"In PHP version 8.0.* before 8.0.30,  8.1.* before 8.1.22, and 8.2.* before 8.2.8, when loading phar file, while reading PHAR directory entries, insufficient length checking may lead to a stack buffer overflow, leading potentially to memory corruption or RCE.\n\nAffected: Debian:12:php8.2\n\nFixed in: 8.2.18-1~deb12u1\n\nReferences:\nhttps://security-tracker.debian.org/tracker/CVE-2023-3824","url":"https://osv.dev/vulnerability/DEBIAN-CVE-2023-3824","published_at":"2023-08-11T06:15:10.560000Z","updated_at":"2026-10-26T18:03:05.843988Z","fetched_at":"2026-11-21T19:15:05.963758Z","severity":"critical","cvss_score":9.8,"epss":0.21786,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php8.2","vuln_id":"CVE-2023-3824","vuln_ids":["CVE-2023-3823","CVE-2023-3824","CVE-2024-2756","CVE-2024-3096","DEBIAN-CVE-2023-3824","GHSA-JQCX-CCGC-XWHV"],"tags":["package-watch","pkg:php8.2","fix-available"],"cluster_id":380,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/503","html":"https://vulnwatch.ve1ve2.com/item/503"}},{"id":12679,"source":{"id":"gh-php-src","name":"PHP releases (GitHub php/php-src tags)"},"title":"GHSA-jqcx-ccgc-xwhv / CVE-2023-3824: Buffer overflow and overread in phar_dir_read()","summary":"Buffer overflow and overread in phar_dir_read() ### Summary Buffer mismanagement in `phar_dir_read()` causes a buffer overflow and a buffer overread later. ### Details https://github.com/php/php-src/blob/be71cadc2f899bc39fe27098042139392e2187db/ext/phar/dirstream.c#L89C1-L116 There are few issues here: * The if check `to_read == 0 || count < ZSTR_LEN(str_key)` is not right. In particular, if this is false we know that `count >= ZSTR_LEN(str_key)`. Furthermore, because of `to_read = MIN(ZSTR_LEN(str_key), count);` we now actually have: `to_read == ZSTR_LEN(str_key)`. If we have a filename length (i.e. `ZSTR_LEN(str_key)`) equal to `sizeof(php_stream_dirent)`, then we get `ZSTR_LEN(str_key) == count == to_read == sizeof(php_stream_dirent)`. Take a look now at this line: `((php_stream_dirent *) buf)->d_name[to_read + 1] = '\\0';`. Assume `sizeof(php_stream_dirent)` is 4096 like on most Linuxes. Then we write at offset 4097, which is two bytes outside of `buf`. This line was actually supposed to use `to_read` instead of `to_read + 1`, because now even if it doesn't overflow, it does not properly NUL-terminate the filename. We're just lucky there's a memset above. Correcting that to use `to_read` doesn't solve the whole problem: it would still overflow because it will write at offset 4096 which is still outside `buf`. This means we have a stack information leak and a buffer write overflow. * Both the `memset` and the return value assume that `count == sizeof(php_stream_dirent)`. In principle if there are any callers where that count is smaller, a buffer overflow occurs in the `memset`. However, inside PHP itself I did not find any such caller, but this may be a concern for third-party extensions. ### PoC I created a reproducer using PHP-8.0 with these configure flags: `./configure --enable-debug --disable-all --enable-phar --with-valgrind` using compiler `gcc (GCC) 13.1.1 20230429`. Create the malicious Phar file using: ```php startBuffering(); $phar->addFromString(str_repeat('A', PHP_MAXPATHLEN - 1).'B', 'This is the content of the file.'); $phar->stopBuffering(); ?> ``` Trigger the buffer overflow and overread using this script: ```php ``` If you run this in Valgrind, i.e. `valgrind ./sapi/cli/php trigger.php` you'll find two Valgrind complaints: ``` ==42575== Conditional jump or move depends on uninitialised value(s) ==42575== at 0x4847ED8: strlen (vg_replace_strmem.c:501) ==42575== by 0x53BE9C: zif_readdir (dir.c:389) ==42575== by 0x6D05C4: ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (zend_vm_execute.h:1295) ==42575== by 0x742F7D: execute_ex (zend_vm_execute.h:55163) ==42575== by 0x747848: zend_execute (zend_vm_execute.h:59523) ==42575== by 0x696376: zend_execute_scripts (zend.c:1694) ==42575== by 0x5F6D45: php_execute_scrip Patched: 8.0.30","url":"https://github.com/php/php-src/security/advisories/GHSA-jqcx-ccgc-xwhv","published_at":"2023-08-05T04:14:59Z","updated_at":"2023-08-05T04:14:59Z","fetched_at":"2026-11-22T14:05:37.431203Z","severity":"critical","cvss_score":9.8,"epss":0.21786,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php-src","vuln_id":"CVE-2023-3824","vuln_ids":["CVE-2023-3823","CVE-2023-3824","CVE-2024-2756","CVE-2024-3096","GHSA-JQCX-CCGC-XWHV"],"tags":["repo-advisory","CWE-120","CWE-121","CWE-122","CWE-126","security","repo:php/php-src","stack"],"cluster_id":11792,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/12679","html":"https://vulnwatch.ve1ve2.com/item/12679"}}]}