Gitlab XSS in markdown preview page
A DOM-based cross-site scripting flaw existed in GitLab's markdown preview because the mermaid diagram feature allowed a click handler to contain a javascript: URL. An attacker could craft a malicious issue that, when a victim clicked a diagram node, executed arbitrary JavaScript in the victim's browser.
GitLab
Originally disclosed on GitLab
- Fixed in 2 months
- Disclosed after 2 months
HackerOne report #645043 by brainpanic on 2019-07-16, assigned to akelly:
Summary
A DOM-Based XSS in markdown preview page due to mermaid feature.
Steps to reproduce
- sign in to GitLab
- find a repo and create a issue
- submit with the following code
graph LR;
A-->CLICK_HERE_AND_GET_BONUS;
click A alert "aaa"
click CLICK_HERE_AND_GET_BONUS "javascript:alert%28%64%6f%63%75%6d%65%6e%74%2e%64%6f%6d%61%69%6e%29" "Here is the XSS"
- goto the issue page
- click the node named "CLICK_HERE_AND_GET_BONUS", you will see an alert box with document.domain
Impact
The XSS can be used to hijack the victim's Gitlab account.
Examples
Goto the link below, and click the node named "CLICK_HERE_AND_GET_BONUS"
https://gitlab.com/c00lyu/sss/issues/1
You will see an alert box with document.domain
What is the current bug behavior?
Execute javascript code
What is the expected correct behavior?
Do not allow javascript code to execute
Relevant logs and/or screenshots

Output of checks
This bug happens on GitLab.com
Impact
The XSS can be used to hijack the victim's Gitlab account.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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 mermaid diagram renderer did not sanitise click handler URLs, allowing a javascript: scheme to be used as a link target.
Impact
The XSS could be used to hijack the victim's GitLab account, but it required the victim to click a specific diagram node.
What the attacker needed
A GitLab account; victim views the malicious issue; victim clicks a diagram node
How it was found
- Sign in to GitLab.
- Find a repository and create an issue.
- Submit the issue with a mermaid code block containing a click handler with a javascript: URL.
- Go to the issue page.
- Click the diagram node labelled CLICK_HERE_AND_GET_BONUS to trigger the alert.
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.
Cross-site scripting (XSS) is when a website runs attacker-supplied JavaScript in a victim's browser. Here, a diagram tool called mermaid let a link inside a diagram start with 'javascript:', so clicking it ran code. That code could then act as the victim on GitLab.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.