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

No hook sender verification #60

Open
IgorDuino opened this issue Dec 28, 2023 · 0 comments
Open

No hook sender verification #60

IgorDuino opened this issue Dec 28, 2023 · 0 comments

Comments

@IgorDuino
Copy link

class TelegramBotWebhookView(View):
# WARNING: if fail - Telegram webhook will be delivered again.
# Can be fixed with async celery task execution
def post(self, request, *args, **kwargs):
if DEBUG:
process_telegram_event(json.loads(request.body))
else:
# Process Telegram event in Celery worker (async)
# Don't forget to run it and & Redis (message broker for Celery)!
# Locally, You can run all of these services via docker-compose.yml
process_telegram_event.delay(json.loads(request.body))
# e.g. remove buttons, typing event
return JsonResponse({"ok": "POST request processed"})

Anyone can send a request and imitate any actions of users who started the bot

According to the documentation, such a check is enough

  • accept incoming POSTs only from subnets 149.154.160.0/20 and 91.108.4.0/22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant