CVE-2023-3824

9.4 CRITICAL

📋 TL;DR

This CVE describes a stack buffer overflow vulnerability in PHP's PHAR file handling that could lead to memory corruption or remote code execution. It affects PHP versions 8.0.* before 8.0.30, 8.1.* before 8.1.22, and 8.2.* before 8.2.8. Any system running vulnerable PHP versions that processes PHAR files is potentially at risk.

💻 Affected Systems

Products:
  • PHP
Versions: PHP 8.0.* before 8.0.30, 8.1.* before 8.1.22, 8.2.* before 8.2.8
Operating Systems: All operating systems running affected PHP versions
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability triggers when PHP loads PHAR files. Applications that process user-uploaded files or include PHAR archives are particularly vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution with the privileges of the PHP process, potentially leading to complete system compromise.

🟠

Likely Case

Memory corruption leading to denial of service (PHP process crash) or limited code execution depending on exploit sophistication.

🟢

If Mitigated

Denial of service from PHP process crashes if exploit attempts are blocked or fail.

🌐 Internet-Facing: HIGH - PHP is commonly used in web applications that may process user-uploaded PHAR files.
🏢 Internal Only: MEDIUM - Internal systems running PHP applications could be exploited by authenticated users or through other attack vectors.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires the ability to make PHP load a malicious PHAR file, which could be achieved through file upload functionality or other means.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: PHP 8.0.30, 8.1.22, 8.2.8

Vendor Advisory: https://github.com/php/php-src/security/advisories/GHSA-jqcx-ccgc-xwhv

Restart Required: Yes

Instructions:

1. Identify PHP version with 'php -v'. 2. Update PHP using your package manager: For Ubuntu/Debian: 'sudo apt update && sudo apt upgrade php'. For RHEL/CentOS: 'sudo yum update php'. 3. Restart web server: 'sudo systemctl restart apache2' or 'sudo systemctl restart nginx'. 4. Verify update with 'php -v'.

🔧 Temporary Workarounds

Disable PHAR extension

all

Disable the PHAR extension to prevent loading of PHAR files entirely.

Add 'phar.readonly = 1' to php.ini
Add 'extension=phar.so' to php.ini with a leading semicolon to comment it out

Restrict file uploads

all

Block upload or processing of .phar files in web applications.

Configure web application firewalls to block .phar files
Implement file type validation in applications

🧯 If You Can't Patch

  • Implement strict file upload controls to block PHAR files
  • Use web application firewalls to detect and block exploit attempts

🔍 How to Verify

Check if Vulnerable:

Run 'php -v' and check if version is in affected range: 8.0.0-8.0.29, 8.1.0-8.1.21, or 8.2.0-8.2.7.

Check Version:

php -v

Verify Fix Applied:

Run 'php -v' and confirm version is 8.0.30+, 8.1.22+, or 8.2.8+.

📡 Detection & Monitoring

Log Indicators:

  • PHP segmentation fault errors
  • Unexpected process termination of PHP-FPM or Apache modules
  • Failed PHAR file loading attempts

Network Indicators:

  • Unusual file uploads with .phar extension
  • HTTP requests attempting to trigger PHAR loading

SIEM Query:

source="*php*" AND ("segmentation fault" OR "core dumped" OR "phar" AND "load")

🔗 References

📤 Share & Export