Sovra Recon·Glossary · SSTI

SSTI (Server-Side Template Injection): Definition, Detection, and Protection

By Solan Barlet, co-founder of Sovra Recon
Updated October 29, 2026

In short

An SSTI (Server-Side Template Injection) vulnerability occurs when an application inserts user data directly into the template itself of a template engine (Jinja2, Twig, FreeMarker, Velocity, etc.) instead of passing it as a simple variable. The engine then interprets the attacker’s expressions on the server side, which often leads to remote code execution. This can be prevented by never constructing a template from user input.

How it occurs

A template engine assembles a page from a template and data. In normal use, the data is passed as a variable: the engine displays it without interpreting it. The vulnerability arises when the developer concatenates the data into the template text, typically to personalize an email, a welcome message, or a generated document.

The standard detection method involves submitting an expression such as {{7*7}}: if the page displays 49, the input is evaluated. The syntax that works then reveals the engine being used, and each engine has its own known paths to command execution.

How to Protect Against It

  • Always pass user data as template variables, never within the template text itself.
  • If users need to write their own templates (e.g., to customize emails), use a logic-free engine, such as Mustache, or a sandbox mode—keeping in mind that sandboxes have already been bypassed.
  • Execute the rendering in an isolated environment with minimal privileges.

Frequently asked questions

What is the difference between SSTI and XSS?

An XSS is executed in the victim’s browser; an SSTI is executed on the server. An SSTI is often detected in situations where one was expecting an XSS, since the input is displayed on the page, but it is generally much more serious.

Sources

Find out where an attacker would get in.

Our AI agents actually attack your scope, fully automated, and hand you the proof of every vulnerability.