The vulnerability exists because the application used an untrusted sender identity from request parameters for authorization in Discord moderation actions (timeout, kick, ban). This allowed a non-admin user to potentially execute these actions by spoofing the sender's identity. The fix was to introduce and consistently use a trusted requesterSenderId from the server-side context for all moderation-related authorization checks.
The analysis of the patch commit 775816035ecc6bb243843f8000c9a58ff609e32d reveals the key functions involved. The function handleDiscordModerationAction in src/agents/tools/discord-actions-moderation.ts is the primary vulnerable function, as it directly executed the moderation commands without proper authorization checks. The patch adds a call to the new verifySenderModerationPermission function to fix this.
The function tryHandleDiscordMessageActionGuildAdmin in src/channels/plugins/actions/discord/handle-action.guild-admin.ts was also vulnerable because it was responsible for calling the moderation action handler but failed to provide the trusted sender's ID, thereby enabling the vulnerability. The patch corrects this by extracting the requesterSenderId from the context and passing it to the action handler.
Finally, handleDiscordMessageAction in src/channels/plugins/actions/discord/handle-action.ts was changed to accept the requesterSenderId in its context, enabling the trusted identity to be passed down through the call chain. The absence of this in the function's context was a contributing factor to the vulnerability.