Skip to content
XSS Disclosed report Intermediate

Stored XSS in merge request because of target branch

A stored cross-site scripting vulnerability existed in GitLab merge requests because the target branch name was not properly sanitised. An attacker could inject a malicious branch name that would execute script when a merge request was created and the 'Merge Immediately' button was clicked, affecting all users of a public project.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

HackerOne report #1030189 by ashish_r_padelkar on 2020-11-09, assigned to @kaunghtet:

Report | Attachments | How To Reproduce

Report

Summary

Hello,

I Found a stored XSS in merge request which triggers for everyone in public project as merge requests are available for everyone. Currently Gitlab.com is prevented because of CSP.

Steps to reproduce
  1. Create a file at -/new/master/ and in Target Branch section put branch name as XSS payload ">{{media:2}}.
  2. Create a merge request now at /-/merge_requests/new. Select Target Branch as above branch with XSS payload and create a merge request.
  3. As soon as you create merge request, you should see below button
Screenshot_2020-11-10_at_00.52.04.png
Screenshot_2020-11-10_at_00.52.04.png From the original on GitLab
  1. Click on Merge Immediately
  2. It will create a pipeline and appears as a note which triggers this XSS
Screenshot_2020-11-10_at_00.53.36.png
Screenshot_2020-11-10_at_00.53.36.png From the original on GitLab
Output of checks

This bug happens on GitLab.com

Regards,
Ashish

Impact

Stored XSS in merge request

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 application failed to properly escape or sanitise the target branch name when rendering it in the merge request interface.

Impact

Stored XSS in merge requests could execute arbitrary JavaScript in the context of other users, but on GitLab.com the exploit was prevented by Content Security Policy (CSP).

What the attacker needed

Public project; ability to create branches and merge requests

How it was found

  1. Create a file at `-/new/master/` and in the Target Branch section put a branch name containing an XSS payload.
  2. Create a merge request at `/-/merge_requests/new` and select the branch with the XSS payload as the Target Branch.
  3. After creating the merge request, a button appears.
  4. Click on 'Merge Immediately'.
  5. A pipeline is created and appears as a note, which triggers the XSS.

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 XSS bug. A branch name containing HTML code could run in other users' browsers when a merge request used that branch.

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.