Skip to content
XSS Disclosed report Advanced

HTML injection in Child item search on issue page leads to XSS on self hosted instances

The issue page's child item search rendered user-controlled task names through v-safe-html without proper escaping, allowing HTML injection. On self-hosted instances without a strict CSP, an attacker could use an SVG use element to bypass DOMPurify and achieve XSS in Firefox and Safari.

GitLab

Originally disclosed on GitLab

  • Fixed in 6 months
  • Disclosed after 6 months

⚠️ 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 #2655757 by joaxcar on 2024-08-14, assigned to @kmorrison1:

Report | Attachments | How To Reproduce

Report

Summary

HTML injection in issue page when adding Child item. Leading to XSS on self-hosted instances without proper CSP

See this code

HTML
 formatResults(input) {  
      if (!this.searchTerm) {  
        return input;  
      }  
      return highlighter(`<span class="gl-text-black-normal">${input}</span>`, this.searchTerm);  
    },  
...  
<div v-safe-html="formatResults(dropdownItem.title)" class="gl-text-truncate"></div>  

where dropdownItem.title ends up in v-safe-html

This allows an attacker to inject any HTML that can get through DOMPurify to the page. As shown in https://hackerone.com/reports/2654010 its possible to use svg/use to bypass the current DOMPurify filter to gain XSS in Firefox and Safari.

Steps to reproduce

!! Use Firefox/Safari !!

  1. Create a new group called group1 (public)
  2. Create a subgroup in group1 called assets (public)
  3. Open dev-tools and go to the inspector and search in the DOM for assets/icons- find any url that looks like this /assets/icons-454317f5123bdb93dcb695c6092c458fb0ec6c862d0a56857aefa1c73469f743.svg#sidebar (the long hash value will depend on the gitlab instance) copy the icons-<hash>.svg name
  4. In group1/assets/ create a project called icons-<hash>.svg (the full hash name from step 3) (public)
  5. In the new project create a file called test.svg with this content
SVG
<?xml version="1.0"?>    
<svg id="main" xmlns="http://www.w3.org/2000/svg">    
    <image href="1" onerror="alert(document.domain)" />    
</svg>  
  1. Go back to the main group group1 and create a new project called project1 (public)
  2. In project1 create a new issue, call it issue1
  3. When issue1 is created you land on the issue page, now click Add->New Task and name the new task
<svg><use href="..\..\..\assets/icons-<hash>.svg/-/raw/main/test.svg#main"/></svg>  

where you replace <hash> with the hash from step 3 (!! important)
9. Now go to group1/project1/-/issues/new again and create a new issue issue2
10. When the new issue is created click Add->Existing Task
11. The alert should pop

In an attack scenario, its a victim user that created the issue2 but this shows the injection

In this image I have disabled CSP on gitlab.com

Screenshot_2024-08-14_at_09.14.48.png
Screenshot_2024-08-14_at_09.14.48.png From the original on GitLab

What is the current bug behavior?

User-controlled content is sent directly into v-safe-html

What is the expected correct behavior?

Task name should be HTML escaped

Impact

HTML injection on gitlab.com and XSS on self-hosted servers

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

Root cause

Likely the task title was inserted into v-safe-html without sufficient sanitisation, and the sanitiser could be bypassed with an SVG use element.

Impact

HTML injection occurred on gitlab.com, and XSS could occur on self-hosted servers that lack a proper CSP; the exploit worked in Firefox and Safari.

What the attacker needed

Self-hosted instance without strict CSP; Firefox or Safari browser; attacker can create public projects and issues; victim views the issue page

The fix

Task names should be HTML-escaped before being rendered.

How it was found

  1. Create a public group and a public subgroup called assets.
  2. Find an asset icon URL in the page source and note the hashed SVG filename.
  3. Create a public project named after that hashed SVG file and add a malicious SVG file.
  4. Create a public project with an issue, then add a new task whose name contains an SVG use element pointing to the malicious file.
  5. Create a second issue and use Add->Existing Task to trigger the payload.

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 task name is shown in a search dropdown without proper cleaning, so special code in a task name could run in another user's browser on some servers.

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.