[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.
- 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.
-
Please proceed to access your Wiki, then select "Edit" on the homepage (or create a new Markdown page).
-
Next, please activate your web intercept proxy. After doing so, enter generic text into the "Content" field and select the "Save Changes" button.
-
Return to your web intercept proxy, and identify the POST request to the
wikisendpoint. Within this request, please identify thecontentparameter and replace this with the below payload. -
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

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
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
- Open the project wiki and edit the homepage or create a new Markdown page.
- Turn on a web intercept proxy, enter generic text in the content field and save.
- In the intercepted POST to the wikis endpoint, replace the content parameter with the crafted payload.
- 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.