Cross-site Scripting (XSS)
Improper Neutralization of Input During Web Page Generation (Cross-site Scripting)
CWE-79 · High severity · Updated November 6, 2026
What it is
CWE-79 covers all variants of cross-site scripting: reflected, stored, and DOM-based. The weakness exists when a web application embeds user-controlled input into a page without proper neutralization. An attacker who controls the input can inject script that executes in the victim's browser session.
Why it matters
XSS remains in the OWASP Top 10 and is a fixture of the CWE Top 25. Successful exploitation lets an attacker steal session cookies, log keystrokes, render fake login forms inside a trusted origin, and pivot toward CSRF and account takeover. Modern frameworks (React, Angular, Vue) escape by default, but XSS resurfaces whenever developers reach for dangerouslySetInnerHTML, v-html, or [innerHTML] without sanitization.
Common patterns
- Rendering req.query.q directly into HTML without escaping.
- Using dangerouslySetInnerHTML in React with un-sanitized content from a CMS or user post.
- Concatenating user input into template strings that drive innerHTML or document.write.
- Reflecting headers, cookies, or URL fragments into the DOM after a navigation event.
- Stored XSS via comment systems, profile bios, or chat messages that render Markdown without an allowlist.
Languages affected
JavaScript, TypeScript, Python, Ruby, Java, Go, PHP
What Deva detects
Deva's taint-mode rules track data from user-controlled sources through to DOM sinks such as innerHTML, dangerouslySetInnerHTML, and document.write. Each rule carries a confidence value. On Pro, an optional AI validation step can then triage a finding as likely real or a probable false positive.
Example
Vulnerable
app.get('/search', (req, res) => {
res.send(`<h1>Results for: ${req.query.q}</h1>`)
})Fixed
import escapeHtml from 'escape-html'
app.get('/search', (req, res) => {
res.send(`<h1>Results for: ${escapeHtml(req.query.q)}</h1>`)
})The vulnerable version reflects req.query.q directly into HTML. An attacker who gets a victim to open /search?q=<script>alert(document.cookie)</script> runs script in the victim's session. The fix runs the input through escape-html before reflection. For richer HTML allowed in user content (Markdown comments, rich bios), use DOMPurify or sanitize-html with a strict allowlist.
Where this fits in OWASP Top 10
- A05 InjectionUntrusted input interpreted as code or commands by a downstream interpreter.
Compliance framework references
These references explain how the weakness relates to control topics. They do not mean Deva offers evaluation for every framework listed. CMMC evaluation and SPRS scoring are currently unavailable. See the FAQ for offered frameworks and preview status. Deva provides code-level evidence for your assessment, without certifying compliance.
| Framework | Controls |
|---|---|
| OWASP Top 10:2025 | A05:2025 Injection |
| NIST 800-53 Rev 5 | SI-10 Information Input Validation |
| PCI-DSS v4.0.1 | 6.2.4 Software engineering techniques |
| HIPAA Security Rule | 164.312(c)(1) Integrity controls |