Following security vulnerability has been reported on our application -
The call to readLine() at xyz.java line 119 might allow an attacker to crash the program or otherwise make it unavailable to legitimate users.
Code with vulnerability
Commented line reported -
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpConnection.getInputStream()));
String inputLine;
StringBuffer okResponse = new StringBuffer();
while ((inputLine = reader.readLine()) != null) { //readLine() on this line has been reported
okResponse.append(inputLine);
}
reader.close();
return okResponse.toString();
The remediation for the same says -
Validate user input to ensure that it will not cause inappropriate resource utilization.
But, it is not clear what exactly can be validated. Any pointers?