From bfcae63373bded79cd62811d6610e7d8fc4a0dcd Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 23 Apr 2026 19:06:51 +0100 Subject: [PATCH] fix: harden Discord native command auth (#70711) (thanks @vincentkoc) --- .../native-command.commands-allowfrom.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts b/extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts index d62ba6995cb..efa09626b50 100644 --- a/extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts +++ b/extensions/discord/src/monitor/native-command.commands-allowfrom.test.ts @@ -291,6 +291,27 @@ describe("Discord native slash commands with commands.allowFrom", () => { expectUnauthorizedReply(interaction); }); + it("rejects guild slash commands when owner restrictions are configured and the sender is not allowlisted", async () => { + const { dispatchSpy, interaction } = await runGuildSlashCommand({ + userId: "999999999999999999", + mutateConfig: (cfg) => { + cfg.commands = { + ...cfg.commands, + allowFrom: undefined, + }; + cfg.channels = { + ...cfg.channels, + discord: { + ...cfg.channels?.discord, + allowFrom: ["user:123456789012345678"], + }, + }; + }, + }); + expect(dispatchSpy).not.toHaveBeenCalled(); + expectUnauthorizedReply(interaction); + }); + it("rejects guild slash commands outside the Discord allowlist when commands.useAccessGroups is false and commands.allowFrom is not configured", async () => { const { dispatchSpy, interaction } = await runGuildSlashCommand({ mutateConfig: (cfg) => {