[Kubernetes for Everyone] — Exploiting Grafana (CVE-2021-43798) To Gain SSH Access and Extract…
A Grafana instance running version 8.3.0 was vulnerable to a directory traversal flaw (CVE-2021-43798) that allowed reading arbitrary files, including the Grafana database and /etc/passwd. The attacker used the extracted information to obtain SSH access and then enumerated Kubernetes secrets and pods to find flags.
meetcyber.net
Published on meetcyber.net
In this lab, the target environment exposed multiple services that together formed a realistic attack surface commonly seen in containerized infrastructure. The assessment involved service enumeration, exploitation of a vulnerable Grafana instance, credential extraction, SSH access, and deep exploration of a…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Grafana plugin endpoint did not properly sanitise file paths, allowing traversal outside the intended directory.
What the attacker needed
Grafana 8.3.0 exposed; Network access to Grafana; Public exploit available
How it was found
- Scan ports with naabu and nmap to find services, including Grafana on port 3000.
- Use a public exploit for CVE-2021-43798 to read files such as /var/lib/grafana/grafana.db and /etc/passwd.
- Inspect a web app on port 5000, find a commented Pastebin URL in main.css, and decode a Base32 string.
- Use a string from /etc/passwd as the password for user vagrant to gain SSH access.
- Run k0s kubectl get secret to list and inspect Kubernetes secrets.
- List pods with k0s kubectl get pods -A and extract data from a completed pod.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A directory traversal bug lets an attacker use a web address to read files on the server that should not be accessible, like a password file. Here, the attacker read a database file and a system file to find a password, then logged in via SSH to explore the server further.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.