CVE-2020-7068: Use of freed hash key in the phar_parse_zipfile function
Fixed bug (Use of freed hash key in the pharparsezipfile function). (CVE-2020-7068)
Other sources
he pharparsezipfile function had use-after-free vulnerability because of mishandling of the actualalias variable.
----- ext/phar/zip.c ----- int pharparsezipfile(phpstream fp, char fname, sizet fnamelen, char alias, sizet aliaslen, phararchivedata pphar, char error) / {{{ / { ...
mydata->alias = entry.ispersistent ? pestrndup(actualalias, mydata->aliaslen, 1) : actualalias;
if (entry.ispersistent) { efree(actualalias); }
zendhashstraddptr(&(PHARG(pharaliasmap)), actualalias, mydata->aliaslen, mydata);
... ---------------------------
actualalias variable is allocated by estrndup function, which string is part of data of the zip file.
The above code snippet mydata->alias is assigned by pestrndup(actualalias, mydata->aliaslen, 1) if entry.ispersistent is true. Or mydata->alias is assigned by actualalias variable. And if entry.ispersistent is true, actualalias variable is freed by invoke efree function. actualalias variable is used invoke of zendhashstraddptr function as 2nd argument.
Problem is that actualalias variable is freed if entry.ispersistent is true, the key of pharaliasmap will use freed memory. entry.ispersistent is true if phar.cachelist fields is defined in php.ini file.
So if phar.cachelist is defined with target phar path so that entry.ispersistent is true, then it can be that pharaliasmap hash key would use sensitive freed memory data such as heap addresses that addresses set via linked list after invoke the efree function.
Possibly affected versions: php 7.2.32, php 7.3.20, php 7.4.8
Upstream Reference:
https://bugs.php.net/bug.php?id=79797 https://www.php.net/ChangeLog-7.php
— Red Hat
In PHP versions 7.2.x below 7.2.33, 7.3.x below 7.3.21 and 7.4.x below 7.4.9, while processing PHAR files using phar extension, pharparsezipfile could be tricked into accessing freed memory, which could lead to a crash or information disclosure.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 7.2.33 - Upgrade
Upgrade
alpine/php7to a version that resolves this vulnerability.Fixed in 7.3.22-r0 - Upgrade
Upgrade
alpine/php7to a version that resolves this vulnerability.Fixed in 7.2.33-r0 - Upgrade
Upgrade
redhat/phpto a version that resolves this vulnerability.Fixed in 7.2.33 - Upgrade
Upgrade
redhat/phpto a version that resolves this vulnerability.Fixed in 7.3.21 - Upgrade
Upgrade
redhat/phpto a version that resolves this vulnerability.Fixed in 7.4.9 - Upgrade
Upgrade
debian/php7.4to a version that resolves this vulnerability.Fixed in 7.4.9-1 - Upgrade
Upgrade
debian/php7.0to a version that resolves this vulnerability.Fixed in 7.0.33-0+deb9u9 - Upgrade
Upgrade
debian/php7.3to a version that resolves this vulnerability.Fixed in 7.3.27-1~deb10u1 - Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 7.3.21 - Upgrade
Upgrade
PHPto a version that resolves this vulnerability.Fixed in 7.4.9
Event History
Frequently Asked Questions
What is CVE-2020-7068?
CVE-2020-7068 is a vulnerability in PHP that allows for the use of a freed hash key in the phar_parse_zipfile function.
How does CVE-2020-7068 affect PHP?
CVE-2020-7068 affects PHP versions up to and excluding 7.2.33.
What is the severity of CVE-2020-7068?
The severity of CVE-2020-7068 is not specified.
How can I fix CVE-2020-7068?
To fix CVE-2020-7068, update PHP to version 7.2.33 or later.
Where can I find more information about CVE-2020-7068?
More information about CVE-2020-7068 can be found in the PHP ChangeLog at https://www.php.net/ChangeLog-7.php#7.2.33.