安全矩阵

 找回密码
 立即注册
搜索
查看: 2519|回复: 0

MeterSphere PluginController Pre-auth RCE

[复制链接]

855

主题

862

帖子

2940

积分

金牌会员

Rank: 6Rank: 6

积分
2940
发表于 2022-1-14 09:23:35 | 显示全部楼层 |阅读模式
原文链接:MeterSphere PluginController Pre-auth RCE

搭建环境
  1. wget https://github.com/metersphere/metersphere/releases/download/v1.16.3/metersphere-online-installer-v1.16.3.tar.gz
  2. tar zxvf metersphere-online-installer-v1.16.3.tar.gz
  3. cd metersphere-online-installer-v1.16.3/
  4. MSVERSION="v1.16.3"
  5. echo $MSVERSION
  6. sed -i -e "s#MS_IMAGE_TAG=.*#MS_IMAGE_TAG=${MSVERSION}#g" install.conf
  7. sed -i -e "s#MS_IMAGE_PREFIX=.*#MS_IMAGE_PREFIX=registry.cn-qingdao.aliyuncs.com\/metersphere#g" install.conf
  8. /bin/bash install.sh
复制代码



搭建完运行在http://172.16.16.129:8081/ docker中 msctl status可以看到状态。
分析漏洞根据diff https://github.com/metersphere/m ... e/v1.16.3...v1.16.4

删除了/plugin/**路由的anon权限,也就是说原来访问/plugin/是不需要授权的。
找到路由对应的controller io.metersphere.controller.PluginController

主要关注两个函数 add 和 customMethod
add函数中上传文件跟进到io.metersphere.service.PluginService#editPlugin

io.metersphere.commons.utils.FileUtils#create将上传的文件拼接写入到 /opt/metersphere/data/body/plugin 目录下

继续跟进this.loadJar()

这里将上传的文件通过URLClassLoader加载进来,那么我们可以通过上传jar包,向内存中注册任意类。
接下来再看io.metersphere.controller.PluginController#customMethod
跟进到io.metersphere.service.PluginService#customMethod

Class.forName参数可控,我们可以在上文的jar包中写一个customMethod函数,这样就可以执行任意java代码了。
整个流程就是写一个Evil类,类中定义一个customMethod函数,打成jar包上传来向内存中注册class,然后通过customMethod路由调用jar包中的Evil类customMethod函数。
复现截图




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-4-23 19:20 , Processed in 0.012362 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表