Write-up · 3 min read

GrafanaWrite-up

CVE-2022-21713: an IDOR in Grafana's Teams API

Three Teams API endpoints in Grafana returned team data to users who should not see it. What the flaw was, how the fix shipped in 21 days, and how to test for the same class of bug.

By Kursad AlsanPublished 3 min read

  • IDOR/BOLA
  • API security
  • Grafana
  • Disclosure
CVSS 3.1, medium
4.3
report to public release
21 days
endpoints affected
3
fixed in, with 7.5.15
8.3.5

The short version

  • Grafana's Teams API required a signed-in user but did not properly check whether that user could see the team they asked for.
  • Three endpoints were affected: team details, team search (which counted teams the user could not access) and, with editors_can_admin on, team members.
  • Rated 4.3 (Medium) and fixed in Grafana 8.3.5 and 7.5.15, 21 days after my report.

In January 2022 I reported an authorization flaw in Grafana's Teams API. Grafana confirmed it within three days, issued CVE-2022-21713 and shipped the fix in Grafana 8.3.5 and 7.5.15. This post covers what was wrong, how the disclosure ran and how to test your own APIs for the same class of bug.

What was wrong

Grafana groups users into teams, and teams carry permissions on dashboards and folders. Grafana's advisory describes the flaw as an insecure direct object reference (IDOR): the Teams API took a team ID or a search from any authenticated user without properly handling authorization, so it returned data the caller was not meant to see.

EndpointWhat an authenticated attacker could do
/teams/:teamIdView unintended data by querying a team ID.
/teams/:searchSee the total number of teams, including teams they cannot access.
/teams/:teamId/membersWith editors_can_admin enabled, see unintended member data.
From Grafana's advisory.

Nothing here let an attacker change data: the advisory scores integrity and availability impact as none. But team names, team counts and membership describe how an organization is structured, which is useful to anyone planning a next step.

The request flow

  1. AccessAuthenticated userlow privileges (PR:L)
  2. RequestQueries a team ID/teams/:teamIdattacker in control
  3. FlawIDOR in the Teams APIinsecure direct object reference
  4. ImpactUnintended team dataconfidentiality: low (C:L)
1 of 4 hops is attacker-controlled.

Every step is stated in Grafana's advisory.

Severity

4.3MediumCVSS 3.1 base score
  • Attack vectorNetwork
  • Attack complexityLow
  • Privileges requiredLow
  • User interactionNone
  • ScopeUnchanged
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N

Reachable over the network, low complexity and needing only a low-privileged account, but limited to reading some data: a 4.3, Medium.

Disclosure timeline

21 days from report to public release

  1. Reported to Grafana

    My report included reproducible request evidence and an impact analysis.

  2. 3 days later:

    Confirmed reproducible
  3. 3 days later:

    CVE issued, fix PR opened
  4. 1 day later:

    Private release
  5. 14 days later:

    Public release: Grafana 8.3.5 and 7.5.15

    Grafana announced the fixes on its blog the same day.

Dates from Grafana's advisory, UTC.

Three days to confirm, a CVE and a fix within a week, and a coordinated public release two weeks later: a fast, orderly disclosure on Grafana's side.

How to test for this class

In APIs, IDOR goes by BOLA, broken object level authorization, and it is number one on the OWASP API Security Top 10. It is simple to test and easy to miss:

  1. Use two accounts

    Two low-privileged users in different teams or tenants. Everything below runs as user A against objects that belong to user B.

  2. Map the object IDs

    Collect every ID the API exposes: teams, users, dashboards, folders. Sequential IDs make guessing trivial, and random IDs still leak through search results, URLs and logs.

  3. Replay across users

    Request user B's objects with user A's session. Any response with B's data is a finding, and so is an error that confirms the object exists.

  4. Check lists, searches and counts

    Search endpoints often filter the items but not the totals. A count that includes objects you cannot see is a leak, as /teams/:search showed.

  5. Toggle the configuration

    Authorization code branches on settings. The members endpoint leaked only with editors_can_admin enabled, so test optional flags both on and off.

  6. Write it so it reproduces

    Exact requests, both accounts' roles, the response that proves access, and the impact in one sentence.

two-account check
# user A belongs to team 1 only; team 2 is someone else's
GET /api/teams/2 HTTP/1.1
Host: grafana.example.com
Cookie: grafana_session=<user A>

# a vulnerable version answered with team 2's details;
# a fixed version refuses the request
An illustration of the test, not a request from the original report. Grafana's HTTP API serves teams under /api/teams.

If you run Grafana

Every version from 5.0.0-beta1 up to the fix was affected. Grafana 8.3.5 and 7.5.15 fixed it (pull request #45083), and every later release includes the fix. Grafana Cloud was patched, and licensed cloud providers, including Amazon Managed Grafana, were notified under embargo.

Sources

Keep reading

All posts

On the research page

Need an API authorization review?

Web application and API penetration testing, with reproducible evidence.