CVE-2024-9264
High · 8.8Grafana Command Injection And Local File Inclusion Via Sql Expressions
CVSS
8.8
EPSS
97.1%
Published
Oct 18, 2024
CISA due date
—
Cloudanix analysis
A regular Grafana user may be able to make the server read sensitive files or run commands, so affected systems should be updated and checked for abuse quickly.
- Exploitation
- Remote Authenticated
- Attacker needs
- Low Privilege
- Complexity
- Moderate
- Impact
- Remote Code Execution
- Component
- Application
- Class
- Command Injection
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
CVE-2024-9264 is a Grafana SQL Expressions flaw in which user-controlled input is insufficiently sanitized before being evaluated through DuckDB. An authenticated Grafana user with VIEWER or higher privileges can craft a SQL Expressions query that causes local file inclusion and, when the duckdb binary is available in Grafana's PATH, command injection. Successful exploitation can allow the attacker to read files accessible to the Grafana process and potentially execute operating-system commands as the Grafana service account. The issue is conditional on the experimental SQL Expressions feature and the presence of the duckdb binary, which is not installed by default in standard Grafana distributions.
Why it matters to the business
A low-privileged Grafana user account can potentially be turned into a foothold for server-side file theft or command execution. This can expose secrets stored on the Grafana host, data source credentials, configuration files, tokens, and other sensitive operational data, and may allow attackers to pivot into connected monitoring, cloud, or database environments. The vulnerability has weaponized exploit maturity and a very high EPSS score, so organizations running affected Grafana deployments should treat exposure as urgent even though it is not currently listed in CISA KEV. The affected product and fixed-version list supplied appears to reference Ubuntu kernel packages rather than Grafana; remediation should be based on Grafana vendor advisories and deployed Grafana versions, not unrelated kernel package versions.
How an attack unfolds
An attacker first obtains or compromises any Grafana account with VIEWER, EDITOR, or ADMIN permissions. They then identify whether SQL Expressions are enabled and whether the server can invoke duckdb from the Grafana process environment. The attacker submits a crafted request through Grafana's query APIs or UI-backed data query workflow that places malicious input into a SQL Expression. Because the input is not safely sanitized before DuckDB evaluation, the query can be abused to read local files or trigger command execution through the DuckDB execution path. If successful, the attacker retrieves sensitive files such as Grafana configuration, provisioned data source definitions, service account tokens, cloud credentials, or other files readable by the Grafana user. In a command-execution scenario, the attacker may stage a reverse shell, drop tooling, enumerate the host, harvest secrets, and pivot to systems reachable from the Grafana server.
How to fix it
Upgrade Grafana to a vendor-fixed release for the deployed major/minor branch. If immediate upgrade is not possible, disable the experimental SQL Expressions feature, remove duckdb from the Grafana service PATH if it is not explicitly required, and restrict Grafana access to trusted users and networks. Review all Grafana users and service accounts, especially accounts with VIEWER access that should not have broad visibility. Rotate secrets stored in or accessible by Grafana if exploitation is suspected, including data source credentials, API keys, service account tokens, cloud credentials, and database passwords. The fixed versions provided in the input are Ubuntu kernel package versions, such as linux 3.13.0-70.113 and linux-aws 4.4.0-1002.2, and do not correspond to the described Grafana vulnerability; do not treat those kernel updates as remediation for this Grafana issue.
How to confirm the fix worked
Confirm the running Grafana version is at or above the fixed version specified by Grafana for the installed branch. Verify SQL Expressions are disabled unless explicitly required. On the Grafana host, check whether duckdb is installed and reachable by the Grafana process using PATH inspection and package inventory. Validate that the Grafana service account cannot execute duckdb if the feature is not needed. Review Grafana configuration files, environment variables, systemd unit overrides, container images, and plugin/provisioning directories for references to SQL Expressions or DuckDB. Where safe and authorized, perform a non-destructive authenticated test using a low-privileged account to confirm crafted SQL Expression input is rejected or sanitized and cannot read local files. Recheck package inventories and container images after remediation to ensure older Grafana builds are not redeployed by automation.
Typical attack path
- Acquire valid Grafana credentials for a user with VIEWER or higher privileges.
- Confirm the target is running an affected Grafana version and that SQL Expressions are available.
- Check whether the duckdb binary is installed and reachable in the Grafana service PATH, either directly through exploitation attempts or indirectly through behavior and error responses.
- Send a crafted SQL Expressions query through Grafana query functionality, commonly via API requests associated with dashboard or panel queries.
- Use the injection to read local files accessible to the Grafana process or to execute commands as the Grafana service account.
- Extract Grafana configuration, data source credentials, tokens, or other secrets from the host.
- Use stolen credentials or command execution to move laterally, access connected data sources, or establish persistence.
How to detect it
Hunt for authenticated Grafana users issuing unusual query requests, especially to data/query APIs used by dashboards or panels. Useful sources include Grafana server logs, reverse proxy and load balancer access logs, Grafana audit logs if enabled, systemd journal logs for the grafana-server service, container stdout/stderr, endpoint detection telemetry, process creation logs, shell history for the Grafana service account, and file access telemetry. Look for POST requests to Grafana query endpoints containing SQL Expressions, DuckDB references, local filesystem paths, command separators, encoded shell metacharacters, or attempts to read common sensitive files. On hosts, investigate any grafana-server process spawning duckdb, shells, curl, wget, nc, bash, sh, python, perl, or other interpreters. Review for unexpected files written in temporary directories, web-accessible directories, Grafana plugin directories, and provisioning paths. Examine whether sensitive files such as Grafana configuration, data source provisioning YAML files, service account tokens, SSH keys, cloud metadata credentials, or /etc/passwd were accessed around suspicious request times. If threat hunting finds likely exploitation, assume Grafana-held credentials may be compromised and rotate them.
- POST /api/ds/query
- POST /api/ds/query?
- /api/ds/query
- duckdb
- DuckDB
- sqlExpression
- SQL Expressions
- read_csv_auto(
- read_text(
- read_json_auto(
- COPY
- ATTACH
- INSTALL
- LOAD
- /etc/passwd
- /etc/shadow
- /var/lib/grafana/grafana.db
- /etc/grafana/grafana.ini
- /etc/grafana/provisioning/datasources/
- /var/lib/grafana/plugins/
- /proc/self/environ
- /proc/1/environ
- /root/.ssh/id_rsa
- /home/grafana/.ssh/id_rsa
- aws_access_key_id
- AWS_ACCESS_KEY_ID
- BEGIN RSA PRIVATE KEY
- BEGIN OPENSSH PRIVATE KEY
- grafana-server
- grafana-server spawned duckdb
- grafana-server spawned /bin/sh
- grafana-server spawned /bin/bash
- grafana-server spawned curl
- grafana-server spawned wget
- grafana-server spawned nc
- grafana-server spawned python
- /tmp/duckdb
- /tmp/grafana
- ;curl
- ;wget
- |curl
- |wget
- && curl
- && wget
- `curl
- $(curl
What your security team should do
- Immediately inventory all Grafana instances, including containers, embedded appliances, managed deployments, and internal monitoring stacks.
- Prioritize internet-facing or broadly accessible Grafana instances for upgrade because exploit code is weaponized and the EPSS score is very high.
- Upgrade Grafana to the appropriate vendor-fixed release and ensure deployment pipelines cannot roll back to vulnerable images.
- Disable SQL Expressions if not required, and remove or isolate the duckdb binary from Grafana hosts where possible.
- Restrict Grafana access using SSO, MFA, network controls, and least-privilege role assignments; treat VIEWER accounts as potentially exploitable for this issue.
- Hunt for suspicious Grafana query activity, especially POST requests to query endpoints containing DuckDB-related syntax, local file paths, shell metacharacters, or attempts to access sensitive files.
- If exploitation is plausible, rotate Grafana data source credentials, service account tokens, API keys, and any secrets readable by the Grafana process.
- Review Grafana audit logs, web access logs, system logs, and endpoint telemetry for command execution, unexpected child processes, or file reads by the Grafana process.
- Do not rely on the Ubuntu kernel fixed versions listed in the supplied product metadata as a fix for this Grafana vulnerability; validate against Grafana-specific advisories.
The record
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.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Go | github.com/grafana/grafana | 0 | No fix |
| Go | github.com/grafana/grafana | 11.0.0 | 11.0.6+security-01 |
| Go | github.com/grafana/grafana | 11.1.0 | 11.1.7+security-01 |
| Go | github.com/grafana/grafana | 11.2.0 | 11.2.2+security-01 |
| Bitnami | grafana | 11.0.0 | 11.0.5 |
| Bitnami | grafana | 11.0.0 | 11.2.2 |
| Chainguard | grafana-11.0 | 0 | 11.0.7-r0 |
| Chainguard | grafana-fips-11.0 | 0 | 11.0.7-r0 |
| Chainguard | grafana-fips-11.0-oci-compat | 0 | 11.0.7-r0 |
| Chainguard | grafana-oci-compat | 0 | 11.0.7-r0 |
| SUSE:Linux Enterprise Module for Package Hub 15 SP5 | govulncheck-vulndb | 0 | 0.0.20241030T212825-150000.1.9.1 |
| SUSE:Linux Enterprise Module for Package Hub 15 SP6 | govulncheck-vulndb | 0 | 0.0.20241030T212825-150000.1.9.1 |
| SUSE:Linux Enterprise Module for Package Hub 15 SP6 | grafana | 0 | 11.5.5-150200.3.72.2 |
| SUSE:Linux Enterprise Module for Package Hub 15 SP7 | grafana | 0 | 11.5.5-150200.3.72.2 |
| SUSE:Linux Enterprise Server 12 SP5-LTSS | golang-github-prometheus-node_exporter | 0 | 1.9.1-1.36.2 |
| SUSE:Linux Enterprise Server LTSS Extended Security 12 SP5 | golang-github-prometheus-node_exporter | 0 | 1.9.1-1.36.2 |
| SUSE:Manager Client Tools 12 | golang-github-prometheus-alertmanager | 0 | 0.26.0-1.31.2 |
| SUSE:Manager Client Tools 12 | golang-github-prometheus-node_exporter | 0 | 1.9.1-1.36.2 |
| SUSE:Manager Client Tools 12 | golang-github-prometheus-prometheus | 0 | 2.53.4-1.60.2 |
| SUSE:Manager Client Tools 12 | grafana | 0 | 11.5.5-1.79.2 |
| SUSE:Manager Client Tools 12 | prometheus-blackbox_exporter | 0 | 0.26.0-1.27.1 |
| SUSE:Manager Client Tools 15 | golang-github-prometheus-prometheus | 0 | 2.53.4-150000.3.62.2 |
| SUSE:Manager Client Tools 15 | grafana | 0 | 11.5.5-150000.1.79.1 |
| SUSE:Manager Client Tools 15 | prometheus-blackbox_exporter | 0 | 0.26.0-150000.1.27.1 |
| SUSE:Manager Client Tools for SLE Micro 5 | prometheus-blackbox_exporter | 0 | 0.26.0-150000.1.27.1 |
| SUSE:Manager Proxy Module 4.3 | prometheus-blackbox_exporter | 0 | 0.26.0-150000.1.27.1 |
| SUSE:Manager Server 4.3 | release-notes-susemanager | 0 | 4.3.15.2-150400.3.133.1 |
| SUSE:Package Hub 12 | govulncheck-vulndb | 0 | 0.0.20241104T154416-5.1 |
| Ubuntu:16.04:LTS | grafana | 0 | No fix |
| Ubuntu:Pro:16.04:LTS | grafana | 0 | No fix |
| Wolfi | grafana-11.0 | 0 | 11.0.7-r0 |
| Wolfi | grafana-oci-compat | 0 | 11.0.7-r0 |
| go | github.com/grafana/grafana | 11.0.0 | 11.0.7 |
| go | github.com/grafana/grafana | 11.1.0 | 11.1.8 |
| go | github.com/grafana/grafana | 11.2.0 | 11.2.3 |
| openSUSE:Leap 15.5 | govulncheck-vulndb | 0 | 0.0.20241030T212825-150000.1.9.1 |
| openSUSE:Leap 15.6 | govulncheck-vulndb | 0 | 0.0.20241030T212825-150000.1.9.1 |
| openSUSE:Leap 15.6 | grafana | 0 | 11.5.5-150200.3.72.2 |
| openSUSE:Leap 15.6 | prometheus-blackbox_exporter | 0 | 0.26.0-150000.1.27.1 |
| openSUSE:Tumbleweed | govulncheck-vulndb | 0 | 0.0.20241030T212825-1.1 |
| openSUSE:Tumbleweed | grafana | 0 | 11.3.0-1.1 |
Related vulnerabilities
- CVE-2025-41115 Grafana Incorrect Privilege Assignment vulnerability Also affects github.com/grafana/grafana
- CVE-2025-6023 An open redirect vulnerability has been identified in Grafana OSS that can be exploited… Also affects github.com/grafana/grafana
- CVE-2025-4123 A cross-site scripting (XSS) vulnerability exists in Grafana caused by combining a client… Also affects github.com/grafana/grafana
- CVE-2024-10452 Grafana org admin can delete pending invites in different org Also affects github.com/grafana/grafana
- CVE-2024-6322 Access control for plugin data sources protected by the ReqActions json field of the… Also affects github.com/grafana/grafana
- CVE-2024-1313 It is possible for a user in a different organization from the owner of a snapshot to… Also affects github.com/grafana/grafana
- CVE-2024-1442 A user with the permissions to create a data source can use Grafana API to create a data… Also affects github.com/grafana/grafana
- CVE-2023-6152 A user changing their email after signing up and verifying it can change it without… Also affects github.com/grafana/grafana