Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d0232b

Browse files
committed
Add more servlet methods and fix formatting errors
1 parent d978f28 commit 1d0232b

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

java/ql/src/experimental/Security/CWE/CWE-600/UncaughtServletException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
3030
// GOOD
3131
{
3232
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
33-
String ip = "10.100.10.81";
33+
String ip = "10.100.10.81";
3434
InetAddress addr = InetAddress.getByName(ip); // OK: Hard-coded variable value or system property is not controlled by attacker.
3535
}
36-
}
36+
}
3737

3838
}

java/ql/src/experimental/Security/CWE/CWE-600/UncaughtServletException.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<qhelp>
55
<overview>
66
<p>
7-
Even though the signatures for methods in a servlet include throws IOException, ServletException, it's a bad idea to let such exceptions be thrown. Failure to catch exceptions in a servlet could leave a system in a vulnerable state, possibly resulting in denial-of-service attacks, or the exposure of sensitive information because when a servlet throws an exception, the servlet container typically sends debugging information back to the user. And that information could be very valuable to an attacker.
7+
Even though the signatures for methods in a servlet include `throws IOException, ServletException`, it's a bad idea to let such exceptions be thrown. Failure to catch exceptions in a servlet could leave a system in a vulnerable state, possibly resulting in denial-of-service attacks, or the exposure of sensitive information because when a servlet throws an exception, the servlet container typically sends debugging information back to the user. And that information could be very valuable to an attacker.
88
</p>
99
</overview>
1010

java/ql/src/experimental/Security/CWE/CWE-600/UncaughtServletException.ql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ private predicate isServletMethod(Callable c) {
3636
c.getName() = "doGet" or
3737
c.getName() = "doPost" or
3838
c.getName() = "doPut" or
39-
c.getName() = "doDelete"
39+
c.getName() = "doDelete" or
40+
c.getName() = "doHead" or
41+
c.getName() = "doOptions" or
42+
c.getName() = "doTrace" or
43+
c.getName() = "service"
4044
)
4145
}
4246

java/ql/test/experimental/query-tests/security/CWE-600/UncaughtServletException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
2222
InetAddress addr = InetAddress.getByName(ip);
2323
} catch (UnknownHostException uhex) {
2424
uhex.printStackTrace();
25-
}}
25+
}
26+
}
2627

2728
public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
2829
String ip = "10.100.10.81";

0 commit comments

Comments
 (0)