Checkmarx is giving XSS vulnerability for following method in my Controller class. Specifically: This element’s value (ResultsVO) then flows through the code without being properly sanitized or validated and is eventually displayed to the user in method:
@RequestMapping(value = "/getresults", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResultsVO getConfigResults(@RequestBody ResultsVO resultsVO, HttpServletRequest request)
throws OverrideApplicationException {
String loggedUserId = request.getHeader("USER");
return resultsService.getConfigResults(resultsVO, loggedUserId);
}
The ResultsVO object has a lot of String attributes and I'm just wondering is there an elegant way to encode them to prevent this vulnerabilty.