@@ -94,40 +94,19 @@ private class StaticInitializationVectorSource extends DataFlow::Node {
94
94
}
95
95
}
96
96
97
- /**
98
- * A config that tracks initialization of a cipher for encryption.
99
- */
100
- private class EncryptionModeConfig extends TaintTracking2:: Configuration {
101
- EncryptionModeConfig ( ) { this = "EncryptionModeConfig" }
102
-
103
- override predicate isSource ( DataFlow:: Node source ) {
104
- source
105
- .asExpr ( )
106
- .( FieldRead )
107
- .getField ( )
108
- .hasQualifiedName ( "javax.crypto" , "Cipher" , "ENCRYPT_MODE" )
109
- }
110
-
111
- override predicate isSink ( DataFlow:: Node sink ) {
112
- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
113
- m .hasQualifiedName ( "javax.crypto" , "Cipher" , "init" ) and
114
- ma .getArgument ( 0 ) = sink .asExpr ( )
115
- )
116
- }
117
- }
118
-
119
97
/**
120
98
* A sink that initializes a cipher for encryption with unsafe parameters.
121
99
*/
122
100
private class EncryptionInitializationSink extends DataFlow:: Node {
123
101
EncryptionInitializationSink ( ) {
124
- exists ( MethodAccess ma , Method m , EncryptionModeConfig config | m = ma .getMethod ( ) |
102
+ exists ( MethodAccess ma , Method m , FieldRead fr | m = ma .getMethod ( ) |
125
103
m .hasQualifiedName ( "javax.crypto" , "Cipher" , "init" ) and
126
104
m .getParameterType ( 2 )
127
105
.( RefType )
128
106
.hasQualifiedName ( "java.security.spec" , "AlgorithmParameterSpec" ) and
129
- ma .getArgument ( 2 ) = this .asExpr ( ) and
130
- config .hasFlowToExpr ( ma .getArgument ( 0 ) )
107
+ fr .getField ( ) .hasQualifiedName ( "javax.crypto" , "Cipher" , "ENCRYPT_MODE" ) and
108
+ DataFlow:: localExprFlow ( fr , ma .getArgument ( 0 ) ) and
109
+ ma .getArgument ( 2 ) = this .asExpr ( )
131
110
)
132
111
}
133
112
}
0 commit comments