Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: 在 WebHook 模式下自动生成 secret_token #22

Closed
src-hyc opened this issue Feb 9, 2023 · 2 comments
Closed

Feature Request: 在 WebHook 模式下自动生成 secret_token #22

src-hyc opened this issue Feb 9, 2023 · 2 comments
Labels

Comments

@src-hyc
Copy link

src-hyc commented Feb 9, 2023

I tried this adapter in webhook mode. I noticed in the current version, when it sets up the webhook, it does not have a secret_token (defined in https://core.telegram.org/bots/api#setwebhook) field in it. It neither checks if the request is from one of the Telegram servers (defined in https://core.telegram.org/bots/webhooks). Therefore, it is possible for an attacker to forge a request from Telegram server, and the bot is vulnerable to it, unless the user has their custom routing to limit the connection from Telegram servers.

My suggestion it to randomly generate a secret_token when a user sets up the bot in webhook mode, and checks whether a request has a matching X-Telegram-Bot-Api-Secret-Token header when it receives an update. This change should be transparent to existing users, and save users without a custom routing rule from forged updates.

@j1g5awi
Copy link
Member

j1g5awi commented Feb 10, 2023

ありがとうございます。はい、 シークレット_トークン は、リクエストがテレグラムサーバーから送信されたことを確認するのに非常に役立ちます。 この機能をできるだけ早く実装します。

j1g5awi added a commit that referenced this issue Feb 10, 2023
@j1g5awi
Copy link
Member

j1g5awi commented Feb 10, 2023

Breaking 使用 WebHook 获取更新的用户需要更改配置!

改动前:

telegram_bots = [{"token": "1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI", "webhook_url":  "https://yourdomain.com"}]

改动后:

telegram_bots = [{"token": "1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI", "is_webhook": True}]
telegram_webhook_url = "https://yourdomain.com"

@j1g5awi j1g5awi closed this as completed Apr 5, 2023
@j1g5awi j1g5awi pinned this issue Apr 5, 2023
@j1g5awi j1g5awi changed the title Feature Request: Automatically setting a secret token when setting webhook Feature Request: 在 WebHook 模式下自动生成 secret_token Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants