3
3
import java
4
4
import semmle.code.java.dataflow.TaintTracking
5
5
import semmle.code.java.dataflow.DataFlow2
6
+ private import semmle.code.java.dataflow.ExternalFlow
6
7
7
8
/**
8
9
* Holds if `array` is initialized only with constants.
@@ -113,34 +114,7 @@ private class StaticInitializationVectorSource extends DataFlow::Node {
113
114
* A sink that initializes a cipher with unsafe parameters.
114
115
*/
115
116
private class EncryptionInitializationSink extends DataFlow:: Node {
116
- EncryptionInitializationSink ( ) {
117
- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
118
- m .hasQualifiedName ( "javax.crypto" , "Cipher" , "init" ) and
119
- m .getParameterType ( 2 )
120
- .( RefType )
121
- .hasQualifiedName ( "java.security.spec" , "AlgorithmParameterSpec" ) and
122
- ma .getArgument ( 2 ) = this .asExpr ( )
123
- )
124
- }
125
- }
126
-
127
- /**
128
- * Holds if `fromNode` to `toNode` is a dataflow step
129
- * that creates cipher's parameters with initialization vector.
130
- */
131
- private predicate createInitializationVectorSpecStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
132
- exists ( ConstructorCall cc , RefType type |
133
- cc = toNode .asExpr ( ) and type = cc .getConstructedType ( )
134
- |
135
- type .hasQualifiedName ( "javax.crypto.spec" , "IvParameterSpec" ) and
136
- cc .getArgument ( 0 ) = fromNode .asExpr ( )
137
- or
138
- type .hasQualifiedName ( "javax.crypto.spec" , [ "GCMParameterSpec" , "RC2ParameterSpec" ] ) and
139
- cc .getArgument ( 1 ) = fromNode .asExpr ( )
140
- or
141
- type .hasQualifiedName ( "javax.crypto.spec" , "RC5ParameterSpec" ) and
142
- cc .getArgument ( 3 ) = fromNode .asExpr ( )
143
- )
117
+ EncryptionInitializationSink ( ) { sinkNode ( this , "encryption-iv" ) }
144
118
}
145
119
146
120
/**
@@ -156,10 +130,6 @@ deprecated class StaticInitializationVectorConfig extends TaintTracking::Configu
156
130
}
157
131
158
132
override predicate isSink ( DataFlow:: Node sink ) { sink instanceof EncryptionInitializationSink }
159
-
160
- override predicate isAdditionalTaintStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
161
- createInitializationVectorSpecStep ( fromNode , toNode )
162
- }
163
133
}
164
134
165
135
/**
@@ -169,10 +139,6 @@ module StaticInitializationVectorConfig implements DataFlow::ConfigSig {
169
139
predicate isSource ( DataFlow:: Node source ) { source instanceof StaticInitializationVectorSource }
170
140
171
141
predicate isSink ( DataFlow:: Node sink ) { sink instanceof EncryptionInitializationSink }
172
-
173
- predicate isAdditionalFlowStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
174
- createInitializationVectorSpecStep ( fromNode , toNode )
175
- }
176
142
}
177
143
178
144
/** Tracks the flow from a static initialization vector to the initialization of a cipher */
0 commit comments