How One PHP File Can Hack a Server: WebDAV File Upload to RCE
A WebDAV directory on an Apache server allowed unauthenticated file uploads, so an attacker could upload a PHP reverse shell and execute it to gain a remote shell as the web server user.
medium.com
Published on medium.com
In this blog, we’ll demonstrate how a simple file upload vulnerability can open the door to full Remote Code Execution (RCE) — turning a misconfigured WebDAV directory into a shell-dropping backdoor.
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 attacker could execute arbitrary commands on the server as the www-data user, leading to full system compromise if further privilege escalation is possible.
What the attacker needed
Network access to the WebDAV service; WebDAV enabled with write permissions; server executes PHP files
How it was found
- Send an OPTIONS request to confirm WebDAV is enabled and find the /dav/ path.
- Prepare a PHP reverse shell script with the attacker's IP and port.
- Use the cadaver WebDAV client to upload the PHP file to the /dav/ directory.
- Start a netcat listener on the chosen port.
- Visit the uploaded PHP file in a browser to trigger the 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.
WebDAV is a set of extensions to HTTP that lets users manage files on a web server, including uploading them. If a server allows anyone to upload files and also runs PHP, an attacker can upload a PHP script that connects back to them, giving them command-line access to the server.
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.