githubEdit

Grafana

Grafana is an open-source analytics and interactive visualization web application. It's commonly used for monitoring dashboards.


Discovery

# Default port
# 3000 - HTTP

# Nmap fingerprint
nmap -sC -sV TARGET -p 3000
# http-title: Grafana
# Requested resource was /login

# Version disclosure in footer
# "Open Source v8.0.0 (41f0542c1e)"

# Check robots.txt
curl http://TARGET:3000/robots.txt
# Disallow: /

Version Detection via API


CVE-2024-9264 - DuckDB SQL Injection (Authenticated RCE)

SQL injection in Grafana's DuckDB integration allowing authenticated users to read arbitrary files and execute commands.

Affected Versions: Grafana v11.0.0 (code execution), v11.0.x - v11.2.1 (file read)

Requirements: Valid Grafana credentials

Reference: https://github.com/nollium/CVE-2024-9264

Exploitation

Getting Shell Without nc

If target lacks netcat, use msfvenom:

Exfiltrating grafana.db via Base64


CVE-2021-43798 - Arbitrary File Read / LFI

Directory traversal vulnerability allowing unauthenticated arbitrary file read via plugin paths.

Affected Versions: Grafana 8.0.0-beta1 through 8.3.0 (except patched versions)

Reference: https://github.com/grafana/grafana/security/advisories/GHSA-8pjx-jj86-j47p

Exploitation

POC Tools:

  • https://github.com/Jroo1053/GrafanaDirInclusion

  • https://github.com/K3ysTr0K3R/CVE-2021-43798-EXPLOIT

Manual Exploitation

The vulnerability exists in plugin paths. Various plugins can be used:

High-Value Files to Target

Download Grafana Database


Extracting Credentials from grafana.db

Direct SQLite Query

User Table Schema

Example output:

Handling Corrupted Database

If sqlite3 reports "database disk image is malformed":


Cracking Grafana Password Hashes

Grafana uses PBKDF2-HMAC-SHA256 with 10000 iterations.

Using grafana2hashcat

Cracking with Hashcat


Post-Exploitation

Data Sources

Grafana often connects to databases. Check data_source table:

API Keys

Credential Reuse

Grafana database passwords are often reused:


Grafana Running in Docker

If Grafana is running in a Docker container and you have sudo docker exec:


Default Credentials

Username
Password

admin

admin


Useful Paths

Path
Description

/var/lib/grafana/grafana.db

SQLite database with credentials

/etc/grafana/grafana.ini

Main configuration

/etc/grafana/defaults.ini

Default configuration

/var/log/grafana/

Log files

Last updated