Agent Wranglers

Injection Required

Keep input out of templates

Pass user input to a template as data. Never use it as the template itself.

How to do it

Load templates only from your own files. If customers write their own text, such as email messages, use a small placeholder list like {name} and replace only those. Run full template engines only in a sandbox.

How to check

Put {{7*7}}, #{7*7} and <%= 7*7 %> in fields that end up in emails, PDFs or pages. The output shows the text as typed, never 49.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers security testing playbook: https://agentwranglers.se/playbook/adversarial-testing/injection/template-injection.