@@ -23,26 +23,26 @@ private class NumericCastFlowConfig extends TaintTracking::Configuration {
2323 override predicate isSource ( DataFlow:: Node src ) { src instanceof RemoteFlowSource }
2424
2525 override predicate isSink ( DataFlow:: Node sink ) {
26- sink .asExpr ( ) = any ( NumericNarrowingCastExpr cast ) .getExpr ( )
26+ sink .asExpr ( ) = any ( NumericNarrowingCastExpr cast ) .getExpr ( ) and
27+ sink .asExpr ( ) instanceof VarAccess
2728 }
2829
2930 override predicate isSanitizer ( DataFlow:: Node node ) {
3031 boundedRead ( node .asExpr ( ) ) or
3132 castCheck ( node .asExpr ( ) ) or
3233 node .getType ( ) instanceof SmallType or
3334 smallExpr ( node .asExpr ( ) ) or
34- node .getEnclosingCallable ( ) instanceof HashCodeMethod
35+ node .getEnclosingCallable ( ) instanceof HashCodeMethod or
36+ exists ( RightShiftOp e | e .getShiftedVariable ( ) .getAnAccess ( ) = node .asExpr ( ) )
3537 }
3638}
3739
3840from
3941 DataFlow:: PathNode source , DataFlow:: PathNode sink , NumericNarrowingCastExpr exp ,
40- VarAccess tainted , NumericCastFlowConfig conf
42+ NumericCastFlowConfig conf
4143where
42- exp .getExpr ( ) = tainted and
43- sink .getNode ( ) .asExpr ( ) = tainted and
44- conf .hasFlowPath ( source , sink ) and
45- not exists ( RightShiftOp e | e .getShiftedVariable ( ) = tainted .getVariable ( ) )
44+ sink .getNode ( ) .asExpr ( ) = exp .getExpr ( ) and
45+ conf .hasFlowPath ( source , sink )
4646select exp , source , sink ,
4747 "$@ flows to here and is cast to a narrower type, potentially causing truncation." ,
4848 source .getNode ( ) , "User-provided value"
0 commit comments