Merge pull request #7740 from erik-krogh/CWE-347

JS: promote the js/jwt-missing-verification query out of experimental
This commit is contained in:
Erik Krogh Kristensen
2022-02-01 13:10:35 +01:00
committed by GitHub
9 changed files with 78 additions and 45 deletions

View File

@@ -0,0 +1,3 @@
| bad-jwt.js:10:19:10:20 | "" | This argument disables the integrity enforcement of the token verification. |
| bad-jwt.js:11:19:11:27 | undefined | This argument disables the integrity enforcement of the token verification. |
| bad-jwt.js:12:19:12:23 | false | This argument disables the integrity enforcement of the token verification. |

View File

@@ -0,0 +1 @@
Security/CWE-347/MissingJWTKeyVerification.ql

View File

@@ -0,0 +1,12 @@
const jwt = require("jsonwebtoken");
const secret = "my-secret-key";
var token = jwt.sign({ foo: 'bar' }, secret, { algorithm: "HS256" })
jwt.verify(token, secret, { algorithms: ["HS256", "none"] }) // OK
var token = jwt.sign({ foo: 'bar' }, secret, { algorithm: "none" })
jwt.verify(token, "", { algorithms: ["HS256", "none"] }) // NOT OK
jwt.verify(token, undefined, { algorithms: ["HS256", "none"] }) // NOT OK
jwt.verify(token, false, { algorithms: ["HS256", "none"] }) // NOT OK