High severityJavaScript / TypeScriptCross-Site Scripting (XSS)HIGH confidence
React Dangerously Set Inner HTML
dangerouslySetInnerHTML is populated from a dynamic value, which renders unescaped HTML and can lead to XSS.
Standards mapping
- OWASP Top 10
- A03:2021 - Injection
- OWASP ASVS
- V5.3.3 (L1)
Vulnerable vs. safe
Flagged by this check
return <div dangerouslySetInnerHTML={{ __html: userHtml }} />;Passes - the safe pattern
return <div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(userHtml) }} />;Why it matters & how to fix it
dangerouslySetInnerHTML is populated from a dynamic value, which renders unescaped HTML and can lead to XSS. Sanitize the markup with DOMPurify before assigning, or render as text instead.
References
Rule ID integsec-react-dangerously-set-inner-html - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Cross-Site Scripting (XSS)DOM XSS Innerhtml Sink
- JavaScript / TypeScript - Cross-Site Scripting (XSS)Reflected XSS Response Tainted Input
- Go - Cross-Site Scripting (XSS)Text Template For HTML
- Go - Cross-Site Scripting (XSS)XSS Response Write
- Go - Cross-Site Scripting (XSS)XSS Template HTML Bypass
- Ruby - Cross-Site Scripting (XSS)XSS HTML Safe Interpolation