Skip to content
XSS Disclosed report Intermediate

[Markdown] Stored XSS via character encoding parser bypass

The Markdown parser in GitLab 10.0 could be bypassed using control characters embedded in a link, allowing an attacker to store a link that executes JavaScript when clicked. This gave persistent cross-site scripting on any page rendering Markdown, such as project wikis.

ysx Follow

Originally disclosed on HackerOne

  • Triaged in 1 hour
  • Fixed in 25 days
  • Disclosed after 26 days

Summary by the researcher

A carefully crafted injection could be leveraged to achieve persistent XSS. This affected all locations where the Markdown parser was deployed. The Project Wiki feature was used to present a suitable proof of concept. Thanks again to @briann and the GitLab team for the swift remediation.

The report

Hi @briann and team,

A carefully crafted injection used against the Markdown input parser can be leveraged to store and execute arbitrary JavaScript on GitLab 10.0 hosts. Given the nature of this injection, which makes use of a rather esoteric filter bypass, the scope for exploitation may vary.

Proof of concept

I have been able to exploit the following vulnerability within project Wiki pages. Consequently, prior to reproducing this issue please set up a test GitLab 10.0 instance with a Markdown-formatted project wiki. For ease of exploitation, the use of a web intercept proxy (e.g. Burp Suite) is recommended.

  1. Please proceed to access your Wiki, then select "Edit" on the homepage (or create a new Markdown page).

  2. Next, please activate your web intercept proxy. After doing so, enter generic text into the "Content" field and select the "Save Changes" button.

  3. Return to your web intercept proxy, and identify the POST request to the wikis endpoint. Within this request, please identify the content parameter and replace this with the below payload.

  4. Finally, please POST the request and disable your web intercept proxy. Upon arriving on the updated Wiki page, please select the hyperlink to execute the JavaScript payload.

Markdown parser payload

%3Ca+href%3D%22%01java%03script%3Aconfirm%28document.domain%29%22%3EClick+to+execute%3Ca%3E%0D%0A

Supporting evidence

GitLab_Markdown_XSS.png
GitLab_Markdown_XSS.png From the original on HackerOne

Verified conditions

At the time of testing, I have successfully confirmed exploitability in the following environment:

  • Firefox 55.0.3 stable (32-bit) on Ubuntu 16.04.3 LTS
  • Fresh GitLab 10.0.0 CE install

Thanks,

Yasin

The original report as published on HackerOne, by ysx. 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

Likely the Markdown sanitiser did not strip control characters inside link URLs, so a javascript: scheme could be smuggled past the filter and stored.

Impact

An attacker could store JavaScript that runs when a victim clicks the crafted link, though exploitation was only confirmed on Firefox 55 and required the victim to click.

What the attacker needed

GitLab 10.0 instance; Markdown-formatted project wiki; ability to edit wiki pages; victim clicks the crafted link

The fix

The report says the GitLab team remediated the issue swiftly, though it does not describe the code change.

How it was found

  1. Open the project wiki and edit the homepage or create a new Markdown page.
  2. Turn on a web intercept proxy, enter generic text in the content field and save.
  3. In the intercepted POST to the wikis endpoint, replace the content parameter with the crafted payload.
  4. Forward the request, turn off the proxy, open the updated wiki page and click the link to run the 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 report has not been written yet. The Original tab links to the source.

Markdown is a simple way of writing formatted text, and GitLab turns it into web pages. The parser that does this conversion could be tricked with hidden control characters so that a normal-looking link actually ran JavaScript code in the victim's browser. Because the malicious link is saved on the page, anyone who clicks it runs the attacker's code.

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 ysx

View all

25 more disclosed reports, best first.

More from GitLab

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.