最近公司要求上传的代码进行扫描,一扫描吓一跳。原本在controller中post传对象的接口都被扫描出Insecure Binder Configuration漏洞。类似以下接口
@PutMapping("/course")
public CourseBaseInfoDto modifyCourseBase(@RequestBody @Validated EditCourseDto editCourseDto) {
return courseBaseInfoService.updateCourseBase(companyId, editCourseDto);
}
相信大部分同学post接口都是这样写的。
漏洞原因是Fortify不建议在post请求中传递实体
修复方法:在controller中添加spring的InitBinder
@InitBinder()
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{});
}