Unrestricted File Upload to Remote Code Execution
A Backdrop CMS site exposed its .git directory, leaking database credentials and a user email, and the admin area allowed uploading a malicious theme archive containing a PHP shell. An attacker could then run OS commands on the server and escalate to root via a sudo-allowed CMS tool.
medium.com
Published on medium.com
Ini hanyalah contoh sederhana bagaimana kerentanan berupa fitur upload file yang tidak dibatasi atau ditangani dengan baik dapat memungkinkan terjadinya serangan RCE berbasis OS command injection. Target disini adalah dog machine di hackthebox labs.
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 CMS allowed administrators to upload theme archives containing executable PHP files, and the exposed .git directory leaked credentials that gave admin access.
Impact
An attacker with admin access could run arbitrary OS commands and obtain a reverse shell, then escalate to root on the host.
What the attacker needed
Exposed .git directory; leaked database credentials; admin login to the CMS; ability to upload a theme archive
How it was found
- Scan ports with nmap and find the web server and CMS version plus an exposed .git directory.
- Dump the .git directory with git-dumper and read settings.php for MySQL credentials.
- Search the dumped files for an email address ending in the machine's domain.
- Log in to the admin page with the found email and password.
- Upload a malicious theme archive through the appearance/functionality upload feature.
- Access the uploaded PHP file with a cmd parameter to run OS commands, then open a reverse shell.
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 website accidentally left its source-code history folder (.git) publicly readable, which revealed a database password and a user's email address. Once logged in as an administrator, the attacker uploaded a fake theme package that included a small script; because the site ran uploaded files as code, the attacker could make the server execute commands. Finally, a command-line tool the user was allowed to run with administrator rights let the attacker become the root user.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.