From File Upload to Command Injection to AWS compromise
The file upload endpoint passed the user-supplied filename directly to a shell command, allowing command injection. An attacker could execute arbitrary commands, read environment variables containing AWS credentials, and access an S3 bucket.
We are given a URL to a webapp https://cwlw44ht84.execute-api.ap-southeast-1.amazonaws.com/Prod. It allows us to upload files.
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 concatenated the user-controlled filename into a shell command without sanitisation or validation.
Impact
An attacker could execute arbitrary commands on the server, steal AWS credentials, and access sensitive files in an S3 bucket.
What the attacker needed
Access to the file upload feature; ability to intercept HTTP requests
How it was found
- Upload a file and intercept the request with a proxy.
- Notice the filename appears in the request path.
- Append a command injection payload after the filename.
- Send the request and observe command output in the response.
- Use the env command to list environment variables and find AWS credentials.
- Use the AWS CLI with the stolen credentials to list and download files from the S3 bucket.
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 web app took the name of the uploaded file and used it in a system command without cleaning it. By adding extra shell commands after the filename, the attacker made the server run those commands too. This let them read secret keys and download files from cloud storage.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.