FPM: NULL dereference in fpm_status_export_to_zval() when the scoreboard copy fails (PHP-8.3)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in sapi/fpm/fpm/fpm_status.c at fpm_status_export_to_zval() and compare the PHP-8.3 code with the PHP-8.6 guard described in the issue. The report says fpm_get_status() in sapi/fpm/fpm/fpm_main.c reaches this function; add the NULL handling after the scoreboard copy and confirm the function returns -1 on failure.
Written by the indexing model from the issue text.
Description
Description
fpm_status_export_to_zval() in sapi/fpm/fpm/fpm_status.c dereferences the result of fpm_scoreboard_copy() without a NULL check:
scoreboard_p = fpm_scoreboard_copy(NULL, 1); /* line 84 */
now_epoch = time(NULL);
fpm_clock_get(&now);
array_init(status);
add_assoc_string(status, "pool", scoreboard_p->pool); /* line 90 -- no NULL check */
fpm_scoreboard_copy() can return NULL (allocation failure, or no scoreboard), and the result is dereferenced immediately, crashing the worker.
This is reachable from PHP userland via the fpm_get_status() builtin (sapi/fpm/fpm/fpm_main.c:1525, which calls fpm_status_export_to_zval() at :1531).
PHP-8.6 already guards this right after the copy (if (!scoreboard_p) { return -1; }); PHP-8.3 is missing the guard.
Not a cross-boundary vulnerability — the trigger is calling a documented PHP function plus a scoreboard-copy failure (e.g. under OOM); it is a self-crash (NULL dereference) of the calling worker.
Suggested fix
Backport the 8.6 guard to PHP-8.3: return -1 when fpm_scoreboard_copy() returns NULL. PR to follow.
PHP Version
PHP-8.3 branch at 3f52e69cdb (PHP 8.3.38-dev (fpm-fcgi), DEBUG).
Operating System
Linux
- Dominant language
- C
- Stars
- 41.9k
- Forks
- 8.5k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 117
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from php/php-src
-
FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Bug Status: Verified
Difficulty 1/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start codePossibly taken @lazerg claimed this 5 days ago. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ROCm/hrx-system#3628 ·
Maintainers usually reply within 1 day