Skip to content
XSS Disclosed report Beginner

The react-marked-markdown module allows XSS injection in href values.

The react-marked-markdown React component fails to properly sanitise link href values even when the sanitize option is enabled, allowing an attacker to inject JavaScript through user-supplied Markdown. An attacker could execute arbitrary script in the context of a page that renders untrusted Markdown.

ronperris Follow

Originally disclosed on HackerOne

Critical 9.3 View original
  • Triaged in 8 days
  • Fixed in 16 days
  • Disclosed after 16 days

NOTE! Thanks for submitting a report! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!

I would like to report XSS in react-marked-markdown. The react-marked-markdown module incorrectly sanitizes href values and allows arbitrary code injection (XSS) via user provided Markdown.

Module

module name: react-marked-markdown version: 1.4.6 npm page: https://www.npmjs.com/package/1.4.6

Module Description

A react components package that helps you use Markdown easily.

Module Stats

Replace stats below with numbers from npm’s module page:

133 downloads in the last day 935 downloads in the last week 4207 downloads in the last month

Vulnerability

Vulnerability Description

The React component created with react-marked-markdown contains XSS in link values even when the sanitize option is set to true.

The react-marked-markdown module uses marked.Render() but overwrites the link method with a custom version that doesn't correctly escape values passed to the href prop of anchor components.

Steps To Reproduce:

import React from 'react' import ReactDOM from 'react-dom' import { MarkdownPreview } from 'react-marked-markdown'

ReactDOM.render( <MarkdownPreview markedOptions={{ sanitize: true }} value={'[XSS](javascript: alert1)'} />, document.getElementById('root') )

Patch

Supporting Material/References:

State all technical information about the stack where the vulnerability was found

  • macOS 10.13
  • Node.js 8.11.1
  • npm 6.0

Wrap up

Select Y or N for the following statements:

  • I contacted the maintainer to let them know: Y
  • I opened an issue in the related repository: Y

https://github.com/Vincent-P/react-marked-markdown/issues/61

Impact

The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. This allows attackes to add malicious scripts to the page via Markdown.

The original report as published on HackerOne, by ronperris. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The module overrides the marked renderer's link method with a custom version that does not correctly escape or validate the value placed in the href attribute, so the sanitize option does not protect link targets.

Impact

An attacker could inject and run arbitrary script in pages that render untrusted Markdown with this component, even with sanitisation turned on.

What the attacker needed

App renders untrusted Markdown with this module; victim views or clicks the crafted link

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Markdown is a simple way to format text, and links in Markdown can include a URL. This library turns Markdown into web page elements but does not check that the URL is safe, so a link can start with 'javascript:' and run code when clicked. That lets an attacker run their own script in a victim's browser.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by ronperris

View all

1 more disclosed report, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.