smartworldarafath/rea_skill

payloads-ssti

Template injection allows an attacker to include template code into an existing (or not) template.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/smartworldarafath/rea_skill --skill payloads-ssti

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

SSTI Payloads

Source: PayloadsAllTheThings/Server Side Template Injection Category: payloads-injection | Skill ID: payloads-ssti

Overview

Server-Side Template Injection payloads for Jinja2, Twig, Freemarker, and more.

This skill integrates the full PayloadsAllTheThings (PATT) payload library for the SSTI Payloads domain into the REA_Skill framework. Use it during authorized penetration testing, bug bounty research, security audits, and CTF challenges.

Workflow

1. Recon & Identification

  • Identify the target technology stack and injection points
  • Enumerate endpoints, parameters, and input vectors
  • Determine applicable payload categories from the reference below

2. Payload Selection

  • Browse the PATT payload library for the attack class
  • Select encoding-appropriate payloads for the target environment
  • Consider WAF bypass variants and obfuscation techniques

3. Exploitation (Authorized Only)

  • Test payloads in order: passive → active → escalation
  • Document every payload tested and its response
  • Capture PoC evidence (screenshots, HTTP logs, curl output)

4. Verification & Reporting

  • Confirm the vulnerability with a clean minimal PoC
  • Map findings to CVE/CWE where applicable
  • Report with remediation recommendations and code fixes

Full PATT Reference

Server Side Template Injection

Template injection allows an attacker to include template code into an existing (or not) template. A template engine makes designing HTML pages easier by using static template files which at runtime replaces variables/placeholders with actual values in the HTML pages.

Summary

Tools

  • Hackmanit/TInjA - An efficient SSTI + CSTI scanner which utilizes novel polyglots
bash
  tinja url -u "http://example.com/?name=Kirlia" -H "Authentication: Bearer ey..."
  tinja url -u "http://example.com/" -d "username=Kirlia"  -c "PHPSESSID=ABC123..."
  • epinna/tplmap - Server-Side Template Injection and Code Injection Detection and Exploitation Tool
powershell
  python2.7 ./tplmap.py -u 'http://www.target.com/page?name=John*' --os-shell
  python2.7 ./tplmap.py -u "http://192.168.56.101:3000/ti?user=*&comment=supercomment&link"
  python2.7 ./tplmap.py -u "http://192.168.56.101:3000/ti?user=InjectHere*&comment=A&link" --level 5 -e jade
bash
  python3 ./sstimap.py -u 'https://example.com/page?name=John' -s
  python3 ./sstimap.py -i -u 'https://example.com/page?name=Vulnerable*&message=My_message' -l 5 -e jade
  python3 ./sstimap.py -i -A -m POST -l 5 -H 'Authorization: Basic bG9naW46c2VjcmV0X3Bhc3N3b3Jk'

Methodology

Detection and Exploitation Techniques

Original research:

Rendered

Rendered technique workflow
Rendered technique workflow
Applicability: detection, exploitation

When the rendered template is displayed to the attacker, Rendered technique can be used to include the results of the injected code on the page.

Error-Based

Error-Based technique workflow
Error-Based technique workflow
Applicability: detection, exploitation

When the errors are verbosely displayed to the attacker, Error-Based technique can be used to trigger the error message containing the results of the injected code.

Boolean-Based

Boolean-Based technique workflow
Boolean-Based technique workflow
Applicability: detection, blind exploitation, blind data exfiltration

Boolean-Based technique can be used to conditionally trigger an error to indicate success or failure of the injected code.

Time-Based

Time-Based technique workflow
Time-Based technique workflow
Applicability: limited detection, blind exploitation, blind data exfiltration

Time-Based technique can be used to conditionally trigger the delay to indicate success or failure of the injected code.

Triggering the delay often requires guessing payloads for code evaluation or OS command execution.

Out of Bounds

Applicability: limited detection, exploitation

Out of Bounds technique can be used to expose results of the injected code through other channels (e.g. by connecting to an attacker-controlled server).

This technique often requires guessing payloads for code evaluation or OS command execution.

Polyglot-Based

Polyglot-Based technique workflow
Polyglot-Based technique workflow
Applicability: detection

Polyglot-Based technique can be used to quickly determine the template engine by checking how it transforms different payloads.

Universal Detection Payloads

Polyglot to trigger an error in presence of SSTI vulnerability:

ps1
${{<%[%'"}}%\.

Common tags to test for SSTI with code evaluation:

powershell
{{ ... }}
${ ... }
#{ ... }
<%= ... %>
{ ... }
{{= ... }}
{= ... }
\n= ... \n
*{ ... }
@{ ... }
@( ... )

Rendered SSTI can be checked by using mathematical expressions inside the tags:

powershell
7 * 7

Error-Based SSTI can be checked by using this payload inside the tags:

powershell
(1/0).zxy.zxy

If the error caused by that payload is displayed verbosely, it can be checked to guess the language used for code evaluation:

ErrorLanguage
ZeroDivisionErrorPython
java.lang.ArithmeticExceptionJava
ReferenceErrorNodeJS
TypeErrorNodeJS
Division by zeroPHP
DivisionByZeroErrorPHP
divided by 0Ruby
Arithmetic operation failedFreemarker (Java)

To test for blind injections using Boolean-Based technique, the attacker can test pairs of similar payloads wrapped in tags, where one payload evaluates mathematical expression, while the other triggers syntax error:

testokerror
1(3*4/2)3*)2(/4
2((7*8)/(2*4))7)(*)8)(2/(*4

Using at least two pairs of payloads avoids false positives caused by external interference.

Manual Detection and Exploitation

Identify the Vulnerable Input Field

The attacker first locates an input field, URL parameter, or any user-controllable part of the application that is passed into a server-side template without proper sanitization or escaping.

For example, the attacker might identify a web form, search bar, or template preview functionality that seems to return results based on dynamic user input.

TIP: Generated PDF files, invoices and emails usually use a template.

Inject Template Syntax

The attacker tests the identified input field by injecting template syntax specific to the template engine in use. Different web frameworks use different template engines (e.g., Jinja2 for Python, Twig for PHP, or FreeMarker for Java).

Common template expressions:

  • {{7*7}} for Jinja2 (Python).
  • #{7*7} for Thymeleaf (Java).

Find more template expressions in the page dedicated to the technology (PHP, Python, etc).

SSTI cheatsheet workflow
SSTI cheatsheet workflow

In most cases, this polyglot payload will trigger an error in presence of a SSTI vulnerability:

ps1
${{<%[%'"}}%\.

The Hackmanit/Template Injection Table is an interactive table containing the most efficient template injection polyglots along with the expected responses of the 44 most important template engines.

Enumerate the Template Engine

Based on the successful response, the attacker determines which template engine is being used. This step is critical because different template engines have different syntax, features, and potential for exploitation. The attacker may try different payloads to see which one executes, thereby identifying the engine.

  • Python: Django, Jinja2, Mako, ...
  • Java: Freemarker, Jinjava, Velocity, ...
  • Ruby: ERB, Slim, ...

The post "template-engines-injection-101" from @0xAwali summarize the syntax and detection method for most of the template engines for JavaScript, Python, Ruby, Java and PHP and how to differentiate between engines that use the same syntax.

Escalate to Code Execution

Once the template engine is identified, the attacker injects more complex expressions, aiming to execute server-side commands or arbitrary code.

Labs

References


REA MCP Integration

javascript
// REA MCP — Automated payload injection via REA tools
// Use analyze_function, procedure_pseudo_code, or observe_native_calls
// to identify injection sinks, then apply payloads from this skill.

Legal Notice

⚠️ Authorized Use Only. All payloads in this skill are for security research, penetration testing with written permission, CTF competitions, and defensive study. Unauthorized use against systems you do not own or have explicit permission to test is illegal.
같은 저장소의 Skills

더 많은 Skills

모든 Skills
smartworldarafath
커뮤니티

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

1시간 설치 수
2
GitHub Stars
5
업데이트
11월 8일
smartworldarafath
커뮤니티

agent-reach

Read-only access to internet platforms (Twitter/X, Reddit, YouTube subtitles, GitHub, LinkedIn, Bilibili, web). Use when the agent needs to search, read web links, retrieve social discussions, CVE/vulnerability intel, or when standard web search/fetch is blocked or insufficient.

1시간 설치 수
2
GitHub Stars
5
업데이트
11월 8일
smartworldarafath
커뮤니티

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

1시간 설치 수
2
GitHub Stars
5
업데이트
11월 8일
smartworldarafath
커뮤니티

anti-ai-slop-writing

Produces human-sounding text that avoids detectable AI writing patterns. Activates on any writing task — tweets, emails, articles, bios, captions, reports, copy, messages, LinkedIn posts, cover letters, README files, or any content where the output must not read as AI-generated. Enforces banned vocabulary, structural variety, punctuation discipline, accuracy rules, and voice calibration. Use when the user says "write," "draft," "rewrite," "make this sound human," "anti-slop," "not AI," or any va

1시간 설치 수
2
GitHub Stars
5
업데이트
11월 8일