implement a simple InsufficientKeySize query

This commit is contained in:
Erik Krogh Kristensen
2021-11-01 14:02:56 +01:00
parent 7a9315f146
commit 028799deb6
5 changed files with 101 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| tst.js:3:14:3:71 | crypto. ... 1024 }) | Creation of an asymmetric RSA key uses 1024 bits, which is below 2048 and considered breakable. |
| tst.js:7:14:7:59 | crypto. ... : 64 }) | Creation of an symmetric key uses 64 bits, which is below 128 and considered breakable. |

View File

@@ -0,0 +1 @@
Security/CWE-326/InsufficientKeySize.ql

View File

@@ -0,0 +1,9 @@
const crypto = require("crypto");
const bad1 = crypto.generateKeyPairSync("rsa", { modulusLength: 1024 }); // NOT OK
const good1 = crypto.generateKeyPairSync("rsa", { modulusLength: 4096 }); // OK
const bad2 = crypto.generateKeySync("hmac", { length: 64 }); // NOT OK
const good2 = crypto.generateKeySync("aes", { length: 256 }); // OK