We happened to use IBM appscan http://www-01.ibm.com/software/awdtools/appscan/
against our java codebase, and it returned around 3000 high severity vulnerabilities.
Most of them happen to be System Information Leak, which it thinks is happening when we print stack traces in the catch blocks, but we only print the filename and line number it is happening, enabling us to debug the code better.
And some are about SQL injection, input validation etc.
But, my question was about Resource exhaustion (file descriptor, disk space, sockets, ...), and it lists all instances of java.io.BufferedReader.readLine
as places for possible external attacks.
InputStream ins=conn.getInputStream();
String inputLine;
if (!preserveLinefeeds) {
BufferedReader in = new BufferedReader(new InputStreamReader(ins));
while ((inputLine = in.readLine()) != null)
pr.readThreadResponse+=inputLine;
in.close();
ins.close();
}
conn is a HttpURLConnection object.
How do I add safegaurds in the code to prevent this?