Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpress前台存在任意文件上传漏洞 #173

Closed
Er1cccc opened this issue Jan 9, 2022 · 1 comment
Closed

jpress前台存在任意文件上传漏洞 #173

Er1cccc opened this issue Jan 9, 2022 · 1 comment

Comments

@Er1cccc
Copy link

Er1cccc commented Jan 9, 2022

审计过程

jpress框架在安装好之后默认用户注册登录功能

image-20211223165121108

我们可以随意注册一个用户进入到个人主页

image-20211223165157532

在个人主页有文件上传接口,先尝试上传一个html文件,用bp抓包之后发现上传失败了

image-20211223171050527

再来看看成功的回显,这次把后缀改成jpg,成功时会直接回显图片的路径

image-20211223165710851

来看后端的代码,在io.jpress.web.commons.controller.AttachmentController#upload。首先,在51行调用了getFile,获取我们上传的文件

image-20211223165923799

跟进getFile,发现这个方法首先获取了上传的文件数组,然后返回第0个元素,说明我们是可以上传多个文件的

image-20211223170016557

在执行完getFile之后,可以看到,我们上传的文件已经被保存到了临时文件目录,也就是attachment目录下。

image-20211223170136985

紧接着,在65行,判断了文件是否合法,不合法就删除

image-20211223170226545

看到这里应该能想到问题。我们可以上传多个文件(都会存储到临时文件目录),但是最后只检查了第一个文件,如果不合法就删除,其他文件是不会受影响的。

于是我们尝试上传多个文件,直接在bp当中改数据包,加多一个文件

image-20211223171236280

发包之后发现,1.html成功上传到了attachment目录,成功绕过了后缀名限制,实现了任意文件上传

image-20211223171252559

@JPressProjects
Copy link
Owner

新版本已修复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants