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
- Create a file at
-/new/master/and inTarget Branchsection put branch name as XSS payload">{{media:2}}. - Create a merge request now at
/-/merge_requests/new. SelectTarget Branchas above branch with XSS payload and create a merge request. - As soon as you create merge request, you should see below button

- Click on
Merge Immediately - It will create a pipeline and appears as a note which triggers this XSS

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:
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
- Create a file at `-/new/master/` and in the Target Branch section put a branch name containing an XSS payload.
- Create a merge request at `/-/merge_requests/new` and select the branch with the XSS payload as the Target Branch.
- After creating the merge request, a button appears.
- Click on 'Merge Immediately'.
- 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.