Bug 1213407 (CVE-2015-3411)

Summary: CVE-2015-3411 php: missing null byte checks for paths in various PHP extensions
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, 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.40, php 5.5.24, php 5.6.8 Doc Type: Bug Fix
Doc Text:
It was found that certain PHP functions did not properly handle file names containing a NULL character. A remote attacker could possibly use this flaw to make a PHP script access unexpected files and bypass intended file system access restrictions.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-09 21:32:21 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: 1213456, 1228052, 1228053, 1228070, 1228071, 1228072, 1228073, 1228074, 1228075, 1228076, 1228077    
Bug Blocks: 1213462    

Description Vasyl Kaigorodov 2015-04-20 13:42:06 UTC
PHP versions 5.4.40, 5.5.24, and 5.6.8 provide a fix for multiple PHP extensions which did not check for NULL byte in a path when processing/reading a file which might lead to a sensitive information disclosure.

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

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

Comment 1 Vasyl Kaigorodov 2015-04-20 15:24:37 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1213456]

Comment 2 Fedora Update System 2015-04-22 22:51:48 UTC
php-5.6.8-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-04-23 16:10:52 UTC
php-5.6.8-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-04-27 08:39:29 UTC
php-5.5.24-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-21 20:08:52 UTC
This is yet another CVE-2006-7243-like issue (which is tracked via bug 662707).  PHP allows NUL (\0) character in file names.  When such file names are passed to underlying C libraries, file name gets truncated at first \0, which causes PHP to use different file than intended.  This may have application specific consequences.

There are few cases mentioned in the upstream bug report:

- DOMDocument's load(), but upstream fix also covers loadHTMLFile(),  relaxNGValidate(), and schemaValidate() methods

- xmlwriter_open_uri / XMLWriter::openURI

- fileinfo_file - this issue only affects PHP 5.3.0 and later, older versions do not include fileinfo extension

- hash_hmac_file(), but upstream fix also covers hash_file() and hash_update_file()

Upstream fix covers additional cases not mentioned in the upstream bug:

- gd extension:
  - imageloadfont()
  - imagepsencodefont() - this case does not affect PHP packages in Red Hat
    products, as PHP GD extension there does not support Type1 fonts
  - imagecreatefrom*()

- pgsql extension - pg_trace()

- standard extension - readlink() - this was previously fixed as part of CVE-2006-7243.  However, the fix was regressed in PHP 5.4 and later:
  https://bugs.php.net/bug.php?id=69418

- standard extension - stream_resolve_include_path() - it seems this may only have impact if resolving a file form phar archive.  Outside of phar, resolution goes through function php_resolve_path() which already checks paths for NUL.  Function only exists in PHP 5.3.2 and later.

- zlib extension:
  - gzopen()
  - readgzfile()
  - gzfile() was fixed in PHP 5.4 as part of fix for CVE-2006-7243.  The fix
    that was applied to 5.3 did not add NUL check to gzfile().

Comment 6 Tomas Hoger 2015-05-21 20:14:44 UTC
Upstream fix can not be directly backported to PHP 5.3 as the upstream fix uses 'p' parameter parsing option for zend_parse_parameters().  This option was introduced upstream in version 5.4.  Fix either needs to be changed to do checks as strlen(filename) != filename_len and report error, or introduce support for 'p' parsing option (it was added upstream as part of CVE-2006-7243 fix).

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

Comment 9 Tomas Hoger 2015-05-28 12:01:31 UTC
Created new upstream bug report for some related cases where paths with NUL are still accepted:

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

Comment 14 Tomas Hoger 2015-06-05 14:48:53 UTC
The PHP packages as shipped as part of the php54 collection in Red Hat Software Collections were updated to fixed upstream version 5.4.40 via RHSA-2015:1066 released as part of Red Hat Software Collections 2.0.


This issue has been addressed in the php54-php packages in the following products:

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

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

Comment 17 Tomas Hoger 2015-06-17 15:03:03 UTC
(In reply to Tomas Hoger from comment #5)
> There are few cases mentioned in the upstream bug report:

CVE-2015-3411 was assigned to the issues described in the upstream bug report.

> Upstream fix covers additional cases not mentioned in the upstream bug:

CVE-2015-3412 was assigned to the additional fixed part of the upstream commit.  Separate bug 1232823 was created for this CVE.

See the following oss-security mailing list post for details of the CVE assignment:

http://seclists.org/oss-sec/2015/q2/727

Comment 18 errata-xmlrpc 2015-06-23 08:12:57 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 19 errata-xmlrpc 2015-06-25 08:32:15 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 20 errata-xmlrpc 2015-06-25 08:43:37 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 21 errata-xmlrpc 2015-07-09 17:07:36 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