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 {
126
126
m .getMethod ( ) instanceof ReverseDnsMethod and
127
127
not exists ( MethodCall l |
128
128
( variableStep ( l , m .getQualifier ( ) ) or l = m .getQualifier ( ) ) and
129
- l .getMethod ( ) .getName ( ) = "getLocalHost"
129
+ ( l .getMethod ( ) .getName ( ) = "getLocalHost" or l . getMethod ( ) . getName ( ) = "getLoopbackAddress" )
130
130
)
131
131
)
132
132
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public static void main(HttpServletRequest request) throws Exception {
38
38
}
39
39
40
40
// 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
42
42
doReallyImportantSecurityWork ();
43
43
44
44
InetAddress local = InetAddress .getLocalHost ();
@@ -49,6 +49,15 @@ public static void main(HttpServletRequest request) throws Exception {
49
49
if (Inet4Address .getLocalHost ().getCanonicalHostName ().equals ("localhost" )) {
50
50
login (user , password );
51
51
}
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
+ }
52
61
}
53
62
54
63
public static void test (String user , String password ) {
You can’t perform that action at this time.
0 commit comments