File Upload - Upload. Intercept. Exploit.
A file upload feature accepted a malicious ASP web shell after the tester changed the file extension and content in an intercepted request. The uploaded shell could then be accessed via its URL, allowing command execution on the server.
medium.com
Published on medium.com
As a penetration tester, I often come across interesting security issues during assessments. One such case involved a file upload feature that led to a serious vulnerability Remote Code Execution (RCE).
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 application validated only the file extension, possibly on the client side, and did not check the file content or prevent execution of uploaded files.
Impact
An attacker could run commands on the server, access sensitive files, and potentially escalate privileges further.
What the attacker needed
Access to the file upload feature; ability to intercept HTTP requests
The fix
The application should validate uploads on the server, check file content rather than just the extension, use an allowlist of safe file types, store files where they cannot be executed, and sanitise file names.
How it was found
- Upload a simple ASP web shell with a .asp extension and observe the rejection.
- Upload a harmless image file to confirm that normal uploads succeed.
- Intercept the upload request and change the file extension to .asp.
- Replace the file content with ASP shell code and forward the request.
- Navigate to the uploaded file's URL to execute the 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.
A web shell is a small program uploaded to a server that lets an attacker run commands on it. The site only looked at the file name ending, so renaming a picture to end in .asp and putting code inside got past the check. Once the file was on the server, opening it in a browser ran the code.
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.