@@ -43,7 +43,7 @@ module UnsafeDynamicMethodAccessConfig implements DataFlow::StateConfigSig {
4343 label .isTaint ( )
4444 }
4545
46- predicate isAdditionalFlowStep (
46+ additional predicate additionalFlowStep (
4747 DataFlow:: Node src , DataFlow:: FlowLabel srclabel , DataFlow:: Node dst ,
4848 DataFlow:: FlowLabel dstlabel
4949 ) {
@@ -64,7 +64,16 @@ module UnsafeDynamicMethodAccessConfig implements DataFlow::StateConfigSig {
6464 srclabel .isTaint ( ) and
6565 dstlabel = unsafeFunction ( )
6666 )
67+ }
68+
69+ predicate isAdditionalFlowStep (
70+ DataFlow:: Node src , DataFlow:: FlowLabel srclabel , DataFlow:: Node dst ,
71+ DataFlow:: FlowLabel dstlabel
72+ ) {
73+ additionalFlowStep ( src , srclabel , dst , dstlabel )
6774 or
75+ // We're not using a taint-tracking config because taint steps would then apply to all flow states.
76+ // So we use a plain data flow config and manually add the default taint steps.
6877 srclabel .isTaint ( ) and
6978 TaintTracking:: defaultTaintStep ( src , dst ) and
7079 srclabel = dstlabel
@@ -83,20 +92,17 @@ deprecated class Configuration extends TaintTracking::Configuration {
8392 Configuration ( ) { this = "UnsafeDynamicMethodAccess" }
8493
8594 override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowLabel label ) {
86- source . ( Source ) . getFlowLabel ( ) = label
95+ UnsafeDynamicMethodAccessConfig :: isSource ( source , label )
8796 }
8897
8998 override predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowLabel label ) {
90- sink . ( Sink ) . getFlowLabel ( ) = label
99+ UnsafeDynamicMethodAccessConfig :: isSink ( sink , label )
91100 }
92101
93102 override predicate isSanitizer ( DataFlow:: Node node ) {
94103 super .isSanitizer ( node )
95104 or
96- node instanceof Sanitizer
97- or
98- exists ( StringConcatenation:: getOperand ( node , _) ) and
99- not StringConcatenation:: isCoercion ( node )
105+ UnsafeDynamicMethodAccessConfig:: isBarrier ( node )
100106 }
101107
102108 /**
@@ -110,22 +116,6 @@ deprecated class Configuration extends TaintTracking::Configuration {
110116 DataFlow:: Node src , DataFlow:: Node dst , DataFlow:: FlowLabel srclabel ,
111117 DataFlow:: FlowLabel dstlabel
112118 ) {
113- // Reading a property of the global object or of a function
114- exists ( DataFlow:: PropRead read |
115- this .hasUnsafeMethods ( read .getBase ( ) .getALocalSource ( ) ) and
116- src = read .getPropertyNameExpr ( ) .flow ( ) and
117- dst = read and
118- srclabel .isTaint ( ) and
119- dstlabel = unsafeFunction ( )
120- )
121- or
122- // Reading a chain of properties from any object with a prototype can lead to Function
123- exists ( PropertyProjection proj |
124- not PropertyInjection:: isPrototypeLessObject ( proj .getObject ( ) .getALocalSource ( ) ) and
125- src = proj .getASelector ( ) and
126- dst = proj and
127- srclabel .isTaint ( ) and
128- dstlabel = unsafeFunction ( )
129- )
119+ UnsafeDynamicMethodAccessConfig:: additionalFlowStep ( src , srclabel , dst , dstlabel )
130120 }
131121}
0 commit comments