← all rules

code/js-xss-innerhtml

XSS: innerHTML assigned from a variable

highCode regexxssCWE-79js

What it detects

Setting .innerHTML with a non-literal string allows script injection. Use textContent or a sanitizer (DOMPurify).

How it runs

Applied line-by-line via a tagged regex with language-specific gating. Comments are skipped. Designed for high-confidence patterns where AST parsing would be overkill.

Found a false positive or want this rule tuned? File an issue. You can also suppress per-repo via a .repoguardignore line.