appsec.fyi

SSTI — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

SSTI: A Practical Guide

Curated and synthesized by . Last updated 2026-07-01. Synthesized from 98 of 98 curated resources. Browse all 98 SSTI resources →

Problem Framing

Server-Side Template Injection (SSTI) is a critical web security vulnerability that allows an attacker to inject malicious code into a server-side template, leading to arbitrary code execution on the server. This can range from information disclosure to complete system compromise. Template engines are ubiquitous in modern web development for rendering dynamic content, making them a frequent target for attackers [1][2][3][4][5][6]. The core of SSTI lies in the improper handling of user-controlled input within these templating systems, where data is mistakenly interpreted as executable code rather than plain text. This often occurs when developers directly concatenate user input into template strings without adequate sanitization, validation, or isolation [7][8][3][9][5][10][6]. Unlike Cross-Site Scripting (XSS), which targets the client's browser, SSTI directly attacks the server, posing a more severe threat [7][3].

Core Mechanics

At its heart, SSTI exploits the intended functionality of template engines: to dynamically generate content by evaluating expressions and variables within a template. When user input bypasses the intended data-handling mechanisms and is instead processed as part of the template's executable logic, the vulnerability arises [7][8][3][4][5][10][6]. This typically involves injecting specially crafted strings that leverage the template engine's syntax to execute arbitrary code or access sensitive system resources.

The process generally follows these stages:

The danger of SSTI is amplified by the fact that many template engines offer powerful features, including access to reflection APIs, file system operations, and direct OS command execution, often designed for legitimate templating tasks but exploitable by attackers [2][3][10][6].

Notable Techniques

The exploitation of SSTI vulnerabilities is highly dependent on the specific template engine and the surrounding application logic. However, several common techniques and patterns emerge across different environments:

Accessing and Chaining Objects

A cornerstone of SSTI exploitation involves navigating the object model provided by the programming language and template engine to reach sensitive functions or classes. In Python environments leveraging Jinja2, this often involves accessing built-in types like str or dict and then traversing their Method Resolution Order (__mro__) and subclasses (__subclasses__) to find exploitable classes like _io.FileIO for file operations or classes within subprocess or os for command execution [3][9][15][10][16][13][14].

For instance, a common Jinja2 RCE payload might look like:

{{ ''.__class__.__mro__[1].__subclasses__()[40]('/etc/passwd').read() }}
[3]

This payload leverages the str object (''), its class (__class__), its method resolution order to get to the base object class (__mro__[1]), then lists its subclasses (__subclasses__) to find the FileIO class (often at index 40 in older Python versions, though this can vary) to read /etc/passwd.

Similarly, in Java applications using FreeMarker, attackers can leverage classes like freemarker.template.utility.Execute or freemarker.template.ObjectWrapper to achieve RCE [7][17][10][18][19]. A typical FreeMarker RCE payload often involves instantiating the Execute class:

${"freemarker.template.utility.Execute"?new()("id")}
[7][10]

Sandbox Escapes

Many template engines implement sandboxing mechanisms or rely on secure configurations to limit the scope of available functions and objects. Bypassing these sandboxes is a critical technique for achieving RCE.

Blind SSTI

In scenarios where template output is not directly visible, attackers can use blind SSTI techniques. These rely on inducing observable side effects, such as time delays (via sleep commands) or DNS lookups to an attacker-controlled server, to confirm vulnerability and exfiltrate data [31][32][12][6].

Leveraging Specific Objects and Methods

Filter Bypasses

Attackers often encounter blacklists designed to prevent common SSTI payloads. Bypassing these filters is crucial. Techniques include:

Detection and Prevention

Detecting and preventing SSTI requires a multi-faceted approach, combining secure coding practices, diligent input validation, and robust security testing.

Detection Strategies

Prevention Strategies

Tooling

Several tools are instrumental in detecting, identifying, and exploiting SSTI vulnerabilities:

Recent Developments

The landscape of SSTI vulnerabilities is continually evolving, with new research uncovering novel bypasses, engine-specific exploits, and high-profile CVEs.

Where to Go Deeper

For those looking to expand their knowledge of Server-Side Template Injection, the following resources provide in-depth analysis, practical examples, and hands-on learning opportunities:

Sources cited in this guide

  1. SSTI: Explanation, Discovery, Exploitation, and Prevention — akto.io
  2. A Survey of the Overlooked Dangers of Template Engines (arXiv 2024) — arxiv.org
  3. What is SSTI in Flask/Jinja2? — Payatu — payatu.com
  4. Find and Exploit Server-Side Template Injection — TCM Security — tcm-sec.com
  5. What is Server-Side Template Injection? (Indusface) — indusface.com
  6. Server-side template injection | Web Security Academy — portswigger.net
  7. SSTI: Breaking Out of Templates — kayssel.com
  8. Inj3ctlab — SSTI Bug Bounty Labs Writeup — len4m.github.io
  9. SSTI (The Hacker Recipes) — thehacker.recipes
  10. SSTI Explained with Real Code Examples - Xygeni — xygeni.io
  11. A Pentester's Guide to SSTI - Cobalt — cobalt.io
  12. OWASP Testing for Server Side Template Injection — owasp.org
  13. HackTricks: Jinja2 SSTI — book.hacktricks.xyz
  14. Exploiting server-side template injection vulnerabilities — portswigger.net
  15. A Simple Flask (Jinja2) SSTI Example (Kleiber) — kleiber.me
  16. Flask & Jinja2 SSTI cheatsheet — pequalsnp-team.github.io
  17. Exploiting CVE-2021-25770: SSTI in YouTrack (Synacktiv) — synacktiv.com
  18. Synack: Discovering an SSTI vulnerability in FreeMarker — synack.com
  19. PayloadsAllTheThings SSTI: Java — github.com
  20. Jinja2 template injection filter bypasses (0day.work) — 0day.work
  21. OnSecurity: Server Side Template Injection with Jinja2 — onsecurity.io
  22. Jinja2/Flask SSTI Filter bypass (MRLSECURITY) — mrlsecurity.com
  23. Grav CMS Twig SSTI Authenticated Sandbox Bypass RCE — rapid7.com
  24. Grav CMS: Security Sandbox Bypass with SSTI — github.com
  25. Grav CMS: RCE via SSTI through Twig Sandbox Bypass — github.com
  26. Grav: SSTI via Twig escape handler advisory — github.com
  27. Server-Side Template Injection | PortSwigger Research — portswigger.net
  28. Don't Panic: The Thymeleaf Template Injection That Only Hurts If You Let It (CVE-2026-40478) — snyk.io
  29. Exploiting SSTI in Thymeleaf — acunetix.com
  30. Exploiting SSTI in a Modern Spring Boot Application — modzero.com
  31. PayloadsAllTheThings — SSTI README — github.com
  32. SSTI: Transforming Web Apps from Assets to Liabilities — research.checkpoint.com
  33. CVE-2021-43466: Thymeleaf Spring5 RCE — security.snyk.io
  34. SpringBootAdmin Thymeleaf SSTI to RCE — github.com
  35. Ruby ERB Template Injection (TrustedSec) — trustedsec.com
  36. PayloadsAllTheThings: SSTI Ruby payloads — github.com
  37. ruby-ssti: example Ruby ERB app vulnerable to SSTI — github.com
  38. Method Confusion in Go SSTIs Lead to RCE — onsecurity.io
  39. Exploiting SSTI in Golang Frameworks — payatu.com
  40. Golang SSTI: Safe by Default or Vulnerable by Design — oligo.security
  41. ServiceNow RCE Exploitation Campaign — resecurity.com
  42. ServiceNow RCE (CVE-2024-4879) Analysis — cyfirma.com
  43. CVE-2025-23211: Jinja2 SSTI Turns Recipes Into RCE — vsec.com.br
  44. YesWeHack: Limitations are just an illusion — advanced SSTI exploitation with RCE everywhere — yeswehack.com
  45. Server Side Template Injection - Payloads All The Things — swisskyrepo.github.io
  46. Handlebars.js: Safe Usage to Avoid Injection Flaws — xygeni.io
  47. tplmap-python3: Python3 port (GitHub) — github.com
  48. Tplmap - Tool For Automatic SSTI Exploitation (GeeksforGeeks) — geeksforgeeks.org
  49. vladko312/SSTImap: Automatic SSTI detection tool with interactive interface — github.com
  50. epinna/tplmap: SSTI and Code Injection Detection and Exploitation Tool — github.com
  51. Server-side template injection PortSwigger KB — portswigger.net
  52. Practical Exploitation of SSTI in Flask with Jinja2 — karczewski.io
  53. Template Injection Research | PortSwigger Research — portswigger.net
  54. OpenMetadata: FreeMarker SSTI in email templates leads to RCE — github.com
  55. PayloadsAllTheThings - SSTI JavaScript engines — github.com
  56. PayloadsAllTheThings: Server Side Template Injection — github.com
  57. SSTI - Server-side template injection with a custom exploit (Scott Murray) — sc.scomurr.com
  58. Jinja2 SSTI filter bypasses — medium.com
  59. Multiple ServiceNow SSTI Vulnerabilities — censys.com
  60. Strapi Security Disclosure: Multi-CVE SSTI chain — strapi.io
  61. GitHub Security Lab: SSTI in Apache Camel — CVE-2020-11994 — securitylab.github.com
  62. HackTricks: SSTI (Server Side Template Injection) — book.hacktricks.xyz
  63. SSTI: RCE for the Modern Web App - Black Hat 2015 — blackhat.com
  64. SSTI in Bug Bounty: Playing with Handlebars and Breaking Stuff — medium.com
  65. Server-Side Template Injection — Bug Bounty 2k25 — medium.com
  66. SSTI in Flask/Jinja2 (IndominusByte) — medium.com
  67. Lab: SSTI in an unknown language with documented exploit — medium.com
  68. Bug Bytes #124: SSTI to RCE in Go apps (Intigriti) — blog.intigriti.com
  69. Mastering SSTI Exploitation: Executing Commands in Popular Templating Engines — medium.com
  70. SSTI: Advanced Exploitation Techniques (BootstrapSecurity) — medium.com
  71. picoCTF 2025: SSTI2 Exploitation Writeup — medium.com
  72. picoCTF 2025: SSTI Challenge Writeup — medium.com
  73. Deep Dive into SSTI: Finding and Exploiting Like a Pro — infosecwriteups.com
  74. Handlebars template injection and RCE in Shopify app — mahmoudsec.blogspot.com
  75. SSTI: Advanced Exploitation Guide - Intigriti — intigriti.com
  76. Exploiting Jinja SSTI with limited payload size — niebardzo.github.io
  77. RCE via SSTI in Fides Jinja Email Templates — github.com
  78. SSTI in Jinja2 allows RCE (changedetection.io) — github.com
  79. CVE-2025-23211: Tandoor Recipes Jinja2 SSTI to RCE — offsec.com
  80. GoSecure: Template Injection in Action workshop — gosecure.github.io
  81. Breaking the Barrier: RCE via SSTI in FreeMarker — medium.com
  82. CVE-2026-33154: Dynaconf RCE via Insecure Jinja Template Evaluation — advisories.gitlab.com
  83. CVE-2026-27641: Flask-Reuploaded Path Traversal Enabling SSTI RCE — github.com
  84. CVE-2022-46166: Spring Boot Admin RCE — sangfor.com
  85. CVE-2024-29178: Apache StreamPark FreeMarker SSTI — openwall.com
  86. CVE-2023-49964: FreeMarker SSTI in Alfresco — github.com
📚 This guide is synthesized from the full text of resources curated in the SSTI library, and refreshed as new material is added.