CVE-2020-7068 Overview
CVE-2020-7068 is a Use After Free vulnerability affecting PHP versions 7.2.x below 7.2.33, 7.3.x below 7.3.21, and 7.4.x below 7.4.9. The vulnerability exists in the PHAR (PHP Archive) extension, specifically in the phar_parse_zipfile function. When processing maliciously crafted PHAR files, the function can be tricked into accessing freed memory, potentially leading to application crashes or information disclosure.
Critical Impact
A local attacker with low privileges could exploit this vulnerability to cause a denial of service condition through application crash or potentially extract sensitive information from memory.
Affected Products
- PHP versions 7.2.x below 7.2.33
- PHP versions 7.3.x below 7.3.21
- PHP versions 7.4.x below 7.4.9
- Debian Linux 10.0
- Tenable.sc (various versions)
Discovery Timeline
- 2020-09-09 - CVE-2020-7068 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-7068
Vulnerability Analysis
This Use After Free (CWE-416) vulnerability resides in PHP's PHAR extension, which handles PHP Archive files. The phar_parse_zipfile function contains a memory management flaw where it attempts to access memory that has already been deallocated during the parsing of ZIP-based PHAR archives.
Use After Free vulnerabilities occur when a program continues to use a pointer after the memory it references has been freed. In this case, the PHAR parser fails to properly track memory allocation states during archive processing, creating a window where freed memory can be referenced.
The attack requires local access with low privileges to execute, and the attack complexity is high, making successful exploitation more difficult. However, once exploited, an attacker could potentially read sensitive data from freed memory regions or cause the PHP process to crash.
Root Cause
The root cause of CVE-2020-7068 lies in improper memory lifecycle management within the phar_parse_zipfile function. When parsing ZIP-formatted PHAR archives, the function allocates memory for various archive structures. Under certain conditions involving malformed or specially crafted archive data, the memory deallocation logic can execute prematurely while references to that memory still exist in the parsing flow. Subsequent operations then attempt to access this freed memory, triggering the Use After Free condition.
Attack Vector
The attack vector for this vulnerability requires local access to the target system. An attacker would need to:
- Craft a malicious PHAR file designed to trigger the Use After Free condition
- Cause the target PHP application to process this malicious PHAR file through the phar extension
- The phar_parse_zipfile function would then access freed memory during archive parsing
The vulnerability mechanism involves manipulating the ZIP archive structure within a PHAR file to create a race condition or state inconsistency that leads to premature memory deallocation. When the parser continues processing and attempts to access the freed memory region, it may read arbitrary data or cause a segmentation fault.
For technical details on the vulnerability, see the PHP Bug Report #79797.
Detection Methods for CVE-2020-7068
Indicators of Compromise
- Unexpected PHP process crashes or segmentation faults during PHAR file processing
- Abnormal memory access patterns in PHP application logs
- Presence of unusual or malformed PHAR/ZIP archive files in application directories
- Error messages referencing phar_parse_zipfile in PHP error logs
Detection Strategies
- Monitor PHP error logs for segmentation faults or memory-related errors during PHAR operations
- Implement file integrity monitoring to detect suspicious PHAR files being uploaded or created
- Deploy application-level monitoring to track PHAR extension usage patterns
- Use SentinelOne's behavioral detection to identify anomalous PHP process behavior
Monitoring Recommendations
- Enable verbose logging for PHP applications that process PHAR archives
- Implement real-time monitoring of PHP process memory allocation patterns
- Configure alerts for PHP process crashes that may indicate exploitation attempts
- Monitor file upload endpoints for PHAR file submissions
How to Mitigate CVE-2020-7068
Immediate Actions Required
- Upgrade PHP to version 7.2.33 or later for the 7.2.x branch
- Upgrade PHP to version 7.3.21 or later for the 7.3.x branch
- Upgrade PHP to version 7.4.9 or later for the 7.4.x branch
- Review and restrict which applications have access to process PHAR files
- Consider disabling the PHAR extension if not required for application functionality
Patch Information
PHP has released patches addressing this vulnerability in the following versions:
- PHP 7.2.33 - Fixes the Use After Free in phar_parse_zipfile
- PHP 7.3.21 - Fixes the Use After Free in phar_parse_zipfile
- PHP 7.4.9 - Fixes the Use After Free in phar_parse_zipfile
Vendor advisories and patches are available from the following sources:
- PHP Bug Report #79797
- Debian Security Advisory DSA-4856
- Tenable Security Advisory TNS-2021-14
- Gentoo GLSA 202009-10
Workarounds
- Disable the PHAR extension in php.ini if PHAR functionality is not required: phar.readonly = 1 and remove phar from enabled extensions
- Implement strict input validation to prevent processing of untrusted PHAR files
- Use application-level controls to restrict PHAR file processing to trusted sources only
- Deploy web application firewalls (WAF) to filter requests containing PHAR content
# Configuration example - Disable PHAR extension in php.ini
# Edit your php.ini file and add/modify the following:
phar.readonly = 1
# Comment out or remove the phar extension line if present:
# extension=phar
# Restart PHP/web server to apply changes
sudo systemctl restart php-fpm
sudo systemctl restart apache2 # or nginx
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


