php / php/php-src

StreamPollHandle UAF

Ouverte
#22,844 3 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@iliaal y travaille déjà.

Depuis le 21/7/2026.

Bug Category: Streams Status: Verified
Langage dominant
C
Étoiles
40.4k
Forks
8.2k
Merge moyen
2 j 13 h
PR mergées (30 j)
96

Description

Description

StreamPollHandle::__construct() caches the raw php_stream * pointer but only takes a reference on the stream's zend_resource container not on the stream itself. When the stream is closed with fclose() php_stream_free() calls pefree() on the php_stream and zend_resource_dtor() sets res->ptr = NULL yet the handle's cached data->stream field is never cleared and keeps pointing at the freed memory. The methods isValid() getFileDescriptor() and getStream() check the stale data->stream pointer (which is still non-NULL) instead of the resource so they dereference the freed php_stream. This is a use-after-free: getFileDescriptor() reaches php_stream_cast() which reads stream->ops and performs an indirect call through stream->ops->cast() from freed memory and getStream() even hands the freed stream back to userland as a live resource. The fix is to validate and read the stream through the held resource (data->res->ptr/type) rather than the cached raw pointer, or not cache data->stream at all.

PHP Version
8.6.0-dev. Component: Standard (ext/standard/io_poll.c)
Operating System

No response

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.