fix(telegram): enforce gateway auth for inline approval callbacks (#17862)#18180
Merged
Conversation
Collaborator
This was referenced May 9, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #17862 by @johnncenae onto current main.
Summary
Telegram inline button callbacks (approval, slash-confirm, update-prompt) now delegate authorization to
GatewayRunner._is_user_authorized()when a runner is attached, with the existingTELEGRAM_ALLOWED_USERSenv check as a fallback.Previously the callback path returned
TruewhenTELEGRAM_ALLOWED_USERSwas unset, completely bypassing global gateway policy (GATEWAY_ALLOW_ALL_USERS=false, per-chat whitelists viaTELEGRAM_GROUP_ALLOWED_CHATS, DM pairing, etc.). A user blocked by global policy could still press approval/confirm/update-prompt buttons.Changes
TelegramAdapter._is_callback_user_authorized(...)— now an instance method that builds aSessionSource(chat_id, chat_type, thread_id, user_id, user_name), hands it to the runner's auth, and falls back to the env-only check if no runner is attachedValidation
scripts/run_tests.sh tests/gateway/test_telegram_approval_buttons.py tests/gateway/test_telegram_group_gating.py tests/gateway/test_telegram_format.py tests/gateway/test_telegram_webhook_secret.py→ 120/120 passed.Follow-up (separate concern, NOT in this PR)
Model picker callbacks (
mp:/mm:/mb:/mx:/mg:) attelegram.py:1809have no auth check at all — they only check that a picker state exists for the chat. That's a different design question (who's authorized to change the chat's model after someone else ran/model?) and is out of scope here.Closes #17862.