Server-Side Template Injection in Popular Web Frameworks
Summary: SSTI vulnerabilities continue to appear in applications using Jinja2, Twig, Smarty, and Velocity without proper input isolation between user-supplied data and template rendering context.
Technical detail
When user-supplied input is concatenated directly into template strings rather than passed as isolated context variables, attackers can inject template syntax that executes on the server. In Python/Flask applications using Jinja2, payload patterns like {{7*7}} confirm vulnerability and chains like {{config.__class__.__init__.__globals__}} can lead to remote code execution. The same class of vulnerability exists across Twig (PHP), Smarty, Pebble (Java), and Velocity.
Affected patterns
- Jinja2 / Flask / Django (user input in template strings)
- Twig (PHP applications)
- Smarty (PHP CMS platforms)
- Pebble / Velocity (Java applications)
Remediation
Pass user data as context variables, never concatenate into template strings. Use sandboxed template environments where available. Apply input allowlisting for fields that interact with template logic.