Skip to content
XSS Disclosed report Intermediate

Clipboard based XSS in the title field of work items

The title field of GitLab work items allowed pasting HTML with data- attributes, which Rails UJS uses to execute JavaScript. An attacker could craft a malicious clipboard payload that, when pasted and clicked, executes arbitrary JavaScript in the victim's browser.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 months

HackerOne report #1767745 by ryotak on 2022-11-09, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

Due to the improper handling of the clipboard contents in the title field of work items, an attacker is able to insert a malicious HTML element that triggers the execution of JavaScript.

Please refer to #1196958 for a similar report and discussions about this vulnerability type.

Description

In the work/items/components/item_title.vue component of GitLab, the contenteditable attribute is specified.
app/assets/javascripts/work_items/components/item_title.vue line 42-59

HTML
    <span  
      id="item-title"  
      ref="titleEl"  
      role="textbox"  
      :aria-label="__('Title')"  
      :data-placeholder="placeholder"  
      :contenteditable="!disabled"  
      class="gl-px-4 gl-py-3 gl-ml-n4 gl-border gl-border-white gl-rounded-base gl-display-block"  
      :class="{ 'gl-hover-border-gray-200 gl-pseudo-placeholder': !disabled }"  
      [@]blur="handleBlur"  
      [@]keyup="handleInput"  
      [@]keydown.enter.exact="handleSubmit"  
      [@]keydown.ctrl.u.prevent  
      [@]keydown.meta.u.prevent  
      [@]keydown.ctrl.b.prevent  
      [@]keydown.meta.b.prevent  
      >{{ title }}</span  
    >  

Since this attribute allows data- attributes while pasting the HTML contents, malicious clipboard contents can insert arbitrary data- attributes including data-method or data-url.

Since ActionView uses data- attribute to control the behavior of HTML elements, and this feature has an XSS, malicious HTML contents with a data-method attribute can execute arbitrary JavaScript on GitLab.
actionview/app/javascript/rails-ujs/features/method.js line 9-16

JavaScript
  const method = link.getAttribute("data-method")  
  if (!method) { return }

  const href = rails.href(link)  
  const csrfToken = csrf.csrfToken()  
  const csrfParam = csrf.csrfParam()  
  const form = document.createElement("form")  
  let formContent = `<input name='_method' value='${method}' type='hidden' />`  
JavaScript
e.clipboardData.setData('text/html', `<a href="#" data-method="'><img src onerror=alert(document.domain)>">Click me</a>`);  
Steps to reproduce
  1. Set up your own GitLab instance.
  2. Log in to the GitLab instance.
  3. Create a project.
  4. Append /-/work_items/new to the end of the project path. (e.g. https://{GITLAB_INSTANCE}/{USERNAME}/{PROJECT_NAME}/-/work_items/new)
  5. Download
  6. Open in the browser
  7. Click Copy
  8. Paste it to the title field of the page that you opened in step 4.
  9. Click Click me
  10. Confirm that alert(document.domain) is executed.
2022-11-09_22-42-50.mp4 From the original on GitLab
What is the current bug behavior?

A malicious clipboard content is able to inject an HTML element with an XSS payload.

What is the expected correct behavior?

GitLab shouldn't allow the injection of a malicious HTML element.

Results of GitLab environment info
System information  
System:         Ubuntu 20.04  
Proxy:          no  
Current User:   git  
Using RVM:      no  
Ruby Version:   2.7.5p203  
Gem Version:    3.1.6  
Bundler Version:2.3.15  
Rake Version:   13.0.6  
Redis Version:  6.2.7  
Sidekiq Version:6.4.2  
Go Version:     unknown

GitLab information  
Version:        15.5.3-ee  
Revision:       48f51d8b0c3  
Directory:      /opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:     PostgreSQL  
DB Version:     13.6  
URL:            https://gl.ryotak.me  
HTTP Clone URL: https://gl.ryotak.me/some-group/some-project.git  
SSH Clone URL:  [email protected]:some-group/some-project.git  
Elasticsearch:  no  
Geo:            no  
Using LDAP:     no  
Using Omniauth: yes  
Omniauth Providers:

GitLab Shell  
Version:        14.12.0  
Repository storage paths:  
- default:      /var/opt/gitlab/git-data/repositories  
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell  

Impact

An attacker can execute arbitrary JavaScript on the victim's browser and do any actions on behalf of the user.

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

An attacker can execute arbitrary JavaScript on the victim's browser and perform any actions on behalf of the user.

What the attacker needed

Victim pastes malicious content; victim clicks the injected link

How it was found

  1. Set up a GitLab instance and log in.
  2. Create a project and navigate to the new work item page.
  3. Open the provided clipboard.html file and click Copy.
  4. Paste the clipboard content into the title field.
  5. Click the 'Click me' link that appears.
  6. Observe that the JavaScript alert 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.

A work item title field in GitLab let you paste formatted text, but it didn't clean up hidden attributes that control how links behave. An attacker could trick a user into copying a malicious link and pasting it into the title, then clicking it, which would run the attacker's JavaScript in the user'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.