@@ -68,9 +68,11 @@ predicate localAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeT
6868 )
6969 or
7070 // Taint can flow through modeled functions
71+ exprToExprStep ( nodeFrom .asExpr ( ) , nodeTo .asExpr ( ) )
72+ or
7173 exprToDefinitionByReferenceStep ( nodeFrom .asExpr ( ) , nodeTo .asDefiningArgument ( ) )
7274 or
73- exprToExprStep ( nodeFrom .asExpr ( ) , nodeTo .asExpr ( ) )
75+ exprToPartialDefinitionStep ( nodeFrom .asExpr ( ) , nodeTo .asPartialDefinition ( ) )
7476}
7577
7678/**
@@ -133,19 +135,30 @@ private predicate exprToExprStep(Expr exprIn, Expr exprOut) {
133135 )
134136 )
135137 or
136- exists ( TaintFunction f , Call call , FunctionOutput outModel |
138+ exists ( TaintFunction f , Call call , FunctionInput inModel , FunctionOutput outModel |
137139 call .getTarget ( ) = f and
138- exprOut = call and
139- outModel .isReturnValueDeref ( ) and
140- exists ( int argInIndex , FunctionInput inModel | f .hasTaintFlow ( inModel , outModel ) |
141- inModel .isParameterDeref ( argInIndex ) and
142- exprIn = call .getArgument ( argInIndex )
140+ (
141+ exprOut = call and
142+ outModel .isReturnValueDeref ( )
143143 or
144- inModel .isParameterDeref ( argInIndex ) and
145- call .passesByReference ( argInIndex , exprIn )
144+ exprOut = call and
145+ outModel .isReturnValue ( )
146+ ) and
147+ f .hasTaintFlow ( inModel , outModel ) and
148+ (
149+ exists ( int argInIndex |
150+ inModel .isParameterDeref ( argInIndex ) and
151+ exprIn = call .getArgument ( argInIndex )
152+ or
153+ inModel .isParameterDeref ( argInIndex ) and
154+ call .passesByReference ( argInIndex , exprIn )
155+ or
156+ inModel .isParameter ( argInIndex ) and
157+ exprIn = call .getArgument ( argInIndex )
158+ )
146159 or
147- inModel .isParameter ( argInIndex ) and
148- exprIn = call .getArgument ( argInIndex )
160+ inModel .isQualifierObject ( ) and
161+ exprIn = call .getQualifier ( )
149162 )
150163 )
151164}
@@ -163,11 +176,40 @@ private predicate exprToDefinitionByReferenceStep(Expr exprIn, Expr argOut) {
163176 )
164177 )
165178 or
166- exists ( TaintFunction f , Call call , FunctionOutput outModel , int argOutIndex |
179+ exists (
180+ TaintFunction f , Call call , FunctionInput inModel , FunctionOutput outModel , int argOutIndex
181+ |
167182 call .getTarget ( ) = f and
168183 argOut = call .getArgument ( argOutIndex ) and
169184 outModel .isParameterDeref ( argOutIndex ) and
170- exists ( int argInIndex , FunctionInput inModel | f .hasTaintFlow ( inModel , outModel ) |
185+ f .hasTaintFlow ( inModel , outModel ) and
186+ (
187+ exists ( int argInIndex |
188+ inModel .isParameterDeref ( argInIndex ) and
189+ exprIn = call .getArgument ( argInIndex )
190+ or
191+ inModel .isParameterDeref ( argInIndex ) and
192+ call .passesByReference ( argInIndex , exprIn )
193+ or
194+ inModel .isParameter ( argInIndex ) and
195+ exprIn = call .getArgument ( argInIndex )
196+ )
197+ or
198+ inModel .isQualifierObject ( ) and
199+ exprIn = call .getQualifier ( )
200+ )
201+ )
202+ }
203+
204+ private predicate exprToPartialDefinitionStep ( Expr exprIn , Expr exprOut ) {
205+ exists ( TaintFunction f , Call call , FunctionInput inModel , FunctionOutput outModel |
206+ call .getTarget ( ) = f and
207+ (
208+ exprOut = call .getQualifier ( ) and
209+ outModel .isQualifierObject ( )
210+ ) and
211+ f .hasTaintFlow ( inModel , outModel ) and
212+ exists ( int argInIndex |
171213 inModel .isParameterDeref ( argInIndex ) and
172214 exprIn = call .getArgument ( argInIndex )
173215 or
0 commit comments