mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(Telegram Trigger Node): Use timing-safe string comparison (no-changelog) (#10718)
This commit is contained in:
parent
421aa71251
commit
540f79a38f
|
@ -1,3 +1,4 @@
|
|||
import crypto from 'crypto';
|
||||
import type {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
|
@ -233,7 +234,11 @@ export class TelegramTrigger implements INodeType {
|
|||
const nodeVersion = this.getNode().typeVersion;
|
||||
if (nodeVersion > 1) {
|
||||
const secret = getSecretToken.call(this);
|
||||
if (secret !== headerData['x-telegram-bot-api-secret-token']) {
|
||||
const secretBuffer = Buffer.from(secret);
|
||||
const headerSecretBuffer = Buffer.from(
|
||||
String(headerData['x-telegram-bot-api-secret-token'] ?? ''),
|
||||
);
|
||||
if (!crypto.timingSafeEqual(secretBuffer, headerSecretBuffer)) {
|
||||
const res = this.getResponseObject();
|
||||
res.status(403).json({ message: 'Provided secret is not valid' });
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue