Knowledge Base · general

SSTI

generaltechnique notetechniquessti

Server-Side Template Injection: user input is concatenated into a server-side template (Jinja2, Twig, Freemarker) and evaluated, often reaching RCE.

How it works

  • Probe with {{7*7}} / ${7*7} and watch for 49 in the response.
  • Jinja2 chains: {{config}}, {{''.__class__.__mro__}}, {{ cycler.__init__.__globals__.os.popen('id').read() }}.
  • Reflection into a template is enough — no need for a full file write.

Detection & defence

  • Never build templates from user input; pass data as context variables.
  • Use a sandboxed template environment as defence in depth.