Bughunt Authenticated Rce Found In Horizontcms Part 2 Php Filetype Bypass
The application allowed an authenticated admin to upload an .htaccess file and a PHP file with a non-PHP extension, which together enabled remote code execution. An attacker with admin access could execute arbitrary commands on the server.
As I talked about in the Part 1, (BugHunt) Authenticated RCE found in HorizontCMS — Part 1 (Malicious Plugins), blog, we found a way to bypass the patched PHP filetype restrictions to upload a .php file. However, the executing the uploaded PHP file was not accomplished.
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
Impact
An authenticated admin could execute arbitrary commands on the server, leading to full compromise.
What the attacker needed
Admin access to the CMS
The fix
The issue was fixed by HorizontCMS in a security release.
How it was found
- Log in to the admin panel.
- Go to Media → Files.
- Upload a file named test2.htaccess, then rename it to .htaccess.
- Upload a PHP file named test2.php, then rename it to test.hello.
- Access the uploaded file under /storage with a command parameter to execute commands.
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.
The application let an admin upload files, but it tried to block dangerous PHP files by checking their extension. The attacker uploaded a configuration file that told the web server to treat a harmless-looking file as PHP, then uploaded a PHP script with that harmless extension. When the script was accessed, the server ran it, letting the attacker run commands on the machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.