A template engine is configured not to escape HTML, so values inserted into pages can inject markup
What it finds
Template engines escape the values they insert, so that text from users cannot add tags or scripts to the page. Turning escaping off for a whole engine makes every template a place for cross-site scripting.
Reported are Handlebars.compile with noEscape: true, nunjucks.configure and new nunjucks.Environment with autoescape: false, swig.setDefaults with autoescape: false, and assignments of a function to Mustache.escape.
From the rule's source, template_autoescape_off.rs.
declare const nunjucks: any;nunjucks.configure("views", { autoescape: false });tx0 reports: this template engine inserts values without escaping HTMLnunjucks.configure("views", { autoescape: true }); Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:template-autoescape-off" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:template-autoescape-off] reason="..."tx0 explain tx0/ts:template-autoescape-off shows the same in the terminal. Found a false positive? Report it.