GHSA-69j6-29vr-p3j9 BIT-grafana-2021-39226 GHSA-69j6-29vr-p3j9
Authentication bypass for viewing and deletions of snapshots
- Severity
- 7.3 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 99.93%
- Chance of exploitation in the next 30 days. Higher than 99.97% of scored vulnerabilities.
- Known exploited
- Yes
- In CISA's catalog
- Fix
7.5.11- Upgrade github.com/grafana/grafana to this version or later
Description
Today we are releasing Grafana 7.5.11, and 8.1.6. These patch releases include an important security fix for an issue that affects all Grafana versions from 2.0.1.
Grafana Cloud instances have already been patched and an audit did not find any usage of this attack vector. Grafana Enterprise customers were provided with updated binaries under embargo.
8.1.5 contained a single fix for bar chart panels. We believe that users can expedite deployment by moving from 8.1.4 to 8.1.6 directly.
CVE-2021-39226 Snapshot authentication bypass
Summary
CVSS Score: 9.8 Critical CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
We received a security report to security@grafana.com on 2021-09-15 about a vulnerability in Grafana regarding the snapshot feature. It was later identified as affecting Grafana versions from 2.0.1 to 8.1.6. CVE-2021-39226 has been assigned to this vulnerability.
Impact
Unauthenticated and authenticated users are able to view the snapshot with the lowest database key by accessing the literal paths:
/dashboard/snapshot/:key, or/api/snapshots/:key
If the snapshot "public_mode" configuration setting is set to true (vs default of false), unauthenticated users are able to delete the snapshot with the lowest database key by accessing the literal path:
/api/snapshots-delete/:deleteKey
Regardless of the snapshot "public_mode" setting, authenticated users are able to delete the snapshot with the lowest database key by accessing the literal paths:
/api/snapshots/:key, or/api/snapshots-delete/:deleteKey
The combination of deletion and viewing enables a complete walk through all snapshot data while resulting in complete snapshot data loss.
Attack audit
While we can not guarantee that the below will identify all attacks, if you do find something with the below, you should consider doing a full assessment.
Through reverse proxy/load balancer logs
To determine if your Grafana installation has been exploited for this vulnerability, search through your reverse proxy/load balancer access logs for instances where the path is /dashboard/snapshot/:key, /api/snapshots/:key or /api/snapshots-delete/:deleteKey, and the response status code was 200 (OK).
For example, if you’re using the Kubernetes ingress-nginx controller and sending logs to Loki, use a LogQL query like {job="nginx-ingress-controller"} |= "\"status\": 200" |= "\"uri\": \"/api/snapshots/:key\"".
Through the Grafana Enterprise audit feature
If you enabled “Log web requests” in your configuration with router_logging = true, look for
"requestUri":"/api/snapshots-delete/”,“requestUri":"/api/snapshots/:key", or "type":"snapshot" in combination with "action":"delete".
Patched versions
Release 8.1.6:
Release 7.5.11:
Solutions and mitigations
Download and install the appropriate patch for your version of Grafana.
Grafana Cloud instances have already been patched, and Grafana Enterprise customers were provided with updated binaries under embargo.
Workaround
If for some reason you cannot upgrade:
You can use a reverse proxy or similar to block access to the literal paths
/api/snapshots/:key/api/snapshots-delete/:deleteKey/dashboard/snapshot/:key/api/snapshots/:key
They have no normal function and can be disabled without side effects.
Timeline and postmortem
Here is a detailed timeline starting from when we originally learned of the issue. All times in UTC.
- 2021-09-15 14:49: Tuan Tran theblackturtle0901@gmail.com sends initial report about viewing snapshots without authentication
- 2021-09-15 15:56: Initial reproduction
- 2021-09-15 17:10: MEDIUM severity declared
- 2021-09-15 18:58: Workaround deployed on Grafana Cloud
- 2021-09-15 19:15:
/api/snapshots/:keyfound to be vulnerable as well - 2021-09-15 19:30:
/api/snapshots/:keyblocked on Grafana Cloud - 2021-09-16 09:31:
/api/snapshots-delete/:deleteKeyfound to be vulnerable as well, blocked on Grafana Cloud. From this point forward, Cloud is not affected any more. - 2021-09-16 09:35: HIGH severity declared
- 2021-09-16 11:19: Realization that combination of deletion and viewing allows enumeration and permanent DoS
- 2021-09-16 11:19: CRITICAL declared
- 2021-09-17 10:53: Determination that no weekend work is needed. While issue is CRITICAL, scope is very limited
- 2021-09-17 14:26: Audit of Grafana Cloud concluded, no evidence of exploitation
- 2021-09-23: Grafana Cloud instances updated
- 2021-09-28 12:00: Grafana Enterprise images released to customers under embargo
- 2021-10-05 17:00: Public release
Reporting security issues
If you think you have found a security vulnerability, please send a report to security@grafana.com. This address can be used for all of Grafana Labs's open source and commercial products (including but not limited to Grafana, Tempo, Loki, Amixr, k6, Tanka, and Grafana Cloud, Grafana Enterprise, and grafana.com). We only accept vulnerability reports at this address. We would prefer that you encrypt your message to us using our PGP key. The key fingerprint is:
F988 7BEA 027A 049F AE8E 5CAA D125 8932 BE24 C5CA
The key is available from keys.gnupg.net by searching for [security@grafana](http://keys.gnupg.net/pks/lookup?search=security@grafana&fingerprint=on&op=index.
Security announcements
We maintain a category on the community site named Security Announcements, where we will post a summary, remediation, and mitigation details for any patch containing security fixes. You can also subscribe to email updates to this category if you have a grafana.com account and sign in to the community site, or via updates from our Security Announcements RSS feed.
Acknowledgement
We would like to thank Tran Viet Tuan for responsibly disclosing the initially discovered vulnerability to us.
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/grafana/grafana | < 7.5.11 |
7.5.11 |
| github.com/grafana/grafana | >= 8.0.0, < 8.1.6 |
8.1.6 |
| github.com/grafana/grafana | < 7.5.11 |
7.5.11 |
| github.com/grafana/grafana | >= 8.0.0, < 8.1.6 |
8.1.6 |
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 → 7.5.11
- go
go get github.com/grafana/grafana@v7.5.11 && go mod tidy
Severity breakdown
CVSS 3.1 7.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L/E:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- Low
- Integrity
- Low
- Availability
- Low
- Exploit maturity
- H
Weakness
CWE-287: Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
How to prevent it
- Architecture and Design: Use an authentication framework or library such as the OWASP ESAPI Authentication feature.
CWE-862: Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
How to prevent it
- Architecture and Design: Divide the product into anonymous, normal, privileged, and administrative areas. Reduce the attack surface by carefully mapping roles with data and functionality. Use role-based access control (RBAC) [REF-229] to enforce the roles at the appropriate boundaries. Note that this approach may not protect against horizontal authorization, i.e., it will not protect a user from attacking others with the same role.
- Architecture and Design: Ensure that access control checks are performed related to the business logic. These checks may be different than the access control checks that are applied to more generic resources such as files, connections, processes, memory, and database records. For example, a database may restrict access for medical records to a specific database user, but each record might only be intended to be accessible to the patient and the patient's doctor [REF-7].
- Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using authorization frameworks such as the JAAS Authorization Framework [REF-233] and the OWASP ESAPI Access Control feature [REF-45].
- Architecture and Design: For web applications, make sure that the access control mechanism is enforced correctly at the server side on every page. Users should not be able to access any unauthorized functionality or information by simply requesting direct access to that page. One way to do this is to ensure that all pages containing sensitive information are not cached, and that all such pages restrict access to requests that are accompanied by an active and authenticated session token associated with a user who has the required permissions to access that page.
- System Configuration, Installation: Use the access control capabilities of your operating system and server environment and define your access control lists accordingly. Use a "default deny" policy when defining these ACLs.
References
Advisories
Fixes and patches
Packages
Other links
- openwall.com/lists/oss-security/2021/10/05/4
- grafana.com/docs/grafana/latest/release-notes/release-notes-7-5-11
- grafana.com/docs/grafana/latest/release-notes/release-notes-8-1-6
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/DCK…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/E6A…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DCKBF…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/E6ANH…
- security.netapp.com/advisory/ntap-20211029-0008
- cisa.gov/known-exploited-vulnerabilities-catalog
- grafana.com/docs/grafana/latest/release-notes/release-notes-7-5-11
- grafana.com/docs/grafana/latest/release-notes/release-notes-8-1-6
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/DCK…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/E6A…
Timeline
- Published
- Last updated by the source
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-8pjx-jj86-j47p Grafana path traversal | 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 |
| GHSA-p5x9-j974-rpfp Grafana legacy correlations allow cross-tenant disclosure and deletion | Low | Also affects github.com/grafana/grafana |
Credits: theblackturtle
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