Skip to content
XSS Disclosed report Intermediate CVE-2018-10379

XSS (Persistent) - Selecting role(s) for protected branches

A user's username was not escaped when displayed in the protected branch access dropdown, allowing a stored cross-site scripting attack. An attacker with a malicious username could execute script in the browser of a project member with Master access who viewed the dropdown.

phillycheeze Follow

Originally disclosed on HackerOne

  • Triaged in 31 hours
  • Fixed in 29 days
  • Disclosed after 2 months

Summary: When using the dropdown that selects the groups or users that are allowed to push or merge to a protected branch within a project, it is possible to trigger a XSS with a malicious user name string.

Description: This vulnerability is similar to the recently announced CVE-2018-10379. The username input string where an attacker is able to inject a payload is in the same location, but the XSS that renders is in a different location. Since the remediation needs to be applied at the presentation layer, this is indeed a separate vulnerability and needs to be fixed separately (although Gitlab could start whitelisting characters allowed in usernames, similar to how Gitlab whitelists characters for Group or Project names).

The steps to reproduce are fairly simple but there are some restrictions:

Steps To Reproduce:

  1. Set your own username as "<img src=x onerror=alert(document.domain)> foo / bar"
  2. Make yourself have at least Master access to a project
  3. In this project, ensure at least one branch is in the project and that branch is a "Protected Branch"
  4. Under Project Settings -> Repository -> Protected Branches, select the dropdown under the "Ability to Merge" section
  5. Notice that the onerror attribute from the username renders.

Supporting Material/References:

More information can be provided upon request.

You'll notice the payload above is the same as the payload used in a test file (inside the ce source code repo) for the CVE I attached. I only found this vulnerability since I was testing the previous CVE on our own internal instance of Gitlab, left my username saved as that malicious string, and later found the alert() dialog popup in another area of the site even after patching to 10.7.2.

Suggested Remediation

I believe this is the offending Line: https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/app/assets/javascripts/projects/settings/access_dropdown.js#L461

^There could also be other XSS vulnerabilities in this JS file. Everywhere else in the app uses the underscore method _.escape()to escape user input, but this file doesn't.

Impact

The security impact is the same as any typical persistent xss.

The hacker selected the Cross-site Scripting (XSS) - Stored weakness. This vulnerability type requires contextual information from the hacker. They provided the following answers:

URL https://gitlab.com/group/project/settings/repository

Verified Yes

The original report as published on HackerOne, by phillycheeze. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 JavaScript file that builds the access dropdown inserted the username into the page without escaping it, unlike other parts of the application that use an escape function.

Impact

A project member with Master access who viewed the dropdown could have script run in their browser, with the same impact as any typical persistent XSS.

What the attacker needed

Attacker has Starter subscription or higher; attacker can set a malicious username; victim has Master access to the project; victim opens the protected branches dropdown

The fix

The presentation layer should escape the username before inserting it into the dropdown, as other parts of the application do.

How it was found

  1. Set your own username to a string containing an image tag with an onerror handler.
  2. Make yourself have at least Master access to a project.
  3. Ensure the project has a branch marked as a Protected Branch.
  4. Go to Project Settings, Repository, Protected Branches and open the dropdown under Ability to Merge.
  5. Observe that the onerror attribute from the username executes.

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.

When a website shows text from a user without cleaning it first, that text can include code that the browser runs. Here, a username containing an image tag with an error handler was shown in a dropdown, so the browser ran the code. This is called stored cross-site scripting because the malicious text is saved and later shown to others.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by phillycheeze

View all

2 more disclosed reports, best first.

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.