exploiting-template-injection-vulnerabilities

Detects and exploits server-side template injection across Jinja2, Twig, Freemarker, and other engines to achieve remote code execution.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill exploiting-template-injection-vulnerabilities
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: exploiting-template-injection-vulnerabilities
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/web-application-security/exploiting-template-injection-vulnerabilities
Command: npx skills add https://github.com/xalgord/xalgorix --skill exploiting-template-injection-vulnerabilities

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tplmap, sstimap.

What problem does it solve?

During authorized penetration tests, template injection flaws are easy to miss or misidentify: reflected input looks like SSTI but isn't, and each template engine requires different payloads. This Skill provides a systematic workflow to confirm true server-side evaluation, fingerprint the exact engine, and escalate to remote code execution with engine-specific payloads.

Core Features & Use Cases

  • Detection and Confirmation: Uses arithmetic probes ({{77}}, ${77}, #{7*7}) and divergence tests to distinguish real SSTI from plain reflection and avoid false negatives across all delimiter sets, polyglots, and blind/OOB scenarios.
  • Engine Fingerprinting and Exploitation: Identifies Jinja2, Twig, Freemarker, Velocity, Smarty, ERB, and Pebble, then applies engine-specific RCE and file-read payloads, plus automation via tplmap and SSTImap.
  • Use Case: While testing a Flask app's email template feature, you inject {{7*'7'}}, observe 7777777 confirming Jinja2, then use subclass traversal to read the Flask SECRET_KEY and execute commands as www-data, documenting a Critical finding with reproduction steps.

Quick Start

Test the name parameter on the target page for server-side template injection and, if confirmed, fingerprint the engine and demonstrate remote code execution.

Frequently Asked Questions about exploiting-template-injection-vulnerabilities

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect server-side template injection in a web application?

Inject arithmetic expressions like {{7*7}}, ${7*7}, #{7*7}, and <%= 7*7 %> into user-controlled parameters and check whether the response contains the computed result 49. A computed value proves server-side evaluation, while a literal reflection of 7*7 means no template execution at that syntax.

How to identify which template engine is vulnerable to SSTI?

Use the divergence test: {{7*'7'}} returns 7777777 on Jinja2 but 49 on Twig, while ${7*7} evaluating indicates Freemarker or Velocity and #{7*7} indicates Thymeleaf or Ruby. Engine-specific RCE payloads only work after correct fingerprinting, and tplmap can automate detection.

What is the difference between SSTI and reflected XSS?

SSTI executes template directives on the server, proven when an expression like {{7*7}} renders as the computed value 49 rather than echoed text. Reflected XSS only echoes input back to the browser without server-side evaluation, so it cannot reach server objects or achieve server-side code execution.

Can SSTI be exploited when no output is reflected in the response?

Yes, blind SSTI uses out-of-band techniques such as an OOB payload that triggers the server to make a request to an attacker-controlled host, for example via os.popen with curl. Also test asynchronous sinks like email templates, PDF generators, and error pages that render input later.

What tools automate SSTI detection and exploitation?

tplmap and SSTImap automate detection, engine identification, OS command execution, and file download for SSTI vulnerabilities. Burp Suite Intruder with SSTI payload lists and grep matching on indicators like 49 or error messages supports manual fuzzing workflows.

Why does my SSTI payload get blocked by the WAF?

WAFs often strip common delimiters like {{ but may miss {% or URL-encoded braces, so test both raw and encoded payload variants. A polyglot string can also reveal the engine through partial rendering or error messages when standard delimiters are filtered.