Cross-Site Scripting (XSS)
Scans frontend code for dangerous DOM manipulations where user-controlled input reaches execution sinks. See patterns.yaml for detection rules.
Detection Workflow
- Identify sources — URL parameters (
location.search,location.hash), form inputs,postMessagedata - Trace to sinks —
innerHTML,outerHTML,document.write(),eval(),setTimeout(string) - Check sanitization — verify DOMPurify or equivalent sits between source and sink
- Report — file, line, sink type, source, and suggested fix
Vulnerable
element.innerHTML = userInput;
document.write(location.search);
Safe
element.textContent = userInput;
element.innerHTML = DOMPurify.sanitize(userInput);