detect-disable-mustache-escape

Try in Playground
javascript-security

oscar143

SecurityWarning

0

No tags

No CWE or CVE

security/detect-disable-mustache-escape

Detects "object.escapeMarkup = false", which can be used with some template engines to disable escaping of HTML entities

This can lead to Cross-Site Scripting (XSS) vulnerabilities.

More information: OWASP XSS

Ast Rule: assignment


detect-disable-mustache-escape

How to write a rule
function visit(node, filename, code) {
	if (
		node?.left?.parent &&
		node?.left?.name?.value === "escapeMarkup" &&
		node?.right?.value === "false"
	) {
		addError(buildError(
			node.start.line,
			node.start.col,
			node.end.line,
			node.end.col,
			`Markup escaping disabled.`,
			"WARNING",
			"SECURITY",
		));
	}
}

good.js

Expected test result: no error

escapeMarkup = false;
a.escapeMarkup = true;

bad.js

Expected test result: has error


a.escapeMarkup = false;
Add comment

Log in to add a comment


    Be the first one to leave a comment!

Codiga Logo
Codiga Hub
  • Rulesets
  • Playground
  • Snippets
  • Cookbooks
Legal
  • Security
  • Privacy Policy
  • Code Privacy
  • Terms of Service
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.