CVE-2020-7068: Use of freed hash key in the phar_parse_zipfile function

Published Aug 3, 2020
·
Updated

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

15 affected componentsFixes available
PHP PHP<7.2.33
7.2.33
PHP PHP>=7.2.0<7.2.33
PHP PHP>=7.3.0<7.3.21
PHP PHP>=7.4.0<7.4.9
Debian Debian Linux=10.0
Tenable Tenable.Sc<5.19.0
alpine/php7<7.3.22-r0
7.3.22-r0
alpine/php7<7.2.33-r0
7.2.33-r0
redhat/php<7.2.33
7.2.33
redhat/php<7.3.21
7.3.21
redhat/php<7.4.9
7.4.9
debian/php7.4<7.4.9-1
7.4.9-1
debian/php7.0
7.0.33-0+deb9u9
debian/php7.3
7.3.27-1~deb10u1
debian/php7.4
7.4.9-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 7.2.33
  2. Upgrade

    Upgrade alpine/php7 to a version that resolves this vulnerability.

    Fixed in 7.3.22-r0
  3. Upgrade

    Upgrade alpine/php7 to a version that resolves this vulnerability.

    Fixed in 7.2.33-r0
  4. Upgrade

    Upgrade redhat/php to a version that resolves this vulnerability.

    Fixed in 7.2.33
  5. Upgrade

    Upgrade redhat/php to a version that resolves this vulnerability.

    Fixed in 7.3.21
  6. Upgrade

    Upgrade redhat/php to a version that resolves this vulnerability.

    Fixed in 7.4.9
  7. Upgrade

    Upgrade debian/php7.4 to a version that resolves this vulnerability.

    Fixed in 7.4.9-1
  8. Upgrade

    Upgrade debian/php7.0 to a version that resolves this vulnerability.

    Fixed in 7.0.33-0+deb9u9
  9. Upgrade

    Upgrade debian/php7.3 to a version that resolves this vulnerability.

    Fixed in 7.3.27-1~deb10u1
  10. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 7.3.21
  11. Upgrade

    Upgrade PHP to a version that resolves this vulnerability.

    Fixed in 7.4.9

Event History

Aug 3, 2020
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
DescriptionSeverityWeakness
Aug 6, 2020
Data Sourced
12:00 AM
DescriptionAffected Software
Updated
12:00 AM
Affected Software
Aug 11, 2020
Data Sourced
via Red Hat·05:30 PM
DescriptionSeverityAffected Software
Sep 9, 2020
CVE Published
via MITRE·05:58 PM
Data Sourced
via OSV·06:15 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·06:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Jul 1, 2022
Data Sourced
12:18 PM
RemedySeverityWeakness
Nov 24, 2026
Withdrawn
via OSV·04:29 AM

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

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.

2

How does CVE-2020-7068 affect PHP?

CVE-2020-7068 affects PHP versions up to and excluding 7.2.33.

3

What is the severity of CVE-2020-7068?

The severity of CVE-2020-7068 is not specified.

4

How can I fix CVE-2020-7068?

To fix CVE-2020-7068, update PHP to version 7.2.33 or later.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203