mirror of
https://github.com/github/codeql.git
synced 2026-02-16 06:53:41 +01:00
33 lines
834 B
JavaScript
33 lines
834 B
JavaScript
const express = require('express')
|
|
const jwt_simple = require('jwt-simple');
|
|
|
|
function getSecret() {
|
|
return "A Safe generated random key"
|
|
}
|
|
|
|
function aJWT() {
|
|
return "A JWT provided by user"
|
|
}
|
|
|
|
(function () {
|
|
const UserToken = aJwt()
|
|
|
|
// BAD: no signature verification
|
|
jwt_simple.decode(UserToken, getSecret(), true); // NOT OK
|
|
})();
|
|
|
|
(function () {
|
|
const UserToken = aJwt()
|
|
|
|
// GOOD: all with with signature verification
|
|
jwt_simple.decode(UserToken, getSecret(), false); // OK
|
|
jwt_simple.decode(UserToken, getSecret()); // OK
|
|
})();
|
|
|
|
(function () {
|
|
const UserToken = aJwt()
|
|
|
|
// GOOD: first without signature verification then with signature verification for same UserToken
|
|
jwt_simple.decode(UserToken, getSecret(), true); // OK
|
|
jwt_simple.decode(UserToken, getSecret()); // OK
|
|
})(); |