Bug 1323106 (CVE-2016-4072) - CVE-2016-4072 php: Invalid memory write in phar on filename containing \0 inside name
Summary: CVE-2016-4072 php: Invalid memory write in phar on filename containing \0 ins...
Keywords:
Status: CLOSED WONTFIX
Alias: CVE-2016-4072
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: 1323111
Blocks: 1323121
TreeView+ depends on / blocked
 
Reported: 2016-04-01 10:03 UTC by Adam Mariš
Modified: 2020-12-11 12:08 UTC (History)
17 users (show)

Fixed In Version: php 5.5.34, php 5.6.20, php 7.0.5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-23 11:03:42 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-04-01 10:03:15 UTC
An invalid write vulnerability causing segmentation fault in phar on filename with \0 inside its name was found.

Vulnerable code (phar_analyze_path):

				if (!(realpath = expand_filepath(filename, NULL))) {
					efree(filename);
					return FAILURE;
				}
#ifdef PHP_WIN32
				phar_unixify_path_separators(realpath, strlen(realpath));
#endif
				slash = strstr(realpath, filename);
				if (slash) {
					slash += ((ext - fname) + ext_len);
					*slash = '\0';
				}

If fname and thus filename contain \0's, realpath would not contain those parts and thus slash would point past the end of the realpath buffer.

To exploit this, application has to allow attacker to create phar files with arbitrary filenames.

Upstream bug:

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

Upstream patch:

https://gist.github.com/smalyshev/80b5c2909832872f2ba2
https://git.php.net/?p=php-src.git;a=commit;h=1e9b175204e3286d64dfd6c9f09151c31b5e099a

Comment 1 Adam Mariš 2016-04-01 10:10:45 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1323111]

Comment 2 Fedora Update System 2016-04-09 14:21:11 UTC
php-5.6.20-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 2016-04-09 14:22:40 UTC
php-5.6.20-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 5 errata-xmlrpc 2016-11-15 11:50:36 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.