Skip to content
RCE Write-up Intermediate

Exploiting CVE-2024–9264: Anatomy of the Grafana 11.0.0 Remote

Grafana 11.0.0 allows an authenticated user to send a crafted query to the /api/ds/query endpoint that uses the DuckDB expression datasource to read arbitrary files and, if DuckDB extensions can be loaded, execute commands. The attacker needs valid credentials and DuckDB installed on the server.

Raj Kumar M Follow

Published on medium.com

To exploit this vulnerable version of Grafana, we need valid Grafana credentials (username and password). To obtain those credentials, we must perform enumeration.

Raj Kumar M, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Grafana expression datasource passes user-supplied SQL to DuckDB without restricting file access or extension loading.

Impact

An authenticated user could read arbitrary files on the server and, if DuckDB extensions can be loaded, execute commands, but the text notes that extension loading may be blocked.

What the attacker needed

Valid Grafana credentials; DuckDB installed on the server; for RCE: ability to load DuckDB extensions

How it was found

  1. Log in to Grafana with valid credentials.
  2. Send a POST request to /api/ds/query with a query that uses the Expression datasource and a DuckDB SQL expression to read a file.
  3. Read the file contents from the JSON response.
  4. To run a command, send a multi-statement query that installs and loads the shellfs extension and runs the command, redirecting output to a temporary file.
  5. Read the temporary file to get the command output.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Grafana is a tool for making charts from data. In this version, a logged-in user could ask Grafana to run a special database query that reads files from the server, like the list of user accounts. If the server also allowed loading extra database features, the user could run commands on the machine.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Raj Kumar M

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.