An out-of-bounds write flaw was found in the fpm_log_write() logging function of PHP's FastCGI Process Manager service. A remote attacker could repeatedly send maliciously crafted requests to force FPM to exhaust file system space, creating a denial of service and preventing further logging.
A memory leak and out-of-bounds write was found in fpm_log.c.
At line 237 (php 5.6.14):
len2 = snprintf(b, FPM_LOG_BUFFER - len, "%s", env ? env : "-");
The functions snprintf() and vsnprintf() do not write more than size bytes (including the terminating null byte ('\0')). If the output was truncated due to this limit then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available.
The full length (len) is increased by len2 (line 449):
len += len2;
After exiting the loop, a \n byte is written outside of the compiled buffer and the log line along with some memory area lying after it is flushed into the access log:
if (!test && strlen(buffer) > 0) {
buffer[len] = '\n';
write(fpm_log_fd, buffer, len + 1);
}
This results in one byte written out-of-bounds and several bytes read out-of-bounds.
Upstream patch:
https://git.php.net/?p=php-src.git;a=commitdiff;h=2721a0148649e07ed74468f097a28899741eb58f
Upstream bug (contains reproducer):
https://bugs.php.net/bug.php?id=70755
This issue has been addressed in the following products:
Red Hat Software Collections for Red Hat Enterprise Linux 6
Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
Red Hat Software Collections for Red Hat Enterprise Linux 7
Red Hat Software Collections for Red Hat Enterprise Linux 7.2 EUS
Red Hat Software Collections for Red Hat Enterprise Linux 7.3 EUS
Via RHSA-2016:2750 https://rhn.redhat.com/errata/RHSA-2016-2750.html
A memory leak and out-of-bounds write was found in fpm_log.c. At line 237 (php 5.6.14): len2 = snprintf(b, FPM_LOG_BUFFER - len, "%s", env ? env : "-"); The functions snprintf() and vsnprintf() do not write more than size bytes (including the terminating null byte ('\0')). If the output was truncated due to this limit then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. The full length (len) is increased by len2 (line 449): len += len2; After exiting the loop, a \n byte is written outside of the compiled buffer and the log line along with some memory area lying after it is flushed into the access log: if (!test && strlen(buffer) > 0) { buffer[len] = '\n'; write(fpm_log_fd, buffer, len + 1); } This results in one byte written out-of-bounds and several bytes read out-of-bounds. Upstream patch: https://git.php.net/?p=php-src.git;a=commitdiff;h=2721a0148649e07ed74468f097a28899741eb58f Upstream bug (contains reproducer): https://bugs.php.net/bug.php?id=70755