Skip to content
RCE Write-up Intermediate

XSS or RCE  : Make your choice (.shtml) WebShebounty $$$

An upload form that only allowed .txt, .doc and .pdf files and blocked PHP also accepted .html and .shtml files. Because the server processed Server Side Includes in .shtml files, an attacker could run operating system commands on the server, turning a simple file upload into remote code execution.

medium.com

Published on medium.com

Hello, today I will talk about how to increase the impact of an attack if you have access to upload a .html file on the target. Instead of just injecting XSS payloads, you can use .shtml files to execute commands on the server and bypass upload filters.

CyH1337, on medium.com

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 upload filter used a blocklist that missed .shtml, and the web server had Server Side Includes enabled for that directory, so uploaded files were executed rather than served as static content.

Impact

An attacker could execute arbitrary operating system commands on the server, which could lead to full compromise of the host.

What the attacker needed

Access to the upload form; server processes SSI in .shtml files

The fix

The upload should be restricted with an allowlist of safe extensions and the server should not process Server Side Includes in user-uploaded files.

How it was found

  1. Find the upload page that accepts .txt, .doc and .pdf and blocks PHP files.
  2. Upload a plain .html file to confirm it is accepted.
  3. Upload a .shtml file containing a Server Side Include exec directive.
  4. Open the uploaded file so the server processes it and runs the command.

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 website let people upload documents, and it tried to block dangerous file types like PHP. But it forgot about .shtml files, which the web server treats specially: it reads instructions inside them and runs them. The author put a command in such a file, and the server ran it, which means the attacker could control 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.