@@ -16,29 +16,27 @@ import semmle.python.dataflow.new.DataFlow
16
16
import semmle.python.dataflow.new.TaintTracking
17
17
import semmle.python.ApiGraphs
18
18
import ClientSuppliedIpUsedInSecurityCheckLib
19
- import DataFlow :: PathGraph
19
+ import ClientSuppliedIpUsedInSecurityCheckFlow :: PathGraph
20
20
21
21
/**
22
22
* A taint-tracking configuration tracing flow from obtaining a client ip from an HTTP header to a sensitive use.
23
23
*/
24
- class ClientSuppliedIpUsedInSecurityCheckConfig extends TaintTracking:: Configuration {
25
- ClientSuppliedIpUsedInSecurityCheckConfig ( ) { this = "ClientSuppliedIpUsedInSecurityCheckConfig" }
26
-
27
- override predicate isSource ( DataFlow:: Node source ) {
24
+ private module ClientSuppliedIpUsedInSecurityCheckConfig implements DataFlow:: ConfigSig {
25
+ predicate isSource ( DataFlow:: Node source ) {
28
26
source instanceof ClientSuppliedIpUsedInSecurityCheck
29
27
}
30
28
31
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof PossibleSecurityCheck }
29
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof PossibleSecurityCheck }
32
30
33
- override predicate isAdditionalTaintStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
31
+ predicate isAdditionalFlowStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
34
32
exists ( DataFlow:: CallCfgNode ccn |
35
33
ccn = API:: moduleImport ( "netaddr" ) .getMember ( "IPAddress" ) .getACall ( ) and
36
34
ccn .getArg ( 0 ) = pred and
37
35
ccn = succ
38
36
)
39
37
}
40
38
41
- override predicate isSanitizer ( DataFlow:: Node node ) {
39
+ predicate isBarrier ( DataFlow:: Node node ) {
42
40
// `client_supplied_ip.split(",")[n]` for `n` > 0
43
41
exists ( Subscript ss |
44
42
not ss .getIndex ( ) .( IntegerLiteral ) .getText ( ) = "0" and
@@ -49,9 +47,13 @@ class ClientSuppliedIpUsedInSecurityCheckConfig extends TaintTracking::Configura
49
47
}
50
48
}
51
49
50
+
51
+ /** Global taint-tracking for detecting "client ip used in security check" vulnerabilities. */
52
+ module ClientSuppliedIpUsedInSecurityCheckFlow = TaintTracking:: Global< ClientSuppliedIpUsedInSecurityCheckConfig > ;
53
+
52
54
from
53
- ClientSuppliedIpUsedInSecurityCheckConfig config , DataFlow :: PathNode source ,
54
- DataFlow :: PathNode sink
55
- where config . hasFlowPath ( source , sink )
55
+ ClientSuppliedIpUsedInSecurityCheckFlow :: PathNode source ,
56
+ ClientSuppliedIpUsedInSecurityCheckFlow :: PathNode sink
57
+ where ClientSuppliedIpUsedInSecurityCheckFlow :: flowPath ( source , sink )
56
58
select sink .getNode ( ) , source , sink , "IP address spoofing might include code from $@." ,
57
59
source .getNode ( ) , "this user input"
0 commit comments