Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DOMPurify to sanitize and mitigate XSS attacks #3049

Merged
merged 3 commits into from
Sep 24, 2024

Conversation

TheMythologist
Copy link
Contributor

@TheMythologist TheMythologist commented Sep 22, 2024

Description

An XSS vulnerability is present in the Markdown component, where unsanitized user input is directly passed into dangerouslySetInnerHTML. For more info, refer to here.

Note: The changes in UI test snapshots are merely the order of the a tag attributes - they are essentially the same.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

An example would be entering the text <img src="" onerror={alert('xss')} /> in the "Module Help Text" of the Admin Panel page when creating a new course. After sanitization, the alert('xss') command should not be run.

Checklist

  • I have tested this code

@RichDom2185 RichDom2185 self-requested a review September 22, 2024 02:37
@coveralls
Copy link

coveralls commented Sep 22, 2024

Pull Request Test Coverage Report for Build 11007895846

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 31.449%

Totals Coverage Status
Change from base Build 10982558647: 0.0%
Covered Lines: 4852
Relevant Lines: 14547

💛 - Coveralls

Copy link
Contributor

@sayomaki sayomaki left a comment

Choose a reason for hiding this comment

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

Hi, thanks for catching this and working on this! The changes looks good to me, and I think we can go ahead and have this merged once @RichDom2185 takes a look as well.

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks and sorry for the delayed review!

@RichDom2185 RichDom2185 enabled auto-merge (squash) September 24, 2024 06:01
@RichDom2185 RichDom2185 merged commit fe360ae into source-academy:master Sep 24, 2024
6 checks passed
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.

4 participants