security(discord): scope DM preflight/native pairing auth to accountId#26696
security(discord): scope DM preflight/native pairing auth to accountId#26696bmendonca3 wants to merge 6 commits intoopenclaw:mainfrom
Conversation
|
@greptileai please run security/code review on this PR. |
Additional Comments (2)
PR description claims #26671 fixes this, but that PR appears to be open/future work. This path has the identical vulnerability that was just fixed in should be: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/discord/monitor/agent-components.ts
Line: 475
Comment:
same auth boundary bypass exists here - missing `accountId` parameter
PR description claims #26671 fixes this, but that PR appears to be open/future work. This path has the identical vulnerability that was just fixed in `message-handler.preflight.ts` and `native-command.ts`.
should be:
```suggestion
dmPolicy === "allowlist" ? [] : await readChannelAllowFromStore("discord", undefined, ctx.accountId).catch(() => []);
```
How can I resolve this? If you propose a fix, please make it concise.
consistent with the other fix locations, this should include: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/discord/monitor/agent-components.ts
Line: 494-501
Comment:
missing `accountId` in pairing write
consistent with the other fix locations, this should include:
```suggestion
const { code, created } = await upsertChannelPairingRequest({
channel: "discord",
id: user.id,
accountId: ctx.accountId,
meta: {
tag: formatDiscordUserTag(user),
name: user.username,
},
});
```
How can I resolve this? If you propose a fix, please make it concise. |
|
Addressed Greptile feedback from #26696 (comment) in commit Applied in
Also added regression assertions in |
|
@greptileai please rerun on the latest head commit after addressing the agent-components account-scope findings. |
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/security/audit-channel.ts
Line: 227
Comment:
missing `accountId` scope - audit is iterating per-account (line 188) but reading unscoped store
```suggestion
const storeAllowFrom = await readChannelAllowFromStore("discord", undefined, accountId).catch(() => []);
```
How can I resolve this? If you propose a fix, please make it concise. |
|
Addressed follow-up Greptile finding from #26696 (comment) in commit Updated
|
|
@greptileai please rerun on the latest head commit after addressing the audit-channel account-scope finding. |
|
Addressed Greptile notes:
Implemented in commit
|
|
Addressed the failing Fix is test-only and keeps behavior unchanged:
Verified locally:
|
|
@greptileai please rerun security/code review on the latest head commit |
|
Thanks for the PR! Multiple PRs address the same fix. Keeping #26671 as the earliest submission. Closing to reduce noise. This is an AI-assisted triage review. If we got this wrong, feel free to reopen — happy to revisit. |
Summary
This PR fixes a Discord auth boundary bypass where DM pairing-store authorization in high-traffic paths was not scoped by account:
src/discord/monitor/message-handler.preflight.tssrc/discord/monitor/native-command.tssrc/discord/monitor/agent-components.tsIn multi-account Discord setups, pairing approvals created under one account could be consulted while authorizing DM senders under a different account.
Change Type
Scope
src/discord/monitor/message-handler.preflight.tssrc/discord/monitor/native-command.tssrc/discord/monitor/agent-components.tssrc/security/audit-channel.tssrc/discord/monitor/message-handler.preflight.account-scope.test.tssrc/discord/monitor/native-command.account-scope.test.tssrc/discord/monitor/monitor.test.tsSecurity Impact
channels.discord.accounts.<accountId>.accountIdscope for pairing store reads/writes.Repro + Verification
Deterministic repro tests:
src/discord/monitor/message-handler.preflight.account-scope.test.tssrc/discord/monitor/native-command.account-scope.test.tsPre-fix validation (executed against upstream versions of patched files):
pnpm exec vitest run src/discord/monitor/message-handler.preflight.account-scope.test.ts src/discord/monitor/native-command.account-scope.test.ts --maxWorkers=1Post-fix verification:
pnpm checkpnpm exec vitest run src/discord/monitor/message-handler.preflight.account-scope.test.ts src/discord/monitor/native-command.account-scope.test.ts src/discord/monitor/message-handler.preflight.test.ts src/discord/monitor/monitor.test.ts src/security/audit.test.ts --maxWorkers=1Evidence
Dedupe search:
Human Verification
readChannelAllowFromStore("discord", undefined, params.accountId)readChannelAllowFromStore("discord", undefined, accountId)readChannelAllowFromStore("discord", undefined, ctx.accountId)accountId.readChannelAllowFromStore("discord", undefined, accountId)Compatibility / Migration
Failure Recovery
Risks and Mitigations