A bug in the Sundown and Redcarpet markdown parsers may lead to XSS
A bug in the Sundown and Redcarpet markdown parsers caused incorrect handling of email autolinks, allowing an attacker to inject arbitrary HTML tags and attributes. This could lead to XSS when markdown from untrusted sources is rendered.
danlec.com
Published on danlec.com
In early February 2015, I reported an XSS vulnerability in HackerOne itself. After some investigation, we determined that the vulnerability was due to a bug in version 3.2.2 of the Redcarpet markdown parser … which was due to a bug in the autolink feature in version 1.16.0 of the Sundown markdown parser that Redcarpet…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The rewind performed when processing an inline element was allowed to step back into previously output elements, and an assumption was being made that the rewind would only contain plain text.
Impact
An attacker could inject arbitrary HTML and JavaScript, leading to XSS, but HackerOne's strict content security policy blocked script execution in some browsers.
What the attacker needed
Markdown from untrusted source; victim views rendered markdown; browser without CSP support
The fix
The fix was to limit the rewinding so it would never move into text that had already been output as an element.
How it was found
- Input a string like `_http://[email protected]` into a markdown parser using Sundown/Redcarpet.
- Observe that the output contains an unclosed tag and injected content.
- Add attributes such as `style` and `onclick` to the injected tag to execute script.
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 write-up has not been written yet. The Original tab links to the source.
Markdown is a way to format text, and some websites use it to display user content. A bug in the software that converts markdown to HTML meant that certain email-like text could break the HTML and let an attacker insert their own code, which could run 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.