@@ -23,26 +23,26 @@ private class NumericCastFlowConfig extends TaintTracking::Configuration {
23
23
override predicate isSource ( DataFlow:: Node src ) { src instanceof RemoteFlowSource }
24
24
25
25
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
27
28
}
28
29
29
30
override predicate isSanitizer ( DataFlow:: Node node ) {
30
31
boundedRead ( node .asExpr ( ) ) or
31
32
castCheck ( node .asExpr ( ) ) or
32
33
node .getType ( ) instanceof SmallType or
33
34
smallExpr ( node .asExpr ( ) ) or
34
- node .getEnclosingCallable ( ) instanceof HashCodeMethod
35
+ node .getEnclosingCallable ( ) instanceof HashCodeMethod or
36
+ exists ( RightShiftOp e | e .getShiftedVariable ( ) .getAnAccess ( ) = node .asExpr ( ) )
35
37
}
36
38
}
37
39
38
40
from
39
41
DataFlow:: PathNode source , DataFlow:: PathNode sink , NumericNarrowingCastExpr exp ,
40
- VarAccess tainted , NumericCastFlowConfig conf
42
+ NumericCastFlowConfig conf
41
43
where
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 )
46
46
select exp , source , sink ,
47
47
"$@ flows to here and is cast to a narrower type, potentially causing truncation." ,
48
48
source .getNode ( ) , "User-provided value"
0 commit comments