Skip to content

fix(discord): removed DM senders can still message and run commands through an existing session binding - #196848

Merged
drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-1193
Nov 19, 2026
Merged

drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-1193

Conversation

@drobison00

@drobison00 drobison00 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • The new regression (extensions/discord/src/monitor/message-handler.preflight.bound-dm.test.ts) calls the production preflightDiscordMessage entry point with an in-memory binding adapter. On main 3 of 4 cases fail (allowlist rejection, pairing rejection, and command authorization for an admitted sender); on this branch all 4 pass.
  • A second, separately written test set against the DM preflight access resolver: 11 failed / 14 passed on main, 25 passed on this branch.
  • DM authorization, pairing-decision, message-preflight and routing-preflight suites: 77 passed.
  • Full build and full test typecheck passed. Targeted type-aware lint, formatting, line-cap, test-line and mock-export checks passed.

To run the regression:

OPENCLAW_VITEST_RUNTIME=node pnpm test extensions/discord/src/monitor/message-handler.preflight.bound-dm.test.ts --maxWorkers=1 -t 'bound direct messages'

Gap: the broad pnpm check is not green locally. Extension lint reports line-limit errors in the Tlon and Crabbox tests that reproduce on an untouched main with 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.

  • Base: b382a29a688a. Head: 1ff91cc0ded1. Node 24.22.2, pnpm install --frozen-lockfile, pnpm build with private QA enabled.
  • Two synthetic DM senders, A and B, each with an existing session binding. Provider-native MESSAGE_CREATE DM events are injected through the provider's authenticated local ingress. Policy changes go through the Gateway's config.patch RPC with replacePaths: ["channels.discord.allowFrom"]. Bindings are left in place throughout and re-read after every step.
  • Each step sends one message and one command per sender and records whether it reached agent execution, whether the agent's marker reply came back, and whether the command took effect.
Phase Sender Base Head
1. Both on the allowlist A message and command executed message and command executed
1. Both on the allowlist B message and command executed message and command executed
2. A removed from allowFrom, binding retained A message reached the agent and was answered; command executed denied: no agent execution, no reply, command not executed
2. A removed from allowFrom, binding retained B message and command executed message and command executed
3. dmPolicy: pairing, A unpaired, binding retained A message reached the agent and was answered; no pairing request was created not delivered to the agent; pairing request issued; command not executed
3. dmPolicy: pairing, A unpaired, binding retained B not reached (run stopped at A's step) message and command executed

On 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.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Makes 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.

  • Before: The binding admits the sender and authorizes commands despite the current denial.
  • After: The sender follows the normal denial or pairing path; admitted senders retain their binding route.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, correct repair with successful exact-head checks and useful running-Gateway boundary evidence; transport and model behavior remain synthetic.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (live_output): The updated body records the real Discord plugin and Gateway handling synthetic MESSAGE_CREATE events before and after policy changes: revoked bound senders stop reaching agent and text-command execution, pairing resumes, and admitted senders retain delivery; this is channel-boundary proof with a loopback transport and mock model, not live Discord-service proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Removing a Discord DM sender from allowed or paired access does not stop their messages and commands when a session binding remains.
Reason: The change restores the documented access contract without adding configuration, changing storage, or replacing the binding router.

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
Reviewed head: 1ff91cc0ded169b221e036fe042dc22b8da0a2ed

Before merge

None.

Findings

None.

Agent review details

How this fits together

Discord 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]
Loading

Technical review

Best 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

  • Binding-based DM admission and command authorization changes intended behavior with a stated reason (unknown: The override was carried through Discord internalization and later ingress and binding migrations; their recorded purposes preserve routing and async ownership, rather than establish binding existence as current sender authority. Extended git log -S could not read an older promisor blob.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1ebb4c0 adds extensions/discord/src/monitor/message-handler.dm-preflight.ts:83 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ebb4c09323d; files: extensions/discord/src/monitor/message-handler.dm-preflight.ts)
  • Josh Avant: Raw commit 97a53a9 adds extensions/discord/src/monitor/message-handler.dm-preflight.ts:72 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 97a53a9b35a8; files: extensions/discord/src/monitor/message-handler.dm-preflight.ts)

PR surface

Source -23, Tests +149, Other +2. Total +128 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 2 25 -23
Tests 1 149 0 +149
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 153 25 +128

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Current main permits a previously bound Discord sender to bypass revoked DM access and command authorization.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-10T20:31:17.859Z sha 1ff91cc :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-13T18:14:13.172Z sha 1ff91cc :: needs maintainer review before merge. :: none

Reviewed November 13, 2026, 1:20 PM ET / 18:20 UTC (Revision 3).

@drobison00

Copy link
Copy Markdown
Contributor Author

GPT - 6.1 Sol - eng-discord (engineer) via @drobison00

Updated the description: added running-product evidence on base and head under Evidence, and removed the closing process note. @clawsweeper re-review

@drobison00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

GPT - 6.1 Sol - eng-discord (engineer) via @drobison00 - Description updated: attribution line removed; running-product evidence on base and head is under Evidence.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 13, 2026
@drobison00
drobison00 merged commit 2a99e00 into openclaw:main Nov 19, 2026
158 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
(cherry picked from commit 2a99e00)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit cc7210abb60529f7aff92978fc6568a5b41409c9)
tideclaw-bot added a commit that referenced this pull request Nov 24, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant