|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2021-10-11 12:49 UTC] bukka@php.net
-Status: Open
+Status: Assigned
-Package: *General Issues
+Package: FPM related
-Assigned To:
+Assigned To: bukka
[2021-10-17 20:03 UTC] bukka@php.net
[2021-10-18 14:32 UTC] bukka@php.net
[2021-10-18 19:35 UTC] bukka@php.net
[2021-10-31 21:29 UTC] bukka@php.net
[2021-11-01 11:16 UTC] c dot fol at ambionics dot io
[2021-11-07 21:01 UTC] bukka@php.net
-Type: Security
+Type: Bug
[2021-11-07 21:01 UTC] bukka@php.net
[2021-11-07 21:02 UTC] bukka@php.net
[2021-11-14 20:18 UTC] git@php.net
[2021-11-14 20:18 UTC] git@php.net
-Status: Assigned
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Description: ------------ Hello PHP team, There's a heap overflow in PHP-FPM's log management system, which is enabled only if you enable "catch_workers_output" in the configuration, and change zlog_limit. Basically, with catch_workers_output On, the root process will buffer anything its workers write to stderr until a newline is encountered, in which case it will send the line to the log file, and flush the buffer. The code responsible for (re-)allocating the buffer is wrong. Take a look at zlog_stream_buf_copy_cstr(): if there is not enough space remaining in the buffer to store the new string, zlog_stream_buf_alloc_ex() is called. zlog_stream_buf_alloc_ex() can, in some cases, allocate "needed" (3rd params) bytes. Now, when you go back to zlog_stream_buf_copy_cstr(), you can see the memcpy() copies str_len bytes, but starting at offset stream->len. Therefore, there can be cases where you (re-allocate) a buffer of size str_len, but copy up to offset stream->len + str_len, leading to an overflow of size stream->len. The configuration required for this is very unlikely, and exploit pretty tedious, so I don't think it is a serious security bug, but this is a very simple patch. I guess the simplest way to patch is to change: if (stream->buf.size - stream->len <= str_len && !zlog_stream_buf_alloc_ex(stream, str_len)) { to if (stream->buf.size - stream->len <= str_len && !zlog_stream_buf_alloc_ex(stream, stream->len + str_len)) { Charles Expected result: ---------------- No overflow Actual result: -------------- Potential overflow