diff --git a/gateway/run.py b/gateway/run.py index 442837d36bd8..9ac43b5f60b5 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -44,7 +44,7 @@ from contextvars import copy_context from pathlib import Path from datetime import datetime -from typing import Dict, Optional, Any, List, Union +from typing import Callable, Dict, Optional, Any, List, Union # account_usage imports the OpenAI SDK chain (~230 ms). Only needed by # /usage; we still import it at module top in the gateway because test @@ -6354,6 +6354,7 @@ async def start(self) -> bool: adapter.set_session_store(self.session_store) adapter.set_busy_session_handler(self._handle_active_session_busy_message) adapter.set_topic_recovery_fn(self._recover_telegram_topic_thread_id) + adapter.set_authorization_check(self._make_adapter_auth_check(adapter.platform)) adapter._busy_text_mode = self._busy_text_mode # Try to connect @@ -7162,6 +7163,7 @@ async def _platform_reconnect_watcher(self) -> None: adapter.set_session_store(self.session_store) adapter.set_busy_session_handler(self._handle_active_session_busy_message) adapter.set_topic_recovery_fn(self._recover_telegram_topic_thread_id) + adapter.set_authorization_check(self._make_adapter_auth_check(adapter.platform)) adapter._busy_text_mode = self._busy_text_mode # Reconnect after an outage: preserve the platform's @@ -7818,6 +7820,7 @@ async def _start_one_profile_adapters( adapter.set_session_store(self.session_store) adapter.set_busy_session_handler(self._handle_active_session_busy_message) adapter.set_topic_recovery_fn(self._recover_telegram_topic_thread_id) + adapter.set_authorization_check(self._make_adapter_auth_check(adapter.platform)) adapter._busy_text_mode = self._busy_text_mode try: @@ -7986,6 +7989,39 @@ def _create_adapter( return None + def _make_adapter_auth_check( + self, + platform: Platform, + ) -> Callable[[str, Optional[str], Optional[str]], bool]: + """Build a platform-bound auth callback for adapter use. + + Adapters that fetch external context (e.g. Slack + ``conversations.replies``) call this through + ``BasePlatformAdapter._is_sender_authorized`` to mark non-allowlisted + senders as unverified in LLM context, mitigating indirect prompt + injection from third parties in shared threads/channels. + + The returned callback delegates to :meth:`_is_user_authorized` so the + full auth chain — platform allowlists, group allowlists, pairing + store, allow-all flags — stays the single source of truth. + """ + def check( + user_id: str, + chat_type: Optional[str] = None, + chat_id: Optional[str] = None, + ) -> bool: + if not user_id: + return False + source = SessionSource( + platform=platform, + chat_id=chat_id or "", + chat_type=chat_type or "group", + user_id=user_id, + ) + return self._is_user_authorized(source) + return check + + diff --git a/scripts/release.py b/scripts/release.py index 185236da7b9d..80fe49167541 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -45,8 +45,8 @@ # Auto-extracted from noreply emails + manual overrides AUTHOR_MAP = { + "syahidfrd@gmail.com": "syahidfrd", # PR #17059 salvage (tag unverified senders in Slack thread context to mitigate indirect prompt injection) "5823452+sgabel@users.noreply.github.com": "sgabel", # PR #13139 salvage (redact secrets in user-facing approval prompts) - "130270192+CRWuTJ@users.noreply.github.com": "CRWuTJ", # PR #17082 salvage (cancel delayed Telegram deliveries on disconnect so buffered flushes don't dispatch into a torn-down session) "cyb3rwr3n@users.noreply.github.com": "cyb3rwr3n", # PR #11333 salvage (sanitize FTS5 queries for natural-language recall in holographic memory) "9350182+codexGW@users.noreply.github.com": "codexGW", # PR #12302 salvage (Discord raw <@!ID> mention detection + drop bare mention-only pings) "186512915+lEWFkRAD@users.noreply.github.com": "lEWFkRAD", # PR #53848 salvage (stream the MoA aggregator response to the user) @@ -196,6 +196,7 @@ "290859878+synapsesx@users.noreply.github.com": "synapsesx", "157689911+itsflownium@users.noreply.github.com": "itsflownium", "dirtyren@users.noreply.github.com": "dirtyren", + "92324143+ypwcharles@users.noreply.github.com": "ypwcharles", "mailtowbd@gmail.com": "marco0158", "157793278+jacobmansonlkevincc@users.noreply.github.com": "lkevincc0", "121278003+Cossackx@users.noreply.github.com": "Cossackx", # PR #52528 salvage (Windows hermes-shim resolution + prefer --update on recovery; #52378)