SSRF in Prometheus integration
The Prometheus integration in GitLab blocked direct localhost URLs but did not re-check after an HTTP redirect, allowing an attacker to supply an external URL that redirects to an internal address. This could let an attacker make requests to internal services, including localhost.
GitLab
Originally disclosed on GitLab
- Fixed in 33 days
- Disclosed after 33 days
HackerOne report #427364 by bull on 2018-10-23:
Hi,
I have found an issue which can be used by an attacker to make internal request to localhost i.e 127.0.0.1 and all local ip range.
Issue:
So the problem here is it blocks localhost url input, but providing external links and if it redirects, the gitlab doesn't make any check after redirect and make request to internal network. i can also evade path with #
POC:
- log into gitlab and create project and go to integrations
- now go to the prometheus integration and enter in the api url
http://bullbucket.s3-website-us-east-1.amazonaws.com/scuscscnhfdfssadqdqwhich redirects tohttp://127.0.0.1:12345/ssrf/dbvdbhvdb/local# - open netcat at port
12345in gitlab ee to check if request is really made to internal network or not.
Please let me know if you need any more information or if i missed something Thanks @bull
Impact
access to internal services
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
Fix
Security issue: https://dev.gitlab.org/gitlab/gitlabhq/issues/2736
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 application validated the initial URL but did not validate the final destination after following HTTP redirects.
Impact
An attacker could access internal services, including localhost, by redirecting requests to internal addresses.
What the attacker needed
A GitLab account; ability to create a project and configure integrations; an external server that redirects to an internal address
The fix
A GitLab issue is linked for the security issue.
How it was found
- Log into GitLab and create a project, then go to integrations.
- Go to the Prometheus integration and enter an external API URL that redirects to an internal address.
- Open netcat on the internal port to check if a request is made to the internal network.
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 server-side request forgery (SSRF) bug. The application lets a user provide a URL that the server will fetch. The server tried to block internal addresses like [redacted], but if the external URL redirects to an internal address, the server follows the redirect without checking again, so it ends up making a request to an internal service.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.