From 897cda7d994cae153ab58c76df85653c8f8c8f82 Mon Sep 17 00:00:00 2001 From: sudie-codes Date: Fri, 20 Mar 2026 08:08:19 -0700 Subject: [PATCH] msteams: fix sender allowlist bypass when route allowlist is configured (GHSA-g7cr-9h7q-4qxq) (#49582) When a route-level (teams/channel) allowlist was configured but the sender allowlist (allowFrom/groupAllowFrom) was empty, resolveSenderScopedGroupPolicy would downgrade the effective group policy from "allowlist" to "open", allowing any Teams user to interact with the bot. The fix: when channelGate.allowlistConfigured is true and effectiveGroupAllowFrom is empty, preserve the configured groupPolicy ("allowlist") rather than letting it be downgraded to "open". This ensures an empty sender allowlist with an active route allowlist means deny-all rather than allow-all. Co-authored-by: Claude Opus 4.6 (1M context) --- .../src/monitor-handler/message-handler.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/extensions/msteams/src/monitor-handler/message-handler.ts b/extensions/msteams/src/monitor-handler/message-handler.ts index 8f71e80bbf2..fe6751b94c3 100644 --- a/extensions/msteams/src/monitor-handler/message-handler.ts +++ b/extensions/msteams/src/monitor-handler/message-handler.ts @@ -177,10 +177,17 @@ export function createMSTeamsMessageHandler(deps: MSTeamsMessageHandlerDeps) { channelName, allowNameMatching: isDangerousNameMatchingEnabled(msteamsCfg), }); - const senderGroupPolicy = resolveSenderScopedGroupPolicy({ - groupPolicy, - groupAllowFrom: effectiveGroupAllowFrom, - }); + // When a route-level (team/channel) allowlist is configured but the sender allowlist is + // empty, resolveSenderScopedGroupPolicy would otherwise downgrade the policy to "open", + // allowing any sender. To close this bypass (GHSA-g7cr-9h7q-4qxq), treat an empty sender + // allowlist as deny-all whenever the route allowlist is active. + const senderGroupPolicy = + channelGate.allowlistConfigured && effectiveGroupAllowFrom.length === 0 + ? groupPolicy + : resolveSenderScopedGroupPolicy({ + groupPolicy, + groupAllowFrom: effectiveGroupAllowFrom, + }); const access = resolveDmGroupAccessWithLists({ isGroup: !isDirectMessage, dmPolicy,