php / php/php-src

StreamPollHandle UAF

Aperta
#22,844 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@iliaal ci sta già lavorando.

Dal 21/7/2026.

Bug Category: Streams Status: Verified
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.