UAF in report_class_fetch_error() when the autoloader frees the class name (PHP 8.6.0)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Start in zend_execute_API.c with zend_lookup_class_ex(), where the class name string is released around line 1355, and with report_class_fetch_error(), which builds the message around line 1785. zend_fetch_class() around line 1828 reaches the same path. Reproduce with the PoC under AddressSanitizer to confirm the heap-use-after-free at main/spprintf.c:367. Done when the not-found message is built from a string that is still alive and ASan reports no error.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Hi,
PHP 8.6.0 (official Windows NTS x64 build, 18/11/2026) reads a freed class-name string in report_class_fetch_error().
When the autoloader frees the variable that holds the class name, zend_lookup_class_ex() drops the last reference at zend_execute_API.c:1355, and report_class_fetch_error() then builds the "Class ... not found" message from the freed string (main/spprintf.c:367).
PoC:
<?php
spl_autoload_register(function ($cls) {
$GLOBALS['cls'] = null;
});
function test() {
global $cls;
$cls::method();
}
$cls = implode("", ["Undefined", "Class"]);
try { test(); } catch (Throwable $e) { echo $e->getMessage(), "\n"; }
On the official 8.6.0 build the message contains freed memory, e.g. Class "UndefineD\x1aB..." not found. With a class name of about 1.45 MB or more, the process crashes with 0xC0000005 (DoS) because the large block is unmapped before the read.
ASAN: heap-use-after-free, READ of size 8 at main/spprintf.c:367; the free is in zend_string_release_ex called from zend_lookup_class_ex:1355; the read is reached from report_class_fetch_error (zend_execute_API.c:1785) and zend_fetch_class:1828.
I could not find an existing report for this call site. PRs #22688 and #22881 cover the dynamic-call paths, not report_class_fetch_error.
I know SECURITY.md treats this family as bugs, not security issues, so this is a bug report.
Suggested fix: keep a reference to class_name until after report_class_fetch_error() has built the message, or copy the name before releasing it.
- Langage dominant
- C
- Étoiles
- 41.8k
- Forks
- 8.6k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 125
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/php-src
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)OuverteExtension: openssl Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
php/php-src#25402 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
php/php-src#25397 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
SNMP accepts malformed remote portsPeut-être pris @somethingwithproof l’a pris il y a 21 jours. Ouverte
Difficulté 2/5 Une demi-journée Accessibilité débutants 62/100
php/php-src#25137 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de php/php-src
Issues similaires
-
interpreter-core type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
ImageMagick/ImageMagick6#490 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
camera-2018/hdu-cs-wiki#647 ·
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
AcademySoftwareFoundation/openexr#2884 ·
Les mainteneurs répondent en général sous 1 jour