Skip to content
RCE Write-up Advanced

Beyond Ssti

Two Craft CMS plugins, Sprout Forms and SEOmatic, rendered user-controlled input through Twig templates, allowing server-side template injection. An attacker could execute arbitrary PHP code and achieve remote code execution.

blog.isec.pl

Published on blog.isec.pl

During our recent security gig, we were asked to perform a security assessment of a freshly added feature – a contact form. As per usual, contact forms don’t contain lots of features or vulnerabilities.

The author, on blog.isec.pl

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

User-controlled input was passed to a template rendering function that evaluated Twig expressions, without sanitisation.

Impact

An attacker could read database credentials and execute arbitrary system commands on the server.

What the attacker needed

Access to the contact form; ability to submit a crafted email address; ability to send a crafted URL

The fix

The vendors fixed the issues by sanitising URLs and using a safe rendering function.

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 takes user input and inserts it into a template that the server then processes. If the input contains template code, the server runs it, which can let an attacker run commands on the server.

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.