Skip to content
XSS Disclosed report Intermediate

Stored XSS via autocomplete results in rich text editor

The autocomplete suggestion dropdown in GitLab's rich text editor highlighted matches by inserting the query into HTML without escaping, allowing an attacker to inject DOM attributes. An attacker could create a public snippet and an issue with a crafted title so that when a victim triggers autocomplete in a merge request description, clicking the transparent overlay executes arbitrary JavaScript, bypassing CSP.

GitLab

Originally disclosed on GitLab

  • Fixed in 35 days
  • Disclosed after 35 days

⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.

HackerOne report #2404710 by yvvdwf on 2024-03-06, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Hello,

Recently Gitlab improved autocomplete results in rich text editor:

JavaScript
//https://gitlab.com/gitlab-org/gitlab/-/blob/3617b242c79d080dc3757c2defb5574170566051/app/assets/javascripts/content_editor/components/suggestions_dropdown.vue#L236-244      
  highlight(text) {  
      return this.query  
        ? String(text).replace(  
            new RegExp(this.query, 'i'),  
            (match) => `<strong class="gl-text-body!">${match}</strong>`,  
          )  
        : text;  
    },  

Although the results are then rendered via v-safe-html but attacker can inject some DOM attributes, such as, class attribute that can be exploited to execute arbitrary javascript at the client side.

Reproduction

As attacker:

  1. create a public snippet with a json file alert.json containing {"html":"<script>alert(document.domain)</script>"}, then open the raw version and make note of the path, for example: https://gitlab.com/-/snippets/3683972/raw/main/alert.json
snippet.png
snippet.png From the original on GitLab
  1. create a new project and add a new issue within the following title:
HTML
test issue <i class=inline-parallel-buttons><a href=/-/snippets/3683972/raw/main/alert style="position:fixed;transform:translate3d(-2000px,-5000px,0px);width:10000px;height:20000px">  

Note: replace the url in href by the path to your json file noted above with the following modification:

  • no https://gitlab.com prefix
  • no .json suffix
issue.png
issue.png From the original on GitLab

As victim:

go in the project, modify a file, then create a new merge request:

merge-request.png
merge-request.png From the original on GitLab
  1. click Changes to open a diff view
  2. click Switch to rich text editing if you are in plain text editing mode
  3. in Description, enter # character to get suggestion results of the project's issue. Once the suggestion list appears, you might notice a transparent layer on the topmost. Click anywhere to trigger XSS.

Note:

PR:L as attackers need only permission to create a public snippet and an issue inside victim's project. An issue can be also created via Service Desk which is enabled by default for any project. If so, attacks can even create an issue on a private project.

Impact:

XSS with CSP bypassed allows attackers to perform arbitrary actions on behalf of victims

Best,
yvvdwf

Impact

XSS with CSP bypassed allows attackers to perform arbitrary actions on behalf of victims

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

Impact

XSS with CSP bypassed allows attackers to perform arbitrary actions on behalf of victims.

What the attacker needed

Attacker can create a public snippet; attacker can create an issue in victim's project; victim uses rich text editor and triggers autocomplete; victim clicks on the page

How it was found

  1. Create a public snippet containing a JSON file with a script payload and note its raw path.
  2. Create a new project and add an issue with a title containing HTML that includes a link to the snippet's raw path (without domain and .json suffix) and styling to make it cover the page.
  3. As the victim, go to the project, modify a file, and create a new merge request.
  4. Click 'Changes' to open the diff view and switch to rich text editing if needed.
  5. In the Description field, type '#' to trigger the suggestion list; a transparent layer appears.
  6. Click anywhere on the page 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.

When you type a character like '#' in a text box, the application shows a list of suggestions and highlights the part you typed. The code that does the highlighting inserted your text directly into the page's HTML without cleaning it first. This meant an attacker could put special HTML attributes in an issue title, and when that title appeared in the suggestion list, clicking on it would run the attacker's JavaScript in the victim's browser.

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.