I've identified a Cross-Site Scripting (XSS) vulnerability in 'dash-core-components'
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 { Link } from 'dash-core-components'
<Link href={`javascript:alert(1)`} />
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:
|
render() { |
|
const { |
|
className, |
|
style, |
|
id, |
|
href, |
|
loading_state, |
|
children, |
|
title, |
|
target, |
|
} = this.props; |
|
/* |
|
* ideally, we would use cloneElement however |
|
* that doesn't work with dash's recursive |
|
* renderTree implementation for some reason |
|
*/ |
|
return ( |
|
<a |
|
data-dash-is-loading={ |
|
(loading_state && loading_state.is_loading) || undefined |
|
} |
|
id={id} |
|
className={className} |
|
style={style} |
|
href={href} |
|
onClick={e => this.updateLocation(e)} |
|
title={title} |
|
target={target} |
|
> |
|
{isNil(children) ? href : children} |
|
</a> |
It is best practice for a React.js components package to sanitize the href attribute before passing it to an tag. React.js and many popular libraries such as react-router-dom and Next.js also ensure the safety of href attributes. For instance, React.js issues warnings about URLs starting with javascript: and is planning to block these in future versions, as indicated in
this pull request.
Please consider validating the href to resolve this vulnerability, thanks!
I've identified a Cross-Site Scripting (XSS) vulnerability in 'dash-core-components'
Vulnerability Details:
Steps to Reproduce:
In a React.js project:
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:
dash/components/dash-core-components/src/components/Link.react.js
Lines 64 to 94 in 000ec18
It is best practice for a React.js components package to sanitize the href attribute before passing it to an tag. React.js and many popular libraries such as react-router-dom and Next.js also ensure the safety of href attributes. For instance, React.js issues warnings about URLs starting with javascript: and is planning to block these in future versions, as indicated in this pull request.
Please consider validating the href to resolve this vulnerability, thanks!