Bug 1223412 (CVE-2015-4022)

Summary: CVE-2015-4022 php: integer overflow leading to heap overflow when reading FTP file listing
Product: [Other] Security Response Reporter: Vasyl Kaigorodov <vkaigoro>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: bleanhar, ccoleman, dmcphers, fedora, jdetiber, jialiu, jkeck, jliggitt, jokerman, jorton, kseifried, lmeyer, mmaslano, mmccomas, rcollet, webstack-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: php 5.4.41, php 5.5.25, php 5.6.9 Doc Type: Bug Fix
Doc Text:
An integer overflow flaw leading to a heap-based buffer overflow was found in the way PHP's FTP extension parsed file listing FTP server responses. A malicious FTP server could use this flaw to cause a PHP application to crash or, possibly, execute arbitrary code.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-10 16:34:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1223447, 1228052, 1228053, 1228054, 1228055, 1228056, 1228057, 1228058, 1228059, 1228060, 1228061    
Bug Blocks: 1222994    

Description Vasyl Kaigorodov 2015-05-20 13:19:47 UTC
The ftp_genlist() function of the ftp extension is prone to an integer overflow, which may result in remote code execution under certain circumstances.

Upstream report:
https://bugs.php.net/bug.php?id=69545

Upstream fix:
http://git.php.net/?p=php-src.git;a=commitdiff;h=ac2832935435556dc593784cd0087b5e576bbe4d

CVE request:
http://seclists.org/oss-sec/2015/q2/479

Comment 1 Vasyl Kaigorodov 2015-05-20 14:12:32 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1223447]

Comment 2 Fedora Update System 2015-05-26 03:40:28 UTC
php-5.6.9-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 3 Fedora Update System 2015-05-27 16:13:09 UTC
php-5.6.9-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 4 Fedora Update System 2015-05-27 16:23:35 UTC
php-5.5.25-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 5 Tomas Hoger 2015-05-28 10:34:50 UTC
A mitigating factor here is that counter which is overflown is incremented based on actually received data.  Hence application needs to consume ~2GB (or ~512MB on 32bit platforms when using certain older PHP versions) of server response data to trigger overflow.

Upstream fix applied in versions 5.4.41, 5.5.25 and 5.6.9 was found to be incomplete, still making it possible to trigger overflow on 32bit platforms:

https://bugs.php.net/bug.php?id=69545#1431550655

Additionally, when backporting fix to older PHP versions (prior to 5.4.22 and 5.5.6), we need to include this fix to avoid integer overflow in the third argument to safe_emalloc():

http://git.php.net/?p=php-src.git;a=commitdiff;h=8f4a6d6e1b6c36259a5dc865d16f0dad76f2f2c9

A related commit, which is really a cosmetic change, but is needed to have 8f4a6d6 commit above apply cleanly:

http://git.php.net/?p=php-src.git;a=commitdiff;h=1494298231072d5991e76db5ef25f20e81018106

Comment 12 Tomas Hoger 2015-06-04 13:07:36 UTC
(In reply to Tomas Hoger from comment #5)
> Upstream fix applied in versions 5.4.41, 5.5.25 and 5.6.9 was found to be
> incomplete, still making it possible to trigger overflow on 32bit platforms:
> 
> https://bugs.php.net/bug.php?id=69545#1431550655

Upstream fix was corrected via this commit:

http://git.php.net/?p=php-src.git;a=commitdiff;h=0765623d6991b62ffcd93ddb6be8a5203a2fa7e2

Comment 13 errata-xmlrpc 2015-06-23 08:13:28 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2015:1135 https://rhn.redhat.com/errata/RHSA-2015-1135.html

Comment 14 errata-xmlrpc 2015-06-25 08:32:36 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.1 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6.5 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.6 EUS

Via RHSA-2015:1186 https://rhn.redhat.com/errata/RHSA-2015-1186.html

Comment 15 errata-xmlrpc 2015-06-25 08:43:56 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.1 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6.5 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.6 EUS

Via RHSA-2015:1187 https://rhn.redhat.com/errata/RHSA-2015-1187.html

Comment 16 errata-xmlrpc 2015-07-09 17:07:55 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6

Via RHSA-2015:1218 https://rhn.redhat.com/errata/RHSA-2015-1218.html

Comment 17 errata-xmlrpc 2015-07-09 18:53:49 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.1 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6.5 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.6 EUS

Via RHSA-2015:1219 https://rhn.redhat.com/errata/RHSA-2015-1219.html

Comment 18 Tomas Hoger 2015-07-10 16:27:27 UTC
(In reply to Tomas Hoger from comment #5)
> Upstream fix applied in versions 5.4.41, 5.5.25 and 5.6.9 was found to be
> incomplete, still making it possible to trigger overflow on 32bit platforms:
> 
> https://bugs.php.net/bug.php?id=69545#1431550655

A new CVE id CVE-2015-4643 was assigned to the incomplete fix issue, see bug 1234938.  All PHP updates for Red Hat Enterprise Linux and Red Hat Software Collections that corrected this issue CVE-2015-4022 (see comment 13 to comment 17 above) included complete fix and hence also corrected CVE-2015-4643.