mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Telegram Trigger Node): Use timing-safe string comparison (no-changelog) (#10718)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user