fix(telegram): enforce gateway auth for inline approval callbacks#17862
Closed
johnncenae wants to merge 1 commit into
Closed
fix(telegram): enforce gateway auth for inline approval callbacks#17862johnncenae wants to merge 1 commit into
johnncenae wants to merge 1 commit into
Conversation
3 tasks
Contributor
|
Merged via #18180 — your commit cherry-picked onto current main with rebase-merge so your authorship is preserved. Good catch on this one: the |
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.
Summary
This hardens Telegram inline callback authorization for gateway-gated actions.
Previously, Telegram approval, slash-confirm, and update-prompt callbacks only checked
TELEGRAM_ALLOWED_USERSinside the adapter. That meant these callback paths could bypass the gateway's actual authorization decision when access was restricted via global gateway policy rather than the Telegram-specific allowlist.This change makes Telegram callback authorization reuse the runner's
_is_user_authorized(...)decision when available, while preserving the existingTELEGRAM_ALLOWED_USERSfallback for contexts where the adapter is not attached to the gateway runner.What changed
TelegramAdapter._is_callback_user_authorized(...)to:SessionSourceand delegate to the gateway runner's_is_user_authorized(...)when availableTELEGRAM_ALLOWED_USERScheck if no runner-backed auth is availableWhy this matters
Telegram callback queries do not go through the normal inbound message authorization path in
gateway/run.py. Without a matching auth check here, a user blocked by global gateway policy could still press approval or update buttons ifTELEGRAM_ALLOWED_USERSwas unset.Risk
Low.
Tests
Passed:
scripts/run_tests.sh tests/gateway/test_telegram_approval_buttons.pyResult:
15 passed in 4.61s