[php-src] PR #25714: ext/curl: Fix UAF when CURLOPT_DEBUGFUNCTION closes the CURLOPT_FILE stream

From: Date: Tue, 24 Nov 2026 17:13:57 +0000
Subject: [php-src] PR #25714: ext/curl: Fix UAF when CURLOPT_DEBUGFUNCTION closes the CURLOPT_FILE stream
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-40966@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25714 Author: Schwarzemann curl_debug() is the only cURL callback wrapper that does not call _php_curl_verify_handlers() after invoking the user callback. If the CURLOPT_DEBUGFUNCTION callback closes the stream set as CURLOPT_FILE (or CURLOPT_WRITEHEADER / CURLOPT_INFILE), the cached FILE* is freed but still used, and curl_write() then calls fwrite() on it. Reproducer: ```php $fp = fopen('/tmp/out', 'w'); $ch = curl_init('http://localhost/'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_DEBUGFUNCTION, function ($ch, $type, $data) use ($fp) { if ($type === CURLINFO_HEADER_IN && is_resource($fp)) { fclose($fp); } }); curl_exec($ch); ``` With the fix, the closed stream is detected and the handler is reset, matching the other callbacks (CURLOPT_FILE resource has gone away, resetting to default).

« previous php.git-pulls (#40966) next »