Back to blog
ReacttechnicalXSS

React dangerouslySetInnerHTML: your components are open doors to XSS

Published on 2026-03-155 min readCleanIssue

> TL;DR: Using dangerouslySetInnerHTML without sanitization exposes your app to XSS.

The CMS content trap

When your React app displays HTML from a CMS, you probably use dangerouslySetInnerHTML. The name is a warning.

The risk

Malicious JavaScript in injected content executes in the user's browser. Cookie theft, phishing redirect, data exfiltration.

The solution: DOMPurify

dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(content) }}

What we find

40% of React apps we audit use dangerouslySetInnerHTML without sanitization.

Key Takeaways

  • Identify and test your exposed attack surfaces before a third party does.
  • Client-side security controls never replace server-side validation.
  • Regular audits are more effective than one-time checks — vulnerabilities appear with every deployment.
  • Building HR, payroll, or recruiting software? CleanIssue performs security audits for HR SaaS in real-world conditions, no source code access needed. For a first read of your exposure, start with an external review of your application.

    Sources

    Written by CleanIssue
    Reviewed on 2026-03-15

    Editorial analysis based on official vendor, project, and regulator documentation.

    Related services

    If this topic maps to a real risk in your stack, these are the most relevant CleanIssue audits.

    Need an external review of your HR SaaS?

    Share your product, stack, and client context. We will come back with the right review scope.

    Discuss your audit