Definition

Template injection is a security vulnerability that occurs when attackers inject malicious code into a web application template. Many modern web frameworks use templates to isolate the presentation logic from the application’s business logic.

A hacker can compromise a user-supplied input to insert malicious code into a template, which the server-side rendering engine executes.

Developers use templates to generate dynamic content and define reusable layouts. Failure to properly validate user input before inserting it into the template enables hackers to compromise it through template injection.

How Template Injection Works

Dangers of Template Injection