mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -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 {
|
import type {
|
||||||
IHookFunctions,
|
IHookFunctions,
|
||||||
IWebhookFunctions,
|
IWebhookFunctions,
|
||||||
|
@ -233,7 +234,11 @@ export class TelegramTrigger implements INodeType {
|
||||||
const nodeVersion = this.getNode().typeVersion;
|
const nodeVersion = this.getNode().typeVersion;
|
||||||
if (nodeVersion > 1) {
|
if (nodeVersion > 1) {
|
||||||
const secret = getSecretToken.call(this);
|
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();
|
const res = this.getResponseObject();
|
||||||
res.status(403).json({ message: 'Provided secret is not valid' });
|
res.status(403).json({ message: 'Provided secret is not valid' });
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue