Skip to content
XSS Disclosed report Intermediate

Cross-site scripting in "Maximum page reached" page affecting self-hosted instances running without strict CSP

The 'Maximum page reached' page used unfiltered request parameters to build a link, allowing an attacker to inject a javascript: URL and execute arbitrary JavaScript on self-hosted instances without a strict CSP. On GitLab.com, CSP blocked the execution.

GitLab

Originally disclosed on GitLab

  • Fixed in 6 months
  • Disclosed after 6 months

HackerOne report #1728015 by ryotak on 2022-10-10, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

Due to the use of non-filtered params in the Maximum page reached page, an attacker can execute arbitrary JavaScript on the self-hosted instances running without strict CSP.

Description

In app/views/explore/projects/page_out_of_bounds.html.haml, the following code is used to generate a link to return to the explore page.

app/views/explore/projects/page_out_of_bounds.html.haml line 21

Ruby
      = link_to _("Back to page %{number}") % { number: [@]max_page_number }, request.params.merge(page: [@]max_page_number), class: 'gl-button btn btn-inverted'  

As request.params instead of safe_params is used to pass parameters to link_to, arbitrary parameters can be passed here.
Since link_to supports parameters such as protocol or host, it's possible to inject javascript: URLs and achieves XSS.

Steps to reproduce
Self-hosted instance (with an alert)
  1. Set up your own GitLab instance.
  2. Open https://YOUR_OWN_INSTANCE/explore/projects?page=51&protocol=javascript&host=%250dalert(document.domain)//
  3. Click Back to page 50
  4. Confirm that alert(document.domain) has been executed.
GitLab.com (with a CSP error message)
  1. Open https://gitlab.com/explore/projects?page=51&protocol=javascript&host=%250dalert(document.domain)//
  2. Open DevTools.
  3. Click Back to page 50.
  4. Confirm that CSP prevented the execution of JavaScript.
Examples

https://gitlab.com/explore/projects?page=51&protocol=javascript&host=%250dalert(document.domain)//

What is the current bug behavior?

request.params is used, which may include dangerous parameters.

What is the expected correct behavior?

safe_params should be used to filter the dangerous parameters.

Relevant logs and/or screenshots
2022-10-10_14-45-24.mp4 From the original on GitLab
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.4.1-ee  
Revision:       7b2ed8f038f  
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.10.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

Root cause

The application passed unfiltered request parameters directly to a link helper, allowing dangerous parameters like protocol and host to be injected.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser and perform actions on their behalf, but only on self-hosted instances without a strict CSP; GitLab.com's CSP prevented execution.

What the attacker needed

Self-hosted GitLab instance; no strict CSP; victim clicks a crafted link

The fix

The code should use safe_params instead of request.params to filter dangerous parameters.

How it was found

  1. Set up your own GitLab instance.
  2. Open a crafted URL with page, protocol, and host parameters.
  3. Click the 'Back to page 50' link.
  4. Confirm 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.

When you visit a page that says you've gone too far, the site builds a 'back' link using values from the web address. Because it didn't clean those values, an attacker could craft a link that makes the 'back' button run malicious code in your browser. This only worked on self-hosted GitLab servers that didn't have a security feature called CSP turned on.

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.