Raw HTML
Raw HTML. Inserts raw HTML (.innerHTML =). If any of it comes from a user, that's XSS.
This is how the comment reads inline, under the flagged line.
Why it matters
Raw HTML bypasses the framework's escaping. One unescaped field is enough to run script in your users' sessions.
What to do
Render text, or sanitize with a vetted library (DOMPurify) right at this spot.
Examples
<div dangerouslySetInnerHTML={{ __html: comment.body }} /><div>{comment.body}</div>What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python, Markdown, JSON and text. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
el.innerHTML = html;
<div dangerouslySetInnerHTML={{ __html: x }} />Left alone
el.textContent = text;
Research
Raw HTML sinks (`innerHTML`, `dangerouslySetInnerHTML`) and `target="_blank"` without `rel`. Untrusted strings run as script, and an opened page can redirect yours.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"html-injection"
],
"severity": {
"html-injection": "low"
}
}
}