Skip to content

Commit

Permalink
fix: Upgrade jsonwebtoken to address CVE-2022-23540 (#5116)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Jan 13, 2023
1 parent 0a5ab56 commit 97969fc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 51 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"browserslist": "^4.21.4",
"ejs": "^3.1.8",
"fork-ts-checker-webpack-plugin": "^6.0.4",
"jsonwebtoken": "9.0.0",
"cpy@8>globby": "^11.1.0",
"qqjs>globby": "^11.1.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.6",
"@types/json-diff": "^0.5.1",
"@types/jsonwebtoken": "^8.5.2",
"@types/jsonwebtoken": "^9.0.0",
"@types/localtunnel": "^1.9.0",
"@types/lodash.get": "^4.4.6",
"@types/lodash.intersection": "^4.4.7",
Expand Down Expand Up @@ -144,7 +144,7 @@
"ioredis": "^5.2.4",
"json-diff": "^0.5.4",
"jsonschema": "^1.4.1",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^9.0.0",
"jwks-rsa": "~1.12.1",
"localtunnel": "^2.0.0",
"lodash.get": "^4.4.2",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/UserManagement/auth/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function issueJWT(user: User): JwtToken {

const signedToken = jwt.sign(payload, config.getEnv('userManagement.jwtSecret'), {
expiresIn: expiresIn / 1000 /* in seconds */,
algorithm: 'HS256',
});

return {
Expand Down Expand Up @@ -57,7 +58,9 @@ export async function resolveJwtContent(jwtPayload: JwtPayload): Promise<User> {
}

export async function resolveJwt(token: string): Promise<User> {
const jwtPayload = jwt.verify(token, config.getEnv('userManagement.jwtSecret')) as JwtPayload;
const jwtPayload = jwt.verify(token, config.getEnv('userManagement.jwtSecret'), {
algorithms: ['HS256'],
}) as JwtPayload;
return resolveJwtContent(jwtPayload);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@
"@types/formidable": "^1.0.31",
"@types/gm": "^1.18.2",
"@types/imap-simple": "^4.2.0",
"@types/jsonwebtoken": "^8.5.2",
"@types/jsonwebtoken": "^9.0.0",
"@types/lodash.set": "^4.3.6",
"@types/lossless-json": "^1.0.0",
"@types/mailparser": "^2.7.3",
Expand Down Expand Up @@ -780,7 +780,7 @@
"isbot": "^3.3.4",
"iso-639-1": "^2.1.3",
"js-nacl": "^1.4.0",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^9.0.0",
"kafkajs": "^1.14.0",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
Expand Down
68 changes: 22 additions & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97969fc

Please sign in to comment.