@@ -14,47 +14,50 @@ import python
14
14
import semmle.python.dataflow.new.DataFlow
15
15
import semmle.python.ApiGraphs
16
16
17
+ /** Gets a hostname that can be used to bind to all interfaces. */
18
+ private string vulnerableHostname ( ) {
19
+ result in [
20
+ // IPv4
21
+ "0.0.0.0" , "" ,
22
+ // IPv6
23
+ "::" , "::0"
24
+ ]
25
+ }
26
+
17
27
/** Gets a reference to a hostname that can be used to bind to all interfaces. */
18
- private DataFlow:: LocalSourceNode vulnerableHostname ( DataFlow:: TypeTracker t , string hostname ) {
28
+ private DataFlow:: LocalSourceNode vulnerableHostnameRef ( DataFlow:: TypeTracker t , string hostname ) {
19
29
t .start ( ) and
20
- exists ( StrConst allInterfacesStrConst |
21
- hostname in [
22
- // IPv4
23
- "0.0.0.0" , "" ,
24
- // IPv6
25
- "::" , "::0"
26
- ]
27
- |
30
+ exists ( StrConst allInterfacesStrConst | hostname = vulnerableHostname ( ) |
28
31
allInterfacesStrConst .getText ( ) = hostname and
29
32
result .asExpr ( ) = allInterfacesStrConst
30
33
)
31
34
or
32
- // Due to bad performance when using normal setup with `vulnerableHostname (t2, hostname).track(t2, t)`
35
+ // Due to bad performance when using normal setup with `vulnerableHostnameRef (t2, hostname).track(t2, t)`
33
36
// we have inlined that code and forced a join
34
37
exists ( DataFlow:: TypeTracker t2 |
35
38
exists ( DataFlow:: StepSummary summary |
36
- vulnerableHostname_first_join ( t2 , hostname , result , summary ) and
39
+ vulnerableHostnameRef_first_join ( t2 , hostname , result , summary ) and
37
40
t = t2 .append ( summary )
38
41
)
39
42
)
40
43
}
41
44
42
45
pragma [ nomagic]
43
- private predicate vulnerableHostname_first_join (
46
+ private predicate vulnerableHostnameRef_first_join (
44
47
DataFlow:: TypeTracker t2 , string hostname , DataFlow:: Node res , DataFlow:: StepSummary summary
45
48
) {
46
- DataFlow:: StepSummary:: step ( vulnerableHostname ( t2 , hostname ) , res , summary )
49
+ DataFlow:: StepSummary:: step ( vulnerableHostnameRef ( t2 , hostname ) , res , summary )
47
50
}
48
51
49
52
/** Gets a reference to a hostname that can be used to bind to all interfaces. */
50
- DataFlow:: Node vulnerableHostname ( string hostname ) {
51
- vulnerableHostname ( DataFlow:: TypeTracker:: end ( ) , hostname ) .flowsTo ( result )
53
+ DataFlow:: Node vulnerableHostnameRef ( string hostname ) {
54
+ vulnerableHostnameRef ( DataFlow:: TypeTracker:: end ( ) , hostname ) .flowsTo ( result )
52
55
}
53
56
54
57
/** Gets a reference to tuple containing a hostname as the first element, that can be used to bind to all interfaces. */
55
58
private DataFlow:: LocalSourceNode vulnerableAddressTuple ( DataFlow:: TypeTracker t , string hostname ) {
56
59
t .start ( ) and
57
- result .asExpr ( ) = any ( Tuple tup | tup .getElt ( 0 ) = vulnerableHostname ( hostname ) .asExpr ( ) )
60
+ result .asExpr ( ) = any ( Tuple tup | tup .getElt ( 0 ) = vulnerableHostnameRef ( hostname ) .asExpr ( ) )
58
61
or
59
62
// Due to bad performance when using normal setup with `vulnerableAddressTuple(t2, hostname).track(t2, t)`
60
63
// we have inlined that code and forced a join
0 commit comments