fix: Must check length before passing to timingSafeEqual
This commit is contained in:
@@ -15,6 +15,8 @@ const cronHandler = async (ctx: Context) => {
|
|||||||
const { token, limit = 500 } = ctx.body as { token?: string; limit: number };
|
const { token, limit = 500 } = ctx.body as { token?: string; limit: number };
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
!token ||
|
||||||
|
token.length !== env.UTILS_SECRET.length ||
|
||||||
!crypto.timingSafeEqual(
|
!crypto.timingSafeEqual(
|
||||||
Buffer.from(env.UTILS_SECRET),
|
Buffer.from(env.UTILS_SECRET),
|
||||||
Buffer.from(String(token))
|
Buffer.from(String(token))
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ function verifySlackToken(token: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
token.length !== env.SLACK_VERIFICATION_TOKEN.length ||
|
||||||
!crypto.timingSafeEqual(
|
!crypto.timingSafeEqual(
|
||||||
Buffer.from(env.SLACK_VERIFICATION_TOKEN),
|
Buffer.from(env.SLACK_VERIFICATION_TOKEN),
|
||||||
Buffer.from(token)
|
Buffer.from(token)
|
||||||
|
|||||||
Reference in New Issue
Block a user