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

Closes issue #420 #423

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChandraShekharAgrawal
Copy link

Types of changes

What types of changes does your code introduce? Check all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)

Description

  • Edited anchorURLs function that fixes issue of cross site scripting.

Final checklist:

Go over all the following points and check all the boxes that apply
If you're unsure about any of these, don't hesitate to ask. We're here to help!

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING guidelines.
  • All tests passed.

@shakeelmohamed shakeelmohamed self-assigned this Sep 23, 2023
Copy link
Member

@shakeelmohamed shakeelmohamed left a comment

Choose a reason for hiding this comment

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

Great start on this issue, I’ve included the full screenshot of all vulnerable code paths.
There are other areas we have the same issue like:

  • makeListenURL() (which addresses anchorTimestamps())
  • makeSearchURL()

Perhaps we can address all of these with adding encodeURI() inside cleanURL(), will need some manual testing. See my inline comment.

If you’re up for it, I would love to see some tests added for this area!

screencapture-github-zen-audio-player-zen-audio-player-github-io-security-code-scanning-3-2023-09-26-22_58_11

// Use a function to replace matches
return text.replace(re, function(match) {
// Escape the match to prevent XSS
var url = encodeURIComponent(match);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR @ChandraShekharAgrawal!

We actually want encodeURI(match) here instead, otherwise we will get invalid URLs.

e.g.

If match is http://smarturl.it/outlines, then url becomes a non-valid URL http%3A%2F%2Fsmarturl.it%2Foutlines, which is then interpreted by the browser as http://localhost:8080/http%3A%2F%2Fsmarturl.it%2Foutlines when running locally.

Copy link
Member

Choose a reason for hiding this comment

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

You can test this yourself locally after you run npm install and npm start...

  1. Go to http://localhost:8080/?v=03O2yKUgrKw (or other video with links in the description, this is one of our demo videos).
  2. Click Show Description
  3. Inspect any links in the browser

Copy link
Member

Choose a reason for hiding this comment

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

@ChandraShekharAgrawal hi, any chance you can revisit this?

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

Successfully merging this pull request may close these issues.

2 participants