# CVE-2024-9264: Grafana SQL Expressions allow for remote code execution

> Attackers with viewer permissions can execute arbitrary commands and read local files via unsanitized SQL expressions if the duckdb binary is installed.

- **Severity:** Critical 9.4 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H`)
- **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:** 18 Oct 2024
- **Updated:** 14 Mar 2025
- **Also known as:** BIT-grafana-2024-9264, GHSA-q99m-qcv4-fpm7, GO-2024-3215, MINI-46wj-669r-wqqp, MINI-72gw-xxrx-hqq8, MINI-777w-phrm-h39p, MINI-7pf4-x5fj-gg9x, MINI-9jcp-6jhq-rfwq, MINI-9p88-ch6f-mxx4, MINI-c3xc-54hr-hcr2, MINI-chgp-8xpm-mrm2, MINI-cxf5-f737-259f, MINI-hp3r-mhmp-cm9r, MINI-hqq2-whrr-6hr2, MINI-j5v3-xv6p-wvgr, MINI-m3r5-rwg8-8cwg, MINI-p45f-gm69-5qh4, MINI-pvxh-f4rp-qgrc, MINI-qp4g-xxmm-4m9x, MINI-rmrw-592m-6gpv, UBUNTU-CVE-2024-9264

## What is CVE-2024-9264?

CVE-2024-9264 is a critical command injection vulnerability in Grafana Grafana, published on 18 Oct 2024. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

The SQL Expressions experimental feature of Grafana allows for the evaluation of `duckdb` queries containing user input. These queries are insufficiently sanitized before being passed to `duckdb`, leading to a command injection and local file inclusion vulnerability. Any user with the VIEWER or higher permission is capable of executing this attack.  The `duckdb` binary must be present in Grafana's $PATH for this attack to function; by default, this binary is not installed in Grafana distributions.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-94 (Improper Control of Generation of Code)

## Which versions are affected by CVE-2024-9264?

8 open source packages ship an affected version, including github.com/grafana/grafana and grafana. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/grafana/grafana` | Go | All versions | None |
| `github.com/grafana/grafana` | Go | From 11.0.0 | 11.0.6+security-01 |
| `github.com/grafana/grafana` | Go | From 11.0.0 | 11.0.6+security-01 |
| `github.com/grafana/grafana` | Go | From 11.1.0 | 11.1.7+security-01 |
| `github.com/grafana/grafana` | Go | From 11.1.0 | 11.1.7+security-01 |
| `github.com/grafana/grafana` | Go | From 11.2.0 | 11.2.2+security-01 |
| `github.com/grafana/grafana` | Go | From 11.2.0 | 11.2.2+security-01 |
| `grafana` | Bitnami | From 11.0.0 | 11.2.2 |

Products: Grafana Grafana.

## How do I fix CVE-2024-9264?

Upgrade github.com/grafana/grafana to a fixed version for your release line: 11.0.6+security-01, 11.1.7+security-01 or 11.2.2+security-01.

## Is CVE-2024-9264 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-9264 exists.

Public exploit code:

- Exploit for Grafana arbitrary file-read and RCE (CVE-2024-9264) (github_poc): https://github.com/nollium/CVE-2024-9264
- Grafana RCE exploit (CVE-2024-9264) (github_poc): https://github.com/z3k0sec/CVE-2024-9264-RCE-Exploit
- File Read Proof of Concept for CVE-2024-9264 (github_poc): https://github.com/z3k0sec/File-Read-CVE-2024-9264
- A go implementation for CVE-2024-9264 which effect grafana versions 11.0.x, 11.1.x, and 11.2.x.  (github_poc): https://github.com/Cythonic1/CVE-2024-9264
- Authenticated RCE in Grafana (v11.0) via SQL Expressions - PoC Exploit (github_poc): https://github.com/rvzsec/CVE-2024-9264
- Grafana SQL Expressions DuckDB Command Injection (metasploit)

## 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-2024-9264 and fix it if it is affected.

What it is: CVE-2024-9264 is a critical command injection vulnerability in Grafana Grafana, published on 18 Oct 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-9264 exists.

Affected packages and fixed versions:
- github.com/grafana/grafana (Go): affected all versions; no fix listed
- github.com/grafana/grafana (Go): affected from 11.0.0; fixed in 11.0.6+security-01
- github.com/grafana/grafana (Go): affected from 11.0.0; fixed in 11.0.6+security-01
- github.com/grafana/grafana (Go): affected from 11.1.0; fixed in 11.1.7+security-01
- github.com/grafana/grafana (Go): affected from 11.1.0; fixed in 11.1.7+security-01
- github.com/grafana/grafana (Go): affected from 11.2.0; fixed in 11.2.2+security-01
- github.com/grafana/grafana (Go): affected from 11.2.0; fixed in 11.2.2+security-01
- grafana (Bitnami): affected from 11.0.0; fixed in 11.2.2

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-2024-9264/ (Markdown: https://insights.sbomify.com/CVE-2024-9264/index.md)
```

## Sources

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

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