File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
semmle/code/java/dataflow
test/query-tests/security/CWE-807/semmle/tests Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ category : minorAnalysis
3+ ---
4+ * Excluded reverse DNS from the loopback address as a source of untrusted data.
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ private class ReverseDnsSource extends RemoteFlowSource {
126126 m .getMethod ( ) instanceof ReverseDnsMethod and
127127 not exists ( MethodCall l |
128128 ( variableStep ( l , m .getQualifier ( ) ) or l = m .getQualifier ( ) ) and
129- l .getMethod ( ) .getName ( ) = "getLocalHost"
129+ ( l .getMethod ( ) .getName ( ) = "getLocalHost" or l . getMethod ( ) . getName ( ) = "getLoopbackAddress" )
130130 )
131131 )
132132 }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public static void main(HttpServletRequest request) throws Exception {
3838 }
3939
4040 // FALSE NEGATIVE: we have no way of telling that the skipped method is sensitive
41- if (adminCookie .getValue () == "false" ) // $ MISSING: $ hasConditionalBypassTest
41+ if (adminCookie .getValue () == "false" ) // $ MISSING: hasConditionalBypassTest
4242 doReallyImportantSecurityWork ();
4343
4444 InetAddress local = InetAddress .getLocalHost ();
@@ -49,6 +49,15 @@ public static void main(HttpServletRequest request) throws Exception {
4949 if (Inet4Address .getLocalHost ().getCanonicalHostName ().equals ("localhost" )) {
5050 login (user , password );
5151 }
52+
53+ InetAddress loopback = InetAddress .getLoopbackAddress ();
54+ // GOOD: reverse DNS on loopback address is fine
55+ if (loopback .getCanonicalHostName ().equals ("localhost" )) {
56+ login (user , password );
57+ }
58+ if (Inet4Address .getLoopbackAddress ().getCanonicalHostName ().equals ("localhost" )) {
59+ login (user , password );
60+ }
5261 }
5362
5463 public static void test (String user , String password ) {
You can’t perform that action at this time.
0 commit comments