From 32fa8df9fef78db858f14347fee3314cc51f2552 Mon Sep 17 00:00:00 2001 From: sundeep8967 Date: Fri, 13 Nov 2026 20:54:45 +0530 Subject: [PATCH] fix(github-issue-bot): reject webhooks with missing signature header - Fixes #350 - Previously, 'typeof signature !== string' evaluated to true when the header was missing or undefined, inadvertently bypassing webhook signature verification. - Return false when the x-hub-signature-256 header is missing or non-string. Signed-off-by: sundeep8967 --- node-typescript/github-issue-bot/src/github.ts | 11 ++++++++--- node/github-issue-bot/src/github.js | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/node-typescript/github-issue-bot/src/github.ts b/node-typescript/github-issue-bot/src/github.ts index 72a324cd..bbe64bea 100644 --- a/node-typescript/github-issue-bot/src/github.ts +++ b/node-typescript/github-issue-bot/src/github.ts @@ -21,9 +21,14 @@ class GithubService { async verifyWebhook(req: any): Promise { const signature = req.headers['x-hub-signature-256']; - return ( - typeof signature !== 'string' || - (await verify(process.env.GITHUB_WEBHOOK_SECRET, req.bodyBinary, signature)) + if (typeof signature !== 'string') { + return false; + } + + return await verify( + process.env.GITHUB_WEBHOOK_SECRET, + req.bodyBinary, + signature ); } diff --git a/node/github-issue-bot/src/github.js b/node/github-issue-bot/src/github.js index 5d6e877e..97347221 100644 --- a/node/github-issue-bot/src/github.js +++ b/node/github-issue-bot/src/github.js @@ -15,9 +15,14 @@ class GithubService { async verifyWebhook(req) { const signature = req.headers['x-hub-signature-256']; - return ( - typeof signature !== 'string' || - (await verify(process.env.GITHUB_WEBHOOK_SECRET, req.bodyBinary, signature)) + if (typeof signature !== 'string') { + return false; + } + + return await verify( + process.env.GITHUB_WEBHOOK_SECRET, + req.bodyBinary, + signature ); }