12
12
*/
13
13
14
14
import java
15
- import ClientSuppliedIpUsedInSecurityCheckLib
15
+ import semmle.code.java.dataflow.TaintTracking
16
16
import semmle.code.java.dataflow.FlowSources
17
- import DataFlow:: PathGraph
17
+ import ClientSuppliedIpUsedInSecurityCheckLib
18
+ import ClientSuppliedIpUsedInSecurityCheckFlow:: PathGraph
18
19
19
20
/**
20
21
* Taint-tracking configuration tracing flow from obtaining a client ip from an HTTP header to a sensitive use.
21
22
*/
22
- class ClientSuppliedIpUsedInSecurityCheckConfig extends TaintTracking:: Configuration {
23
- ClientSuppliedIpUsedInSecurityCheckConfig ( ) { this = "ClientSuppliedIpUsedInSecurityCheckConfig" }
24
-
25
- override predicate isSource ( DataFlow:: Node source ) {
23
+ module ClientSuppliedIpUsedInSecurityCheckConfig implements DataFlow:: ConfigSig {
24
+ predicate isSource ( DataFlow:: Node source ) {
26
25
source instanceof ClientSuppliedIpUsedInSecurityCheck
27
26
}
28
27
29
- override predicate isSink ( DataFlow:: Node sink ) {
30
- sink instanceof ClientSuppliedIpUsedInSecurityCheckSink
31
- }
28
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof ClientSuppliedIpUsedInSecurityCheckSink }
32
29
33
30
/**
34
31
* Splitting a header value by `,` and taking an entry other than the first is sanitizing, because
35
32
* later entries may originate from more-trustworthy intermediate proxies, not the original client.
36
33
*/
37
- override predicate isSanitizer ( DataFlow:: Node node ) {
34
+ predicate isBarrier ( DataFlow:: Node node ) {
38
35
exists ( ArrayAccess aa , MethodAccess ma | aa .getArray ( ) = ma |
39
36
ma .getQualifier ( ) = node .asExpr ( ) and
40
37
ma .getMethod ( ) instanceof SplitMethod and
@@ -47,8 +44,12 @@ class ClientSuppliedIpUsedInSecurityCheckConfig extends TaintTracking::Configura
47
44
}
48
45
}
49
46
47
+ module ClientSuppliedIpUsedInSecurityCheckFlow =
48
+ TaintTracking:: Global< ClientSuppliedIpUsedInSecurityCheckConfig > ;
49
+
50
50
from
51
- DataFlow:: PathNode source , DataFlow:: PathNode sink , ClientSuppliedIpUsedInSecurityCheckConfig conf
52
- where conf .hasFlowPath ( source , sink )
51
+ ClientSuppliedIpUsedInSecurityCheckFlow:: PathNode source ,
52
+ ClientSuppliedIpUsedInSecurityCheckFlow:: PathNode sink
53
+ where ClientSuppliedIpUsedInSecurityCheckFlow:: flowPath ( source , sink )
53
54
select sink .getNode ( ) , source , sink , "IP address spoofing might include code from $@." ,
54
55
source .getNode ( ) , "this user input"
0 commit comments