Stored XSS via Mermaid (classDiagram)
A stored cross-site scripting vulnerability existed in GitLab's Mermaid class diagram rendering, allowing an attacker to inject HTML that executes when a user views the diagram. An attacker could steal cookies or redirect users to a malicious site.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #1390391 by solov9ev on 2021-11-03, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
Summary
Hi, Security Team!
I discovered a stored xss vulnerability via Mermaid (classDiagram).
Steps to reproduce
-
Run Gitlab docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab gitlab/gitlab-ce:latest (
GitLab Enterprise Edition 14.4.1-ee) -
Insert into any field that supports markdown with using Mermaid the following payload (classDiagram):
classDiagram
class Square~{{media:2}}~{
int id
List~int~ position
setPoints(List~int~ points)
getPoints() List~int~
}
Square : -List~string~ messages
Square : +setMessages(List~string~ messages)
Square : +getMessages() List~string~


Impact
With this vulnerability, an attacker can for example steal users cookies or redirect users on malicious website.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
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 class diagram renderer did not properly sanitise user-supplied class names, allowing HTML injection.
Impact
An attacker could steal users' cookies or redirect them to a malicious website.
What the attacker needed
Ability to insert markdown with Mermaid; victim views the rendered diagram
How it was found
- Run GitLab using the provided Docker command.
- Insert a Mermaid class diagram payload into any markdown field.
- View the rendered diagram, as shown in the attached screenshots.
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.
This report describes a stored cross-site scripting (XSS) bug. When a user inserts a specially crafted Mermaid diagram into a markdown field, the diagram renderer fails to sanitise the input, so malicious HTML runs in the browser of anyone who views the page. That lets an attacker run code in the victim's session, potentially stealing cookies or redirecting them.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.