Skip to content
XSS Disclosed report Beginner

Stored XXS via Mermaid sequenceDiagram

A stored cross-site scripting vulnerability existed in GitLab's Mermaid sequenceDiagram rendering, where a participant's link could use a javascript: URL. An attacker could create an issue with a malicious diagram and execute JavaScript when another user clicked the link, but on gitlab.com the CSP blocked execution.

GitLab

Originally disclosed on GitLab

  • Fixed in 33 days
  • Disclosed after 33 days

HackerOne report #1420627 by chbi on 2021-12-08, assigned to @dcouture:

Report | Attachments | How To Reproduce

Report

Hi,

I've discovered a XSS vulnerability via Mermaid sequenceDiagram.

Tested on a local GitLab 14.5.2 installation with Firefox and Chrome.

This XSS vulnerability exists only since Version 14.5.2!

Steps to reproduce
  1. Create a New Issue
  2. Create a Mermaid diagram with following content
sequenceDiagram  
    participant Alice  
    participant John  
    links Alice: {"Dashboard": "https://dashboard.contoso.com/alice", "Wiki": "https://wiki.contoso.com/alice"}  
    links John: {"Dashboard": "https://dashboard.contoso.com/john", "Wiki": "javaScript:alert(window.opener.document.domain)"}  
    Alice->>John: Hello John, how are you?  
    John-->>Alice: Great!  
    Alice-)John: See you later!  
  1. Press "Create issue"
  2. Hover the cursor over "John" on the top right
  3. Click on "Wiki"
Impact

Run actions in context of other users.

Examples

Video local installation:

poc_local.mp4 From the original on GitLab

On gitlab.com the Javascript execution is blocked by CSP:

Private Issue:
https://gitlab.com/chbi-h1_2021/poc/-/issues/3

Video gitlab.com CSP enabled:

poc_gitlab-com_csp.mp4 From the original on GitLab

Video gitlab.com CSP disabled (just to demonstrate):

poc_gitlab-com_without_csp.mp4 From the original on GitLab
Output of checks

This bug happens on local GitLab instances only since version 14.5.2 and also on gitlab.com.

Results of GitLab environment info

sudo gitlab-rake gitlab:env:info

System information
System: Debian 10
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.7.5p203
Gem Version: 3.1.4
Bundler Version:2.1.4
Rake Version: 13.0.6
Redis Version: 6.0.16
Git Version: 2.33.1.
Sidekiq Version:6.2.2
Go Version: unknown

GitLab information
Version: 14.5.2-ee
Revision: 4511944420f
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 12.7
URL: http://localhost
HTTP Clone URL: http://localhost/some-group/some-project.git
SSH Clone URL: git@localhost:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version: 13.22.1
Repository storage paths:
default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git

Impact

Run actions in context of other users.

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

Impact

An attacker could run actions in the context of other users, but on gitlab.com JavaScript execution was blocked by CSP.

What the attacker needed

Ability to create an issue; victim clicks the malicious link

How it was found

  1. Create a new issue
  2. Add a Mermaid sequenceDiagram with a participant link using a javascript: URL
  3. Press 'Create issue'
  4. Hover over the participant name
  5. Click the malicious link

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 is a stored cross-site scripting (XSS) bug. A user could insert a special link into a diagram that, when clicked by someone else, would run harmful code in their browser. The code could then act as the victim user.

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.