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

Offen Anfängerfreundlich
#26,067 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
c, php
Bereich
api, backend

Rechercherichtung

Beginne in sapi/fpm/fpm/fpm_status.c bei fpm_status_export_to_zval() und vergleiche den PHP-8.3-Code mit der im Issue beschriebenen PHP-8.6-Schutzabfrage. Laut Bericht erreicht fpm_get_status() in sapi/fpm/fpm/fpm_main.c diese Funktion; füge die NULL-Behandlung nach dem Kopieren des Scoreboards hinzu und bestätige, dass die Funktion bei einem Fehler -1 zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C
Sterne
41.9k
Forks
8.5k
Ø Merge
2 T. 16 Std.
Gemergte PRs (30 T.)
117

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus php/php-src

Alle Issues in php/php-src

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.