How I bypassed PHP functions to read sensitive files on server
The target was vulnerable to CVE-2017-9841, allowing remote PHP code execution. The attacker used PHP functions to list directories and read sensitive configuration files, and after some functions were disabled, bypassed the filter using glob() and file_get_contents().
Published on kailashbohara.com.np
Security engineer with 9 years of experience in penetration testing, security architecture, cloud security, zero trust implementation, and threat hunting.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the PHPUnit vulnerability (CVE-2017-9841) allowed remote code execution, and the subsequent filtering of dangerous functions was incomplete, permitting bypass via other PHP functions.
What the attacker needed
Target runs vulnerable PHPUnit (CVE-2017-9841); attacker can send HTTP requests
The fix
The text gives no official fix; the administrator likely filtered dangerous functions, but the vulnerability may still exist.
How it was found
- Identified CVE-2017-9841 via nuclei scan.
- Confirmed code execution by running getcwd() through a crafted request in Burp Suite.
- Used shell_exec() to list home directories and files.
- Read a configuration file using PHP functions.
- After shell_exec() was disabled, used glob() to list files again.
- Combined file_get_contents() and explode() to read the database configuration file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A website was running an old version of a tool (PHPUnit) that let attackers run their own code on the server. The attacker used that to browse folders and open a configuration file that held sensitive information. When the site later blocked some commands, the attacker found other built-in functions to achieve the same result.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.