File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
lib/semmle/javascript/frameworks
test/query-tests/Security/CWE-326 Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,19 @@ private module NodeJSCrypto {
204
204
override predicate isSymmetricKey ( ) { symmetric = true }
205
205
}
206
206
207
+ private class CreateDiffieHellmanKey extends CryptographicKeyCreation , DataFlow:: CallNode {
208
+ // require("crypto").createDiffieHellman(prime_length);
209
+ CreateDiffieHellmanKey ( ) {
210
+ this = DataFlow:: moduleMember ( "crypto" , "createDiffieHellman" ) .getACall ( )
211
+ }
212
+
213
+ override CryptographicAlgorithm getAlgorithm ( ) { none ( ) }
214
+
215
+ override int getSize ( ) { result = getArgument ( 0 ) .getIntValue ( ) }
216
+
217
+ override predicate isSymmetricKey ( ) { none ( ) }
218
+ }
219
+
207
220
private class Apply extends CryptographicOperation , MethodCallExpr {
208
221
InstantiatedAlgorithm instantiation ;
209
222
Original file line number Diff line number Diff line change @@ -30,4 +30,7 @@ var key3 = myBuffer.getBytes(8);
30
30
var bad9 = forge . cipher . createDecipher ( '3DES-CBC' , key3 ) ; // NOT OK
31
31
32
32
var key4 = myBuffer . getBytes ( 16 ) ;
33
- var good5 = forge . cipher . createDecipher ( 'AES-CBC' , key4 ) ; // OK
33
+ var good5 = forge . cipher . createDecipher ( 'AES-CBC' , key4 ) ; // OK
34
+
35
+ var bad10 = crypto . createDiffieHellman ( 512 ) ;
36
+ var good6 = crypto . createDiffieHellman ( 2048 ) ;
You can’t perform that action at this time.
0 commit comments