38

xxl-job 执行器 RESTful API 未授权访问 RCE

 3 years ago
source link: https://www.landgrey.me/blog/18/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

xxl-job 执行器 RESTful API 未授权访问 RCE

一:快速环境搭建

  • 1. 下载源码
git clone https://github.com/xuxueli/xxl-job.git
  • 2. 打开文件
xxl-job/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties

修改参数值,防止文件路径不存在报错

xxl.job.executor.logpath=./jobhandler
  • 3. 最后启动 spring-boot 应用 主类位置:
xxl-job/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/XxlJobExecutorApplication.java

二:漏洞复现

看到发漏洞公告是 RESTful API 未授权,去官网搜了一下使用手册,总共有两种 RESTful API,一个 调度中心 RESTful API,一个 执行器 RESTful API

测试了一下,发现问题出现在执行器 RESTful API。其中有个触发任务执行的说明:

说明:触发任务执行

------

地址格式:{执行器内嵌服务跟地址}/run

Header:
    XXL-JOB-ACCESS-TOKEN : {请求令牌}

请求数据格式如下,放置在 RequestBody 中,JSON格式:
    {
        "jobId":1,                                  // 任务ID
        "executorHandler":"demoJobHandler",         // 任务标识
        "executorParams":"demoJobHandler",          // 任务参数
        "executorBlockStrategy":"COVER_EARLY",      // 任务阻塞策略,可选值参考 com.xxl.job.core.enums.ExecutorBlockStrategyEnum
        "executorTimeout":0,                        // 任务超时时间,单位秒,大于零时生效
        "logId":1,                                  // 本次调度日志ID
        "logDateTime":1586629003729,                // 本次调度日志时间
        "glueType":"BEAN",                          // 任务模式,可选值参考 com.xxl.job.core.glue.GlueTypeEnum
        "glueSource":"xxx",                         // GLUE脚本代码
        "glueUpdatetime":1586629003727,             // GLUE脚本更新时间,用于判定脚本是否变更以及是否需要刷新
        "broadcastIndex":0,                         // 分片参数:当前分片
        "broadcastTotal":0                          // 分片参数:总分片
    }

响应数据格式:
    {
      "code": 200,      // 200 表示正常、其他失败
      "msg": null       // 错误提示消息
    }

注意其中的任务模式 glueType,翻了下代码,有下面几种:

BEAN("BEAN", false, null, null),
GLUE_GROOVY("GLUE(Java)", false, null, null),
GLUE_SHELL("GLUE(Shell)", true, "bash", ".sh"),
GLUE_PYTHON("GLUE(Python)", true, "python", ".py"),
GLUE_PHP("GLUE(PHP)", true, "php", ".php"),
GLUE_NODEJS("GLUE(Nodejs)", true, "node", ".js"),
GLUE_POWERSHELL("GLUE(PowerShell)", true, "powershell", ".ps1");

随手用 GLUE_SHELL 构造了一下请求包,直接在 glueSource 参数值写 bash 命令就可以了:

onzadfjg.png

参考链接:

XXL-JOB官方文档

标签: java 

昵称 *
邮箱 *
Message

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK