-
-
Notifications
You must be signed in to change notification settings - Fork 956
Open
Labels
bugSomething isn't workingSomething isn't working💻 aspect: codeConcerns the software code in the repositoryConcerns the software code in the repository🚦status: awaiting triageHas not been triaged & therefore, not ready for workHas not been triaged & therefore, not ready for work🛠 goal: fixBug fixBug fix
Description
Contributor Guidelines
- I have read the guidelines and discussion
Descrcibe the bug?
Multiple components use dangerouslySetInnerHTML or direct .innerHTML assignment to render content without sanitization. The project already has dompurify as a dependency but it's not used in these files. This creates cross-site scripting (XSS) attack vectors where malicious scripts could be injected.
Steps to reproduce the bug?
#Affected files
src/plays/markdown-editor/Output.jsx:7— renders user-generated markdown without sanitizationsrc/plays/fun-quiz/QuizScreen.jsx:152,160— renders quiz content unsanitizedsrc/plays/fun-quiz/EndScreen.jsx:18,23,28— renders end screen content unsanitizedsrc/plays/text-to-speech/TextToSpeech.jsx:163— renders user text unsanitizedsrc/plays/devblog/Pages/Article.jsx:53— renders article content unsanitizedsrc/common/badges-dashboard/BadgeDetails.jsx:12— renders badge HTML unsanitizedsrc/common/Testimonial/TestimonialCard.jsx:59— renders testimonial unsanitizedsrc/plays/Selection-Sort-Visualizer/SelectionSortVisualizer.js:26— direct.innerHTMLDOM manipulation
What needs to be done:
- Wrap all
dangerouslySetInnerHTMLcontent withDOMPurify.sanitize()before rendering - Replace direct
.innerHTMLassignments with React-safe alternatives or sanitized content - Add ESLint rule
react/no-dangeras a warning to catch future occurrences - Create a shared utility function (e.g.,
sanitizeHTML()) insrc/common/utils/for consistency
Expected behavior
- All user-generated or dynamic HTML content should be sanitized before rendering to prevent XSS attacks.
- Components must use
DOMPurify.sanitize()wheneverdangerouslySetInnerHTMLis required. - Direct
.innerHTMLDOM manipulation should be avoided or replaced with sanitized and React-safe rendering methods. - A shared utility function (e.g.,
sanitizeHTML()) should be used across the project to ensure consistent sanitization. - ESLint should warn developers about unsafe HTML rendering using the
react/no-dangerrule. - The application should safely display markdown, quiz content, articles, testimonials, badges, and user text without executing malicious scripts.
Desktop (Please provide your system information)
Windows
Mobile (Please provide your device information)
No response
Screenshot / Screenshare
No response
Relevant log output
No response
Record
- I have checked the existing issues
- I have read the Contributing Guidelines
- I want to work on this issue
- I am a Hacktoberfest contributor
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working💻 aspect: codeConcerns the software code in the repositoryConcerns the software code in the repository🚦status: awaiting triageHas not been triaged & therefore, not ready for workHas not been triaged & therefore, not ready for work🛠 goal: fixBug fixBug fix