XSS in innerHTML and dangerouslySetInnerHTML
XSS in innerHTML and dangerouslySetInnerHTML If you render attacker-controlled HTML, you are one bad string away from XSS. Two APIs show up constantly in real apps: the browser DOM API: element.innerHTML the React escape hatch: dangerouslySetInnerHTML Both do the same dangerous thing: they parse a string as HTML and inject it into the page. If that string contains active content, your app can execute attacker-supplied JavaScript. This is the reference I wish more teams had pinned in their repos. ...