A template engine is configured not to escape HTML, so values inserted into pages can inject markup

tx0/ts:template-autoescape-offrecommendedwarningsecurity/xssdepth fastsecurity

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.

Example from the rule's tests
declare const nunjucks: any;nunjucks.configure("views", { autoescape: false });tx0 reports: this template engine inserts values without escaping HTMLnunjucks.configure("views", { autoescape: true });
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

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.