@@ -24,17 +24,44 @@ class PostValidation extends DataFlow::FlowState {
2424 *
2525 * This configuration uses two flow states, `PreValidation` and `PostValidation`,
2626 * to track the requirement that a logical validation has been performed before the Unicode Transformation.
27+ * DEPRECATED: Use `UnicodeBypassValidationFlow`
2728 */
28- class Configuration extends TaintTracking:: Configuration {
29+ deprecated class Configuration extends TaintTracking:: Configuration {
2930 Configuration ( ) { this = "UnicodeBypassValidation" }
3031
3132 override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowState state ) {
32- source instanceof RemoteFlowSource and state instanceof PreValidation
33+ UnicodeBypassValidationConfig :: isSource ( source , state )
3334 }
3435
3536 override predicate isAdditionalTaintStep (
3637 DataFlow:: Node nodeFrom , DataFlow:: FlowState stateFrom , DataFlow:: Node nodeTo ,
3738 DataFlow:: FlowState stateTo
39+ ) {
40+ UnicodeBypassValidationConfig:: isAdditionalFlowStep ( nodeFrom , stateFrom , nodeTo , stateTo )
41+ }
42+
43+ /* A Unicode Tranformation (Unicode tranformation) is considered a sink when the algorithm used is either NFC or NFKC. */
44+ override predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowState state ) {
45+ UnicodeBypassValidationConfig:: isSink ( sink , state )
46+ }
47+ }
48+
49+ /**
50+ * A taint-tracking configuration for detecting "Unicode transformation mishandling" vulnerabilities.
51+ *
52+ * This configuration uses two flow states, `PreValidation` and `PostValidation`,
53+ * to track the requirement that a logical validation has been performed before the Unicode Transformation.
54+ */
55+ private module UnicodeBypassValidationConfig implements DataFlow:: StateConfigSig {
56+ class FlowState = DataFlow:: FlowState ;
57+
58+ predicate isSource ( DataFlow:: Node source , DataFlow:: FlowState state ) {
59+ source instanceof RemoteFlowSource and state instanceof PreValidation
60+ }
61+
62+ predicate isAdditionalFlowStep (
63+ DataFlow:: Node nodeFrom , DataFlow:: FlowState stateFrom , DataFlow:: Node nodeTo ,
64+ DataFlow:: FlowState stateTo
3865 ) {
3966 (
4067 exists ( Escaping escaping | nodeFrom = escaping .getAnInput ( ) and nodeTo = escaping .getOutput ( ) )
@@ -80,7 +107,7 @@ class Configuration extends TaintTracking::Configuration {
80107 }
81108
82109 /* A Unicode Tranformation (Unicode tranformation) is considered a sink when the algorithm used is either NFC or NFKC. */
83- override predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowState state ) {
110+ predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowState state ) {
84111 (
85112 exists ( DataFlow:: CallNode cn |
86113 cn .getMethodName ( ) = "unicode_normalize" and
@@ -121,3 +148,8 @@ class Configuration extends TaintTracking::Configuration {
121148 state instanceof PostValidation
122149 }
123150}
151+
152+ /**
153+ * Taint-tracking configuration for detecting "Unicode transformation mishandling" vulnerabilities.
154+ */
155+ module UnicodeBypassValidationFlow = TaintTracking:: GlobalWithState< UnicodeBypassValidationConfig > ;
0 commit comments