Grafana backend sql injection affected all version
Posted onIn漏洞利用复现Views: Word count in article: 701Reading time ≈3 mins.
Grafana backend sql injection affected all version
Vuln Description
The open-source platform for monitoring and observability
to exploit this sql injection vulnerability, someone must use a valid account login to the grafana web backend, then send malicious POST request to /api/ds/query “rawSql” entry.
if attackers login to the grafana web backend, they can use a post request to /api/ds/query api, then they can modify the “rawSql” filed to execute Malicious sql strings leading to time-based blind sql injection vulnerability, then leak data from databases.
Risk level
high
Impact version
grafana latest and all old version
Vulnerability analysis
affected code blocks and functions
grafana grafana-sql package in grafana/packages/grafana-sql/src/datasource/SqlDatasource.ts file
{"queries":[{"refId":"A","format":"time_series","datasourceId":2,"rawSql":"(SELECT 8424 FROM (SELECT(SLEEP(2)))MKRN)","maxDataPoints":10000}]}
login to backend then click “Explore”, then use burp Capture POST /api/ds/query HTTP/1.1 packet, modify the “rawSql” entry to malicious sql strings, then we get a time-based sql injection.
{"from":"1713492692433","to":"1713514292433","queries":[{"rawSql":"(SELECT 8424 FROM (SELECT(SLEEP(2)))MKRN)","format":"table","refId":"datasets","datasource":{"type":"mysql","uid":"edj6pz14v89a8c"}}]}
using sqlmap dump data
Bug repair
Grafana does not validate any queries sent to the DataSource proxy, that filtering has to be done on the datasource side.
summary
grafana official security team dose not think this is a vulnerability, it’s a feature in the backend, it must feel so damn upset to me…
but i think it’s not, so i published this article out :)
Reference resource
time-based blind sql injection vulnerability in grafana-sql package and datasource plugin