Injection
Keep data and code apart. Untrusted input must never become part of a query, a page, a shell command, a template or a header.
- Required 8
Required
Use parameterised queries
RequiredSend every database query with placeholders, and pass user input as separate values. Never build a query by joining strings.
Escape everything you show
RequiredEscape untrusted text for the place it lands in a page, and back it up with a strict Content Security Policy.
Never pass input to a shell
RequiredRun other programs without a shell, with input as separate arguments. Better still, use a library instead of a program.
Keep input out of templates
RequiredPass user input to a template as data. Never use it as the template itself.
Strip line breaks from headers and logs
RequiredRemove or reject line breaks in any input that goes into a header, a redirect, an email header or a log line.
Turn off external entities in XML
RequiredParse XML with external entities and document types turned off, or accept JSON instead.
Never rebuild objects from untrusted data
RequiredRead untrusted data only as plain data, such as JSON. Never use formats that can rebuild code objects.
Block prototype pollution
RequiredIn JavaScript, never merge or copy untrusted objects in a way that lets keys such as
__proto__change every object in the app.
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.