@@ -94,40 +94,19 @@ private class StaticInitializationVectorSource extends DataFlow::Node {
9494 }
9595}
9696
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-
11997/**
12098 * A sink that initializes a cipher for encryption with unsafe parameters.
12199 */
122100private class EncryptionInitializationSink extends DataFlow:: Node {
123101 EncryptionInitializationSink ( ) {
124- exists ( MethodAccess ma , Method m , EncryptionModeConfig config | m = ma .getMethod ( ) |
102+ exists ( MethodAccess ma , Method m , FieldRead fr | m = ma .getMethod ( ) |
125103 m .hasQualifiedName ( "javax.crypto" , "Cipher" , "init" ) and
126104 m .getParameterType ( 2 )
127105 .( RefType )
128106 .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 ( )
131110 )
132111 }
133112}
0 commit comments