#19011: fix(discord): enforce owner checks for privileged message actions
agents
size: S
trusted-contributor
Cluster:
Signal and Discord Fixes
## Fix Summary
This change enforces owner-only authorization for privileged Discord guild-administration and moderation message actions exposed through the `message` tool path. Non-owner senders are now denied before dispatch for destructive/admin actions.
## Issue Linkage
Fixes #19008
## Security Snapshot
- CVSS v3.1: 7.6 (High)
- CVSS v4.0: 7.2 (High)
## Implementation Details
### Files Changed
- `src/agents/openclaw-tools.ts` (+3/-0)
- `src/agents/pi-tools.ts` (+1/-0)
- `src/agents/tools/message-tool.ts` (+3/-0)
- `src/channels/plugins/actions/actions.test.ts` (+122/-0)
- `src/channels/plugins/actions/discord.ts` (+2/-2)
- `src/channels/plugins/actions/discord/handle-action.guild-admin.ts` (+30/-1)
- `src/channels/plugins/actions/discord/handle-action.ts` (+4/-1)
- `src/channels/plugins/types.core.ts` (+2/-0)
- `src/infra/outbound/message-action-runner.ts` (+3/-0)
### Technical Analysis
- Added an explicit privileged-action allowlist in Discord guild-admin action handling and enforced `senderIsOwner === true` before dispatch.
- Propagated `senderIsOwner` through the message-action execution path so authorization context reaches Discord action handlers.
- Added regression coverage asserting privileged actions are rejected for non-owners and allowed for owners, while read-only actions remain accessible.
## Validation Evidence
- Command: `pnpm build`
- Status: passed
## Risk and Compatibility
Non-breaking behavior change for authorized owners. Intentional access restriction for non-owner senders on privileged Discord actions; read-only actions remain unchanged.
## AI-Assisted Disclosure
- AI-assisted: yes
- Model: GPT-5.3-Codex
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR closes a privilege escalation vulnerability (CVSS 7.2-7.6) where non-owner senders could execute destructive Discord guild-administration and moderation actions (channel/category CRUD, role management, emoji/sticker uploads, kicks, bans, timeouts) through the `message` tool path.
- Adds an explicit `OWNER_ONLY_GUILD_ACTIONS` allowlist in `handle-action.guild-admin.ts` covering 16 privileged actions, enforcing `senderIsOwner === true` before dispatch
- Propagates `senderIsOwner` through the full execution chain: `pi-tools` → `openclaw-tools` → `message-tool` → `message-action-runner` → `dispatchChannelMessageAction` → Discord plugin handler
- Uses strict `!== true` comparison, treating `undefined` as unauthorized (secure-by-default)
- Read-only actions (`member-info`, `role-info`, `channel-info`, `channel-list`, `emoji-list`, `voice-status`, `event-list`, `search`) remain accessible to non-owner senders
- Adds comprehensive regression tests (84 passing) covering all privileged action rejection/allowance, undefined-as-unauthorized, and read-only action accessibility
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it adds a security-critical authorization check with comprehensive test coverage and no breaking changes for authorized users.
- Score of 5 reflects: (1) clean, minimal changes scoped precisely to the security fix, (2) complete propagation of senderIsOwner through the entire execution chain verified by code review, (3) comprehensive regression tests covering all 16 privileged actions plus edge cases, (4) secure-by-default design treating undefined as unauthorized, (5) non-breaking for authorized owners, and (6) existing tests updated correctly for the new authorization requirement.
- No files require special attention. All changes are well-structured and consistent.
<sub>Last reviewed commit: e7f2ea5</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17513: fix(discord): respect groupPolicy in channel config fallback (#4555)
by aronchick · 2026-02-15
76.6%
#22557: fix(discord): coerce exec approval approver IDs to string to preven...
by zwffff · 2026-02-21
75.3%
#17254: fix(discord): intercept text-based slash commands instead of forwar...
by robbyczgw-cla · 2026-02-15
75.3%
#14318: feat(discord): enforce outbound allowlist on send functions
by builtbyrobben · 2026-02-11
74.6%
#22022: fix: propagate senderIsOwner to agent loop
by alexalex89 · 2026-02-20
73.6%
#17648: fix: Discord guild channel detection using rawMessage.guild_id
by MisterGuy420 · 2026-02-16
73.5%
#12204: fix(discord): resolve numeric guildId/channelId pairs in channel al...
by mcaxtr · 2026-02-09
73.4%
#21861: fix: selective context gating for OWNER_ONLY privacy tags (#11900)
by Asm3r96 · 2026-02-20
73.4%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 · 2026-02-18
73.3%
#20413: docs: clarify slash command authorization model and ownerAllowFrom
by mcinteerj · 2026-02-18
72.7%