We are currently undertaking security vulnerability assessment of our webapps. For this we have been using the ZAP tool from OWASP for automated penetration testing. One of the alerts we received from ZAP was for integer overflow error with the following description: An integer overflow condition exists when an integer, which has not been properly checked from the input stream is used within a compiled program.
The actual report appears as follows:
The method signature of the API listed above is as follows:
@GetMapping(value = "/list")
public ResponseEntity<PaginatedResponse> getUserList(
@RequestParam(name = "searchQuery", defaultValue = "") String searchString,
@RequestParam(defaultValue = "1") int pageNumber,
@RequestParam(defaultValue = "100") int pageSize,
@RequestParam(name = "sort_by",required = false) String sortBy,
@RequestParam(name = "descending",defaultValue = "false") boolean isDescending)
We are using Spring Boot for our REST API, and the pageSize and pageNumber parameters are values that are passed to PageRequest
for pagination purposes.
I have tried adding a check to see whether the input values are between Integer.MIN_VALUE and Integer.MAX_VALUE, but there is a possibility that the resulting value could still be a valid integer because of the wrap-around behaviour of casting values larger than the integer limit to an integer variable in Java.
Another thing to note is that the tool also passed an integer value to a variable that is expecting boolean (descending
in the screenshot above), which I think will also have to be addressed somehow.
Perhaps there is some way to catch such an issue before binding occurs?