Repository navigation
fix(discord): removed DM senders can still message and run commands through an existing session binding - #196848
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesMakes bound Discord DMs follow current sender access and command authorization decisions. Example: Sender user-1 retains a session binding after removal from the Discord DM allowlist.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current Discord access bypass with a focused removal of binding-based authorization; no introduced correctness or security defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDiscord message preflight checks ingress policy before routing admitted messages through existing conversation bindings to agent execution. flowchart TD
A[Discord DM event] --> B[Message preflight]
B --> C[Current ingress policy]
C --> D[Deny or request pairing]
C --> E[Admitted message]
E --> F[Existing binding router]
F --> G[Agent and command handling]
Technical reviewBest possible solution: Keep ingress policy authoritative for DM admission and command access, using session bindings only to route admitted messages. Do we have a high-confidence way to reproduce the issue? Current-main source directly admits denied senders when a binding exists; the contributor also reports matching base failures and successful head behavior through a running Gateway. Is this the best way to solve the issue? The patch is the smallest complete repair: it deletes the competing authorization path and preserves the existing ingress and routing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against edee0fc0621b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -23, Tests +149, Other +2. Total +128 across 3 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 13, 2026, 1:20 PM ET / 18:20 UTC (Revision 3). |
Updated the description: added running-product evidence on base and head under Evidence, and removed the closing process note. @clawsweeper re-review |
|
@clawsweeper re-review
|
|
🦞👀 Re-review progress:
|
(cherry picked from commit 2a99e00) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cc7210abb60529f7aff92978fc6568a5b41409c9)
Baseline adaptation: Use stable DM preflight admission and leave established session routing intact; upstream admission and guard assertions apply directly. (cherry picked from commit 2a99e00) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cdb4633201ef9e18e599512caa95e766fb27c9b6)
What Problem This Solves
Fixes: a Discord direct-message sender who has been removed from the allowlist, or who is no longer paired, can still message the agent and run commands when an earlier session binding exists for that conversation.
User Impact
User impact: removing a sender from the DM allowlist or pairing takes effect for bound conversations too. Rejected senders reach the normal denial or pairing path, and command authorization follows the current access decision. Admitted senders keep their existing binding and routing. No configuration or storage migration is needed.
Why This Change Was Made
DM preflight treated the existence of a routing binding as an alternative access decision, and also ORed the binding into command authorization. The binding lookup and both overrides are removed from preflight, so admission and command authorization come only from the current ingress result. The existing routing owner still restores bindings for admitted senders. Production code removes 25 lines and adds two.
Evidence
Run with Node 24.22.2 and pnpm 12.15.0. No live Discord connection was used; ingress decisions and transport are mocked.
extensions/discord/src/monitor/message-handler.preflight.bound-dm.test.ts) calls the productionpreflightDiscordMessageentry point with an in-memory binding adapter. Onmain3 of 4 cases fail (allowlist rejection, pairing rejection, and command authorization for an admitted sender); on this branch all 4 pass.main, 25 passed on this branch.To run the regression:
Gap: the broad
pnpm checkis not green locally. Extension lint reports line-limit errors in the Tlon and Crabbox tests that reproduce on an untouchedmainwith identical counts, and the run was stopped while core lint was still pending, so its later formatting and policy stages did not complete.Running Gateway (loopback Discord provider)
The real Discord plugin and Gateway were started from each built checkout through the repository's QA-lab suite runner with the Crabline loopback Discord provider and the mock model provider. No product module is patched or replaced. This is a local provider stand-in, not the Discord service, and the senders are synthetic IDs, not human accounts.
b382a29a688a. Head:1ff91cc0ded1. Node 24.22.2,pnpm install --frozen-lockfile,pnpm buildwith private QA enabled.MESSAGE_CREATEDM events are injected through the provider's authenticated local ingress. Policy changes go through the Gateway'sconfig.patchRPC withreplacePaths: ["channels.discord.allowFrom"]. Bindings are left in place throughout and re-read after every step.allowFrom, binding retainedallowFrom, binding retaineddmPolicy: pairing, A unpaired, binding retaineddmPolicy: pairing, A unpaired, binding retainedOn head the scenario completed with all three phases passing. On base it recorded the violations above in phase 2 and stopped in phase 3 because the expected pairing request never appeared.
Limits: provider-native events from a loopback stand-in are not genuine human-to-bot DMs, and native slash interactions were not exercised; commands were sent as message text. No production Discord behaviour is claimed.