Skip to content
XSS Disclosed report Intermediate

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~  
1.png
1.png From the original on GitLab
2.png
2.png

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:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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

  1. Run GitLab using the provided Docker command.
  2. Insert a Mermaid class diagram payload into any markdown field.
  3. 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.

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.