Semi-blind SSRF using editor privileges in embedded Grafana
Grafana's alert notification webhook feature allowed users with Editor privileges to make server-side requests to arbitrary internal URLs, bypassing GitLab's SSRF protections. An attacker could send requests to local services, such as reloading Alertmanager or port scanning, by crafting a webhook with a custom HTTP method.
GitLab
Originally disclosed on GitLab
- Fixed in 13 days
- Disclosed after 13 days
HackerOne report #1034456 by myster on 2020-11-14, assigned to @cmaxim:
Report | Attachments | How To Reproduce
Report
Hi Team!
Grafana (all versions) supports configuration of notification channels for alerts with various methods including HTTP Webhooks (https://grafana.com/docs/grafana/latest/alerting/notifications/#webhook)
This allows users with at least Editor rights (less privileged than Admin) in Grafana to perform SSRF attacks on local instance and local network.
In the web interface Grafana limits the allowed methods to POST and PUT however by using curl or any other client, GET method or really any other method can also be specified making it possible to port scan local network.
Steps to reproduce:
- Enable alerting (https://gitlab.com/gitlab-org/gitlab/-/issues/28612) and create an editor user in Grafana (https://grafana.com/docs/grafana/latest/permissions/organization_roles/#editor-role).
Editor permissions at glance:
Can view, add, and edit dashboards, panels, and alert rules in dashboards they have access to. This can be disabled on specific folders and dashboards.
Can create, update, or delete playlists.
Can access Explore.
Cannot add, edit, or delete data sources.
Cannot add, edit, or delete alert notification channels.
Cannot manage other organizations, users, and teams.
I have for instance given multiple users editor permissions on my Gitlab grafana instance so that they can primarily edit dashboards and alerts. It is a regular use case as this is below admin user in terms of permissions.
-
Visit https://gitlab/alerting/notifications and create a webhook type of notification channel, something like in attached image notification.png
-
The request I have crafted in this screenshot sends a
reloadcommand to alertmanager and results in a reload of alertmanager process, demonstrating the first SSRF -
Second vector will be to modify the POST request for
api/alert-notifications/testto provide our own method i.eGETwhich may be used for port scanning.
Request would look like following:
curl 'http://localhost/-/grafana/api/alert-notifications/test' -H 'User-Agent: Mozilla/5.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://localhost/-/grafana/alerting/notification/new' -H 'content-type: application/json' -H 'x-grafana-org-id: 1' -H 'Origin: http://localhost' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Cookie: grafana_session=$session_id; known_sign_in=$id; sidebar_collapsed=false; _gitlab_session=$session' -H 'Sec-GPC: 1' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw '{"name":"test","type":"webhook","frequency":"15m","settings":{"httpMethod":"GET","autoResolve":true,"severity":"critical","uploadImage":false,"url":"http://localhost:3000/-/reload"}}'
{"message":"Test notification sent"}
A message saying Test notification sent means the port is open and service running there responded with a 200. This allows a bypass of SSRF protection mechanisms in place in Gitlab itself disallowing local networks.
- Depending on other services running locally and features enabled, it may also be abused to perform operations like:
Prometheus admin actions:
- Taking prometheus data snapshot: https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis
- Deleting a series in prometheus: https://prometheus.io/docs/prometheus/latest/management_api/
Alertmanager actions:
- v1 api: https://prometheus.io/docs/alerting/latest/management_api/
- v2 api: https://github.com/prometheus/alertmanager/blob/master/api/v2/openapi.yaml (because method
POSTis also allowed, it can be used to delete silences etc)
Making redis exporter scrape any target:
- http://localhost:9121/scrape?target=redis://127.0.0.1:7001&check-keys=* (https://rhynorater.github.io/CVE-2020-13379-Write-Up)
I will be happy to probe further about possible impact on other APIs available only from localhost.
Please review.
Thanks!
Impact
- SSRF protection bypass
- Arbitrary requests to internal services as demonstrated above
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
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 webhook notification feature did not restrict the target URL or HTTP method, allowing Editor users to make arbitrary requests from the Grafana server.
Impact
An attacker with Editor privileges could bypass SSRF protections to send arbitrary requests to internal services, potentially performing actions like reloading Alertmanager, port scanning, or interacting with Prometheus and Redis exporter.
What the attacker needed
Editor privileges in Grafana; Alerting enabled
How it was found
- Enable alerting and create an editor user in Grafana.
- Visit the alerting notifications page and create a webhook notification channel.
- Craft a request to send a reload command to alertmanager, demonstrating SSRF.
- Modify the POST request for testing notifications to use a GET method for port scanning.
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.
Grafana lets users set up alerts that send webhooks to other services. The problem was that users with limited 'Editor' permissions could make the Grafana server send requests to any internal address, even though GitLab tried to block such requests. This could let an attacker interact with internal services that are not normally reachable from the internet.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.