@@ -215,28 +215,32 @@ module CallGraph {
215
215
predicate edges ( CallPathNode pred , CallPathNode succ ) { pred .getASuccessor ( ) = succ }
216
216
}
217
217
218
- /**
219
- * Holds if `sourceMethod` is an unprotected request handler that reaches a
220
- * `sinkMethodCall` that updates a database.
221
- */
222
- private predicate unprotectedDatabaseUpdate ( CallPathNode sourceMethod , CallPathNode sinkMethodCall ) {
223
- sourceMethod .asMethod ( ) instanceof CsrfUnprotectedMethod and
218
+ /** Holds if `sourceMethod` is an unprotected request handler. */
219
+ private predicate source ( CallPathNode sourceMethod ) {
220
+ sourceMethod .asMethod ( ) instanceof CsrfUnprotectedMethod
221
+ }
222
+
223
+ /** Holds if `sinkMethodCall` updates a database. */
224
+ private predicate sink ( CallPathNode sinkMethodCall ) {
224
225
exists ( CallPathNode sinkMethod |
225
226
sinkMethod .asMethod ( ) instanceof DatabaseUpdateMethod and
226
- sinkMethodCall .getASuccessor ( ) = pragma [ only_bind_into ] ( sinkMethod ) and
227
- sourceMethod .getASuccessor + ( ) = pragma [ only_bind_into ] ( sinkMethodCall ) and
227
+ sinkMethodCall .getASuccessor ( ) = sinkMethod and
228
228
// exclude SQL `execute` calls that do not update database
229
229
if
230
230
sinkMethod .asMethod ( ) instanceof SqlInjectionDatabaseUpdateMethod and
231
231
sinkMethod .asMethod ( ) .hasName ( "execute" )
232
- then
233
- exists ( SqlExecuteFlow:: PathNode executeSink | SqlExecuteFlow:: flowPath ( _, executeSink ) |
234
- sinkMethodCall .asCall ( ) = executeSink .getNode ( ) .asExpr ( ) .( Argument ) .getCall ( )
235
- )
232
+ then SqlExecuteFlow:: flowToExpr ( sinkMethodCall .asCall ( ) .getAnArgument ( ) )
236
233
else any ( )
237
234
)
238
235
}
239
236
237
+ /**
238
+ * Holds if `sourceMethod` is an unprotected request handler that reaches a
239
+ * `sinkMethodCall` that updates a database.
240
+ */
241
+ private predicate unprotectedDatabaseUpdate ( CallPathNode sourceMethod , CallPathNode sinkMethodCall ) =
242
+ doublyBoundedFastTC( CallGraph:: edges / 2 , source / 1 , sink / 1 ) ( sourceMethod , sinkMethodCall )
243
+
240
244
/**
241
245
* Holds if `sourceMethod` is an unprotected request handler that appears to
242
246
* change application state based on its name.
0 commit comments