fix(msteams): fail closed on denied group access (#121086)

This commit is contained in:
Pavan Kumar Gondhi
2026-08-10 10:39:22 +05:30
committed by GitHub
parent d4fd9cc96a
commit d85f5c1176
2 changed files with 39 additions and 1 deletions
@@ -341,7 +341,7 @@ export async function admitMSTeamsMessage(params: {
});
return null;
}
if (!senderAccess.allowed && senderAccess.reasonCode === "group_policy_not_allowlisted") {
if (!senderAccess.allowed) {
const allowMatch = resolveMSTeamsAllowlistMatch({
allowFrom: effectiveGroupAllowFrom,
senderId,
@@ -641,6 +641,44 @@ describe("msteams monitor handler authz", () => {
).toBe("19:group@thread.tacv2");
});
it.each([
{
name: "missing",
accessGroups: undefined,
},
{
name: "unsupported",
accessGroups: {
operators: {
type: "discord.channelAudience" as const,
guildId: "guild-1",
channelId: "channel-1",
},
},
},
])("fails closed when a group sender access group is $name", async ({ accessGroups }) => {
resetThreadMocks();
const { conversationStore, deps } = createDeps({
accessGroups,
channels: {
msteams: {
groupPolicy: "allowlist",
groupAllowFrom: ["accessGroup:operators"],
requireMention: false,
},
},
} as OpenClawConfig);
const handler = createMSTeamsMessageHandler(deps);
await handler(createAttackerGroupActivity());
expect(conversationStore.upsert).not.toHaveBeenCalled();
expect(runtimeApiMockState.dispatchReplyWithBufferedBlockDispatcher).not.toHaveBeenCalled();
expect(logMeta(deps.log.info, "dropping group message (not in groupAllowFrom)").sender).toBe(
"attacker-aad",
);
});
it("blocks unauthorized text control commands through shared ingress", async () => {
resetThreadMocks();
const hasControlCommand = vi.fn(() => true);