I have done the scan my project java spring boot with Checkmarx tool. The tool found about 23 XSRF occurrences with Medium severity.
The issue found is marked on Rest API method POST on @RequestBody List<String> lineups
In attached the screen-shoot for description result:
@RequestMapping(value = "/rules/lineup/{ruleMode}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> getRulesByRuleModeAndLineup(@PathVariable Integer ruleMode,
@RequestBody List<String> lineups) throws Exception {
LOGGER.info("[getRulesByRuleModeAndLineup] ENTER type: " + ruleMode + " lineup: " + lineups);
ResponseEntity<Object> output = null;
List<Rule> rules = new ArrayList<Rule>();
try {
for (String lineup : lineups) {
String lineupSanitized = HtmlUtils.htmlEscape(lineup);
rules.addAll(uiService.getRulesByRuleModeAndLineup(ruleMode, lineupSanitized));
}
output = new ResponseEntity<>(rules, HttpStatus.OK);
} catch (Exception e) {
LOGGER.error(e, e);
output = new ResponseEntity<>("An error occurred: " + e.getMessage() + "'",
HttpStatus.INTERNAL_SERVER_ERROR);
}
return output;
}
Is there sample fix to resolve the issue ?