# CVE-2022-31107: Grafana account takeover via OAuth vulnerability

> Attackers can take over other users' accounts by manipulating OAuth login names if specific account linking conditions are met.

- **Severity:** High 7.1 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 Jul 2022
- **Updated:** 28 Jan 2026
- **Also known as:** ALSA-2022:5716, ALSA-2022:5717, BIT-grafana-2022-31107, GHSA-mx47-6497-3fv2, GO-2024-2852, MINI-3hm7-3m35-8856, MINI-47g7-hj9x-v656, MINI-4q9c-p752-8qj4, MINI-5hm2-79xj-x3jq, MINI-78m2-44r6-g54c, MINI-7j3h-j3jc-4qgp, MINI-7q9j-mprp-x6xr, MINI-85hc-xc2m-v9fm, MINI-8rwq-cxmm-37q4, MINI-9rfv-7fwv-qjgw, MINI-grrf-8pp3-242q, MINI-h68h-5p85-qrv5, MINI-h8qw-xgjh-hg6f, MINI-hj3r-r78g-mmqm, MINI-rvrw-hp6m-rc4w, MINI-x8pq-qqj7-vh25, MINI-xhw5-fq66-p5qf, OESA-2022-1870, RHSA-2022:5716, RHSA-2022:5717, RHSA-2022:5718, RHSA-2022:5719, RHSA-2022:5720, RLSA-2022:5716, RLSA-2022:5717, UBUNTU-CVE-2022-31107

## What is CVE-2022-31107?

CVE-2022-31107 is a high-severity authentication bypass vulnerability in Grafana Grafana, published on 15 Jul 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

Grafana is an open-source platform for monitoring and observability. In versions 5.3 until 9.0.3, 8.5.9, 8.4.10, and 8.3.10, it is possible for a malicious user who has authorization to log into a Grafana instance via a configured OAuth IdP which provides a login name to take over the account of another user in that Grafana instance. This can occur when the malicious user is authorized to log in to Grafana via OAuth, the malicious user's external user id is not already associated with an account in Grafana, the malicious user's email address is not already associated with an account in Grafana, and the malicious user knows the Grafana username of the target user. If these conditions are met, the malicious user can set their username in the OAuth provider to that of the target user, then go through the OAuth flow to log in to Grafana. Due to the way that external and internal user accounts are linked together during login, if the conditions above are all met then the malicious user will be able to log in to the target user's Grafana account. Versions 9.0.3, 8.5.9, 8.4.10, and 8.3.10 contain a patch for this issue. As a workaround, concerned users can disable OAuth login to their Grafana instance, or ensure that all users authorized to log in via OAuth have a corresponding user account in Grafana linked to their email address.

Weakness: CWE-863 (Incorrect Authorization)

## Which versions are affected by CVE-2022-31107?

10 open source packages ship an affected version, including github.com/grafana/grafana and grafana. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/grafana/grafana` | Go | All versions | None |
| `github.com/grafana/grafana` | Go | From 5.3.0-beta1 | 8.3.10 |
| `github.com/grafana/grafana` | Go | From 5.3.0-beta1 | 8.3.10 |
| `github.com/grafana/grafana` | Go | From 8.4.0 | 8.4.10 |
| `github.com/grafana/grafana` | Go | From 8.4.0 | 8.4.10 |
| `github.com/grafana/grafana` | Go | From 8.5.0 | 8.5.9 |
| `github.com/grafana/grafana` | Go | From 8.5.0 | 8.5.9 |
| `github.com/grafana/grafana` | Go | From 9.0.0 | 9.0.3 |
| `github.com/grafana/grafana` | Go | From 9.0.0 | 9.0.3 |
| `grafana` | Bitnami | From 5.3.0 | 8.3.10, 8.4.10, 8.5.9, 9.0.3 |
| `grafana` | AlmaLinux:8 | All versions | 7.5.11-3.el8_6 |
| `grafana` | AlmaLinux:9 | All versions | 7.5.11-5.el9_0 |
| `grafana` | Red Hat:enterprise_linux:8::appstream | All versions | 0:7.5.11-3.el8_6 |
| `grafana-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:7.5.11-3.el8_6 |
| `grafana` | Red Hat:enterprise_linux:9::appstream | All versions | 0:7.5.11-5.el9_0 |
| `grafana-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:7.5.11-5.el9_0 |
| `grafana` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-azure-monitor` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-cloudwatch` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-debuginfo` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-elasticsearch` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-graphite` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-influxdb` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-loki` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-mssql` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-mysql` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-opentsdb` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-postgres` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-prometheus` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana-stackdriver` | Red Hat:rhel_e4s:8.1::appstream | All versions | 0:6.2.2-9.el8_1 |
| `grafana` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-azure-monitor` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-cloudwatch` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-debuginfo` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-elasticsearch` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-graphite` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-influxdb` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-loki` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-mssql` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |
| `grafana-mysql` | Red Hat:rhel_eus:8.2::appstream | All versions | 0:6.3.6-5.el8_2 |

Products: Grafana Grafana, Netapp E-Series Performance Analyzer.

## How do I fix CVE-2022-31107?

Upgrade github.com/grafana/grafana to a fixed version for your release line: 8.3.10, 8.4.10, 8.5.9 or 9.0.3.

## Is CVE-2022-31107 being exploited?

There is no known exploitation of CVE-2022-31107 in the wild and no public exploit code.

## Other vulnerabilities in Grafana Grafana

- [CVE-2021-43798](https://insights.sbomify.com/CVE-2021-43798/): Grafana Path Traversal (high 7.5, exploited in the wild)
- [CVE-2025-41115](https://insights.sbomify.com/CVE-2025-41115/): Incorrect privilege assignment (critical 10.0)
- [CVE-2022-39328](https://insights.sbomify.com/CVE-2022-39328/): Grafana vulnerable to race condition allowing privilege escalation (critical 9.8)
- [CVE-2022-28660](https://insights.sbomify.com/CVE-2022-28660/): Auth bypass in n/a (critical 9.8)
- [CVE-2022-26148](https://insights.sbomify.com/CVE-2022-26148/): Information disclosure in n/a (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-31107 and fix it if it is affected.

What it is: CVE-2022-31107 is a high-severity authentication bypass vulnerability in Grafana Grafana, published on 15 Jul 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-31107 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/grafana/grafana (Go): affected all versions; no fix listed
- github.com/grafana/grafana (Go): affected from 5.3.0-beta1; fixed in 8.3.10
- github.com/grafana/grafana (Go): affected from 5.3.0-beta1; fixed in 8.3.10
- github.com/grafana/grafana (Go): affected from 8.4.0; fixed in 8.4.10
- github.com/grafana/grafana (Go): affected from 8.4.0; fixed in 8.4.10
- github.com/grafana/grafana (Go): affected from 8.5.0; fixed in 8.5.9
- github.com/grafana/grafana (Go): affected from 8.5.0; fixed in 8.5.9
- github.com/grafana/grafana (Go): affected from 9.0.0; fixed in 9.0.3
- github.com/grafana/grafana (Go): affected from 9.0.0; fixed in 9.0.3
- grafana (Bitnami): affected from 5.3.0; fixed in 8.3.10, 8.4.10, 8.5.9, 9.0.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-31107/ (Markdown: https://insights.sbomify.com/CVE-2022-31107/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-31107
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-31107
- OSV: https://osv.dev/vulnerability/CVE-2022-31107

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-31107/
Summaries are generated and may contain mistakes; the official description above is the record.
