@@ -35,11 +35,6 @@ predicate linearBoundControls(BasicBlock controlled, SsaDefinition def, StackVar
35
35
)
36
36
}
37
37
38
- predicate isUnboundedArrayIndex ( DataFlow:: Node sink , VariableAccess offsetExpr ) {
39
- offsetExpr = sink .asExpr ( ) .( ArrayExpr ) .getArrayOffset ( ) and
40
- not hasUpperBound ( offsetExpr )
41
- }
42
-
43
38
predicate readsVariable ( LoadInstruction load , Variable var ) {
44
39
load .getSourceAddress ( ) .( VariableAddressInstruction ) .getASTVariable ( ) = var
45
40
}
@@ -79,16 +74,21 @@ class ImproperArrayIndexValidationConfig extends TaintTracking::Configuration {
79
74
)
80
75
}
81
76
82
- override predicate isSink ( DataFlow:: Node sink ) { isUnboundedArrayIndex ( sink , _) }
77
+ override predicate isSink ( DataFlow:: Node sink ) {
78
+ exists ( ArrayExpr arrayExpr , VariableAccess offsetExpr |
79
+ offsetExpr = arrayExpr .getArrayOffset ( ) and
80
+ sink .asExpr ( ) = offsetExpr and
81
+ not hasUpperBound ( offsetExpr )
82
+ )
83
+ }
83
84
}
84
85
85
86
from
86
- VariableAccess offsetExpr , ImproperArrayIndexValidationConfig conf , DataFlow:: PathNode source ,
87
- DataFlow :: PathNode sink , string sourceType
87
+ ImproperArrayIndexValidationConfig conf , DataFlow:: PathNode source , DataFlow :: PathNode sink ,
88
+ string sourceType
88
89
where
89
90
conf .hasFlowPath ( source , sink ) and
90
- isFlowSource ( source .getNode ( ) , sourceType ) and
91
- isUnboundedArrayIndex ( sink .getNode ( ) , offsetExpr )
91
+ isFlowSource ( source .getNode ( ) , sourceType )
92
92
select sink .getNode ( ) , source , sink ,
93
93
"$@ flows to here and is used in an array indexing expression, potentially causing an invalid access." ,
94
94
source .getNode ( ) , sourceType
0 commit comments