← all rules

code/js-xss-document-write

XSS: document.write called with a variable

highCode regexxssCWE-79js

What it detects

document.write with untrusted data injects script into the page. Avoid entirely in modern code.

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.