Back to blog
ReacttechnicalXSS

React dangerouslySetInnerHTML: your components are open doors to XSS

Published on 2026-03-155 min readFlorian

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.

Related articles

Three adjacent analyses to keep exploring the same attack surface.

Sources

Written by Florian
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