Server-Side Template Injection in an Unknown Language with a Documented Exploit — SSTI…
The application was vulnerable to server-side template injection in the Handlebars template engine, allowing an attacker to inject a template payload that executed a shell command. The attacker used a documented exploit to run an arbitrary command and delete a file in the user Carlos's home directory.
Published on medium.com
Welcome back for another Pentesting Methodology Lab Walkthrough at the Cybersec Cafe. Today, I’ll be approaching an SSTI vulnerability and detailing my methodology.
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 passed user input directly into a Handlebars template without sanitising it, allowing template expressions to be evaluated as code.
Impact
An attacker could execute arbitrary commands on the server, leading to remote code execution and deletion of files.
What the attacker needed
Access to the vulnerable message parameter
How it was found
- Open the application and click a product that returns an error message, identifying the message parameter as the attack vector.
- Send the request to Burp Repeater and inject a test string to trigger a detailed error message.
- Observe the error message revealing the application uses Handlebars.
- Search online for a documented Handlebars SSTI exploit and obtain a payload that executes a command.
- Modify the payload to run the command to delete the target file, URL-encoding the space.
- Send the modified payload in the message parameter and observe the lab is solved.
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.
Server-side template injection happens when a website builds its pages using a template system and lets user input become part of the template code. If the template engine is not careful, an attacker can insert special template syntax that the server then runs as code, sometimes even running system commands. Here the attacker found the engine was Handlebars and used a known exploit to run a command that deleted a file.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.