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

The file upload vulnerability exists in the latest version of SENS #20

Open
altEr1125 opened this issue Nov 19, 2022 · 0 comments
Open

Comments

@altEr1125
Copy link

This project has file upload function. The corresponding code for this function is located in com.liuyanzhao.sens.web.controller.admin#upload

@PostMapping(value = "/upload", produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    @SystemLog(description = "上传文件", type = LogTypeEnum.ATTACHMENT)
    public Map<String, Object> upload(@RequestParam("file") MultipartFile file,
                                      HttpServletRequest request) {
        return uploadAttachment(file, request);
}

The Upload method calls the uploadAttachment() method.

image

After audit, we can find that the code does not restrict the name of the file and the path of the final storage. The path of the final file is “/upload/202/11/+filename”, so there is a file upload attack.
Use the website provided by the project author to demonstrate the vulnerability.
Changing the name of the file to be uploaded “.. /.. /ind.html” to attack.

image

The traversed file was successfully accessed.

image

Solution: Add a filtering mechanism.

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

1 participant