GHSL-2021-1053: Path traversal in Grafana REST API - CVE-2021-43813, CVE-2021-43815
The Grafana REST API endpoint for retrieving plugin markdown files did not properly sanitise the user-supplied name parameter, allowing path traversal. An authenticated low-privileged user could read arbitrary .md files on the server.
Originally disclosed on GitHub Security Lab
The GetPluginMarkdown request handler is vulnerable to path traversal attacks.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application joined user-controlled input directly into a file path without validating that the resulting path stayed within the intended plugin directory.
Impact
This issue may lead to arbitrary .md file disclosure.
What the attacker needed
Authenticated low-privileged user (e.g., VIEWER)
The fix
The issue was fixed by the vendor.
How it was found
- Start Grafana 8.3.1 in a Docker container.
- Log in as admin and create a new VIEWER user.
- Create a markdown file at /tmp/foo.md with arbitrary contents.
- Send a request to the plugin markdown endpoint with a path traversal sequence in the name parameter, using the VIEWER user's credentials.
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 report has not been written yet. The Original tab links to the source.
A path traversal bug lets someone use '..' in a file path to escape the intended folder and read other files. In this case, a logged-in user with minimal permissions could trick Grafana into reading any markdown file on the server, not just plugin documentation.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.