This vulnerability occurs when an application uses a template engine to process user-controlled input but fails to properly sanitize special syntax characters. Attackers can inject template expressions or directives that the engine executes, leading to unintended code execution.
Modern web applications frequently use template engines like Twig, Jinja2, FreeMarker, or Pug to dynamically generate content. These engines have their own syntax for expressions and commands. If user input containing this syntax isn't neutralized before processing, attackers can inject malicious template code—potentially accessing sensitive data, modifying application logic, or taking control of the rendering process. This vulnerability affects both server-side and client-side template engines, though attack methods differ. While sometimes manifesting as Cross-Site Scripting (XSS), the root cause is template injection rather than HTML injection. Developers should validate and sanitize all external inputs before passing them to template engines, treating template syntax as potentially dangerous code rather than plain text.
Impact: Execute Unauthorized Code or Commands