Bug 1297710 - (CVE-2016-5114) CVE-2016-5114 php: out-of-bounds write in fpm_log.c
CVE-2016-5114 php: out-of-bounds write in fpm_log.c
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20151021,repor...
: Security
Depends On: 1297711
Blocks: 1297732
  Show dependency treegraph
 
Reported: 2016-01-12 04:55 EST by Adam Mariš
Modified: 2016-11-15 08:45 EST (History)
15 users (show)

See Also:
Fixed In Version: php 5.6.17, php 5.5.31
Doc Type: Bug Fix
Doc Text:
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.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-03 08:05:20 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Adam Mariš 2016-01-12 04:55:27 EST
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
Comment 1 Adam Mariš 2016-01-12 04:55:59 EST
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1297711]
Comment 2 Fedora Update System 2016-01-16 08:22:34 EST
php-5.6.17-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 3 Fedora Update System 2016-01-16 09:20:07 EST
php-5.6.17-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.
Comment 7 errata-xmlrpc 2016-11-15 06:49:01 EST
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

Note You need to log in before you can comment on or make changes to this bug.