FPM: NULL dereference in fpm_status_export_to_zval() when the scoreboard copy fails (PHP-8.3)

Open Beginner friendly
#26,067 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, php
Domain
api, backend

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from php/php-src

All issues in php/php-src

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.