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

XSS vulnerabilities in @hashicorp packages #1019

Open
gtsp233 opened this issue Jan 23, 2024 · 0 comments
Open

XSS vulnerabilities in @hashicorp packages #1019

gtsp233 opened this issue Jan 23, 2024 · 0 comments

Comments

@gtsp233
Copy link

gtsp233 commented Jan 23, 2024

I've identified Cross-Site Scripting (XSS) vulnerabilities in '@hashicorp/hero'

Vulnerability Details:

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

Steps to Reproduce:
In a React.js project:

import Hero from "@hashicorp/react-hero"

import React from "react";
import Hero from "@hashicorp/react-hero"
const App = () => {
    return <>
        <Hero description={`<img src='' onerror=alert(1)>`} headline={`<img src='' onerror=alert(1)>`} />
    </>
};

export default App

Then the malicious code alert(1) will be executed. Any React.js application using this package may be vulnerable to XSS.

Suggested Fix or Mitigation:
Sanitize the HTML before passing it to dangerouslySetInnerHTML using popular sanitization libraries, e.g., dompurify

function SectionHeader({ headline, description, useH1 }) {
return (
<div className={`g-section-header ${s.root}`}>
{headline &&
(useH1 ? (
<h1
className={s.headlineOne}
data-testid="h1"
dangerouslySetInnerHTML={{
__html: eliminateOrphans(headline),
}}
/>
) : (
<h2
className={s.headlineTwo}
data-testid="h2"
dangerouslySetInnerHTML={{
__html: eliminateOrphans(headline),
}}
/>
))}
{description && (
<div
className={s.description}
data-testid="description"
dangerouslySetInnerHTML={{
__html: eliminateOrphans(description.trim()),
}}
/>
)}
</div>
)
}

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

No branches or pull requests

1 participant