Skip to content

Fix: Unsafe HTML Rendering with dangerouslySetInnerHTML #7976#7978

Closed
rahul-kr-rai wants to merge 4 commits into
webpack:mainfrom
rahul-kr-rai:security-bug
Closed

Fix: Unsafe HTML Rendering with dangerouslySetInnerHTML #7976#7978
rahul-kr-rai wants to merge 4 commits into
webpack:mainfrom
rahul-kr-rai:security-bug

Conversation

@rahul-kr-rai
Copy link
Copy Markdown
Contributor

Summary

Issue Closes: #7976

This PR addresses a critical security vulnerability by fixing unsafe usage of dangerouslySetInnerHTML in three components. The changes eliminate potential XSS risks by either sanitizing HTML content or replacing dangerous patterns with safe React's declarative approach with useEffect

What kind of change does this PR introduce?

Security Fix: Removes potential XSS vulnerabilities by sanitizing HTML content and eliminating unsafe HTML injection patterns.
Code Refactor: Converts class-based components to functional components where appropriate, improving maintainability.
Dependency Addition: Adds dompurify as a new dependency for HTML sanitization.

Did you add tests for your changes?
Verify it,

Does this PR introduce a breaking change?
No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI
Yes, to increase productivity by following the AI policy.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Mar 11, 2026 7:23pm

Request Review

@alexander-akait
Copy link
Copy Markdown
Member

tests are broken, please take a look

…s and Added null safety check for SVG rendering in SplashViz.jsx
@rahul-kr-rai
Copy link
Copy Markdown
Contributor Author

cypress test are failing, I will fix it as soon as possible.

@rahul-kr-rai
Copy link
Copy Markdown
Contributor Author

I tried to solve the Cypress error, but I was unable to do,

Approach taken

  • Reverted all recent changes
  • Pulled the latest updates from my main branch
  • Run the tests using yarn cypress:run

Please suggest any alternative approach that helps me to fix this error

image

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need it? We pass into dangerouslySetInnerHTML only safe content, it will decrease performance and nothing more

@rahul-kr-rai
Copy link
Copy Markdown
Contributor Author

Then what to do? Close the PR and issue or do any changes. Please suggest which is best.

@alexander-akait
Copy link
Copy Markdown
Member

I think we don't need it at all, we only lost performance here

@rahul-kr-rai
Copy link
Copy Markdown
Contributor Author

As per your suggestion I am closing this PR as well as issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsafe HTML Rendering with dangerouslySetInnerHTML

2 participants