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

validate url to prevent xss #35

Merged
merged 1 commit into from Jan 29, 2024
Merged

validate url to prevent xss #35

merged 1 commit into from Jan 29, 2024

Conversation

gtsp233
Copy link
Contributor

@gtsp233 gtsp233 commented Jan 22, 2024

Fix for Cross-Site Scripting (XSS) Vulnerability

I've identified a Cross-Site Scripting (XSS) vulnerability in package @mtbird/helper-extension

Vulnerability Details:

  • Severity: High/Critical
  • Description: There's a risk of malicious script execution when the url is controlled by an adversary.

POC:
In a React.js project:

import { helpers } from "@mtbird/helper-extension";
helpers.generateEventHandler({}, { link: "link", href: "javascript:alert(1)" });

Then the malicious code alert(1) will be executed.

Suggested Fix or Mitigation:
It is best practice for a helper function to ensure security by sanitizing the URL before passing it to window.open. React.js and many popular libraries such as react-router-dom and Next.js also ensure URL safety to prevent XSS. For instance, React.js issues warnings about URLs starting with javascript: and is planning to block these in future versions, as indicated in facebook/react#15047.

I've already fixed and tested this issue, and have submitted a pull request with the necessary changes. Please review and merge my pull request to resolve this vulnerability. Thanks!

@CLAassistant
Copy link

CLAassistant commented Jan 22, 2024

CLA assistant check
All committers have signed the CLA.

@jtaox jtaox merged commit 73ee9ae into staringos:master Jan 29, 2024
1 check 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.

None yet

3 participants