Bug 1297710 (CVE-2016-5114) - CVE-2016-5114 php: out-of-bounds write in fpm_log.c
Summary: CVE-2016-5114 php: out-of-bounds write in fpm_log.c
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2016-5114
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1297711
Blocks: 1297732
TreeView+ depends on / blocked
 
Reported: 2016-01-12 09:55 UTC by Adam Mariš
Modified: 2019-12-16 05:16 UTC (History)
15 users (show)

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.
Clone Of:
Environment:
Last Closed: 2016-02-03 13:05:20 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2750 0 normal SHIPPED_LIVE Moderate: rh-php56 security, bug fix, and enhancement update 2016-11-15 16:40:02 UTC

Description Adam Mariš 2016-01-12 09:55:27 UTC
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 09:55:59 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1297711]

Comment 2 Fedora Update System 2016-01-16 13:22:34 UTC
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 14:20:07 UTC
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 11:49:01 UTC
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.