3
3
*/
4
4
5
5
private import python
6
+ import semmle.python.dataflow.new.DataFlow
6
7
import semmle.python.ApiGraphs
7
8
import semmle.python.Concepts
8
9
import semmle.python.dataflow.new.internal.DataFlowPublic
@@ -27,16 +28,16 @@ class PostValidation extends DataFlow::FlowState {
27
28
* This configuration uses two flow states, `PreValidation` and `PostValidation`,
28
29
* to track the requirement that a logical validation has been performed before the Unicode Transformation.
29
30
*/
30
- class Configuration extends TaintTracking :: Configuration {
31
- Configuration ( ) { this = "UnicodeBypassValidation" }
31
+ private module UnicodeBypassValidationConfig implements DataFlow :: StateConfigSig {
32
+ class FlowState = DataFlow :: FlowState ;
32
33
33
- override predicate isSource ( DataFlow:: Node source , DataFlow :: FlowState state ) {
34
+ predicate isSource ( DataFlow:: Node source , FlowState state ) {
34
35
source instanceof RemoteFlowSource and state instanceof PreValidation
35
36
}
36
37
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
40
41
) {
41
42
(
42
43
exists ( Escaping escaping | nodeFrom = escaping .getAnInput ( ) and nodeTo = escaping .getOutput ( ) )
@@ -51,7 +52,7 @@ class Configuration extends TaintTracking::Configuration {
51
52
}
52
53
53
54
/* 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 ) {
55
56
exists ( API:: CallNode cn |
56
57
cn = API:: moduleImport ( "unicodedata" ) .getMember ( "normalize" ) .getACall ( ) and
57
58
sink = cn .getArg ( 1 )
@@ -71,3 +72,6 @@ class Configuration extends TaintTracking::Configuration {
71
72
state instanceof PostValidation
72
73
}
73
74
}
75
+
76
+ /** Global taint-tracking for detecting "Unicode transformation mishandling" vulnerabilities. */
77
+ module UnicodeBypassValidationFlow = TaintTracking:: GlobalWithState< UnicodeBypassValidationConfig > ;
0 commit comments