33 */
44
55private import python
6+ import semmle.python.dataflow.new.DataFlow
67import semmle.python.ApiGraphs
78import semmle.python.Concepts
89import semmle.python.dataflow.new.internal.DataFlowPublic
@@ -27,16 +28,16 @@ class PostValidation extends DataFlow::FlowState {
2728 * This configuration uses two flow states, `PreValidation` and `PostValidation`,
2829 * to track the requirement that a logical validation has been performed before the Unicode Transformation.
2930 */
30- class Configuration extends TaintTracking :: Configuration {
31- Configuration ( ) { this = "UnicodeBypassValidation" }
31+ private module UnicodeBypassValidationConfig implements DataFlow :: StateConfigSig {
32+ class FlowState = DataFlow :: FlowState ;
3233
33- override predicate isSource ( DataFlow:: Node source , DataFlow :: FlowState state ) {
34+ predicate isSource ( DataFlow:: Node source , FlowState state ) {
3435 source instanceof RemoteFlowSource and state instanceof PreValidation
3536 }
3637
37- override predicate isAdditionalTaintStep (
38- DataFlow:: Node nodeFrom , DataFlow :: FlowState stateFrom , DataFlow:: Node nodeTo ,
39- DataFlow :: FlowState stateTo
38+ predicate isAdditionalFlowStep (
39+ DataFlow:: Node nodeFrom , FlowState stateFrom , DataFlow:: Node nodeTo ,
40+ FlowState stateTo
4041 ) {
4142 (
4243 exists ( Escaping escaping | nodeFrom = escaping .getAnInput ( ) and nodeTo = escaping .getOutput ( ) )
@@ -51,7 +52,7 @@ class Configuration extends TaintTracking::Configuration {
5152 }
5253
5354 /* A Unicode Tranformation (Unicode tranformation) is considered a sink when the algorithm used is either NFC or NFKC. */
54- override predicate isSink ( DataFlow:: Node sink , DataFlow :: FlowState state ) {
55+ predicate isSink ( DataFlow:: Node sink , FlowState state ) {
5556 exists ( API:: CallNode cn |
5657 cn = API:: moduleImport ( "unicodedata" ) .getMember ( "normalize" ) .getACall ( ) and
5758 sink = cn .getArg ( 1 )
@@ -71,3 +72,6 @@ class Configuration extends TaintTracking::Configuration {
7172 state instanceof PostValidation
7273 }
7374}
75+
76+ /** Global taint-tracking for detecting "Unicode transformation mishandling" vulnerabilities. */
77+ module UnicodeBypassValidationFlow = TaintTracking:: GlobalWithState< UnicodeBypassValidationConfig > ;
0 commit comments