@@ -35,11 +35,6 @@ predicate linearBoundControls(BasicBlock controlled, SsaDefinition def, StackVar
3535 )
3636}
3737
38- predicate isUnboundedArrayIndex ( DataFlow:: Node sink , VariableAccess offsetExpr ) {
39- offsetExpr = sink .asExpr ( ) .( ArrayExpr ) .getArrayOffset ( ) and
40- not hasUpperBound ( offsetExpr )
41- }
42-
4338predicate readsVariable ( LoadInstruction load , Variable var ) {
4439 load .getSourceAddress ( ) .( VariableAddressInstruction ) .getASTVariable ( ) = var
4540}
@@ -79,16 +74,21 @@ class ImproperArrayIndexValidationConfig extends TaintTracking::Configuration {
7974 )
8075 }
8176
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+ }
8384}
8485
8586from
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
8889where
8990 conf .hasFlowPath ( source , sink ) and
90- isFlowSource ( source .getNode ( ) , sourceType ) and
91- isUnboundedArrayIndex ( sink .getNode ( ) , offsetExpr )
91+ isFlowSource ( source .getNode ( ) , sourceType )
9292select sink .getNode ( ) , source , sink ,
9393 "$@ flows to here and is used in an array indexing expression, potentially causing an invalid access." ,
9494 source .getNode ( ) , sourceType
0 commit comments