Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 1359698 - (CVE-2016-6289) CVE-2016-6289 php: Integer overflow leads to buffer overflow in virtual_file_ex
CVE-2016-6289 php: Integer overflow leads to buffer overflow in virtual_file_ex
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=20160629,repor...
: Security
Depends On: 1359837
Blocks: 1359830
  Show dependency treegraph
 
Reported: 2016-07-25 06:19 EDT by Adam Mariš
Modified: 2016-11-15 10:10 EST (History)
14 users (show)

See Also:
Fixed In Version: php 5.5.38, php 5.6.24, php 7.0.9
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-09-26 16:06:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2750 normal SHIPPED_LIVE Moderate: rh-php56 security, bug fix, and enhancement update 2016-11-15 11:40:02 EST

  None (edit)
Description Adam Mariš 2016-07-25 06:19:56 EDT
An integer overflow vulnerability was found in CWD_API virtual_file_ex in php-src/Zend/zend_virtual_cwd.c that allows to memcpy a large chunk of memory leading to buffer overflow.

Upstream bug:

https://bugs.php.net/bug.php?id=72513

Upstream patch:

http://git.php.net/?p=php-src.git;a=commit;h=0218acb7e756a469099c4ccfb22bce6c2bd1ef87

CVE assignment:

http://seclists.org/oss-sec/2016/q3/137
Comment 1 Adam Mariš 2016-07-25 10:12:53 EDT
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1359837]
Comment 2 Huzaifa S. Sidhpurwala 2016-08-04 02:14:54 EDT
Analysis:

This is a flaw in the Thread Safe Resource Manager virtual_file_ex() function of PHP, which is defined as:

CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath)

Inside the function, path_length is calculated by using:

int path_length = (int)strlen(path);

So, if path variable is attacker controller, the attacker could give an extremely long path, which may cause the output of strlen to wrap, causing an integer overflow. Later in the function the following memcpy() is used.

memcpy(resolved_path , path, path_length + 1);

Depending on the value of path_length (because of the integer overflow), this may cause large chunk of data to copied into the stack based variable resolved_path, resulting in a possible crash.

As described in the upstream bug, one way to trigger this crash would be via a PHP zip handling functions. In the POC the following is used:

        $a->extractTo(".", str_repeat("/",0xfffffff0));

Here the path variable fed to virtual_file_ex is specially-crafted and can cause a crash.

So, this attack can only be triggered if the path variable can be in some way controlled by the attacker.
Comment 3 errata-xmlrpc 2016-11-15 06:43:08 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.