Skip to content

fix(matrix): reject invalid tokens when userId is configured - #123766

Merged
steipete merged 1 commit into
mainfrom
fix/autoqa-refill-channel-probes
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/autoqa-refill-channel-probes

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123763

What Problem This Solves

Fixes an issue where openclaw channels status --probe could report a Matrix account as working with an invalid access token whenever that account also configured userId. The probe trusted the local configured identity instead of authenticating the token.

Why This Change Was Made

The Matrix probe now creates its non-persistent client without seeding the configured userId, so the existing wrapper getUserId() path authenticates through /account/whoami. It then rejects a valid token whose authenticated identity differs from the configured user.

This keeps the repair inside the Matrix plugin owner. It does not change core channel-status policy, configuration, the public Plugin SDK, auth storage, migrations, dependencies, or the changelog.

Dependency contract: in [email protected], getUserId() returns the configured credential identity, while whoami() performs authenticated I/O. OpenClaw's wrapper calls whoami only when no local user ID is seeded.

User Impact

Matrix operators can trust an explicit channel probe: invalid tokens now fail with the Matrix status/error, valid matching tokens pass, and tokens for a different configured Matrix user fail with an actionable identity-mismatch error.

Evidence

Exact reviewed head: 36b400f851cdf2631184023e9a585313f61f25e4

Before the fix, the focused regression failed 1/7 because the authenticated identity path was never reached when userId was configured.

After the fix:

  • node scripts/run-vitest.mjs extensions/matrix/src/matrix/probe.test.ts — 7/7 passed.
  • node scripts/run-vitest.mjs extensions/matrix/src/channel.account-paths.test.ts — 2/2 passed.
  • node scripts/run-vitest.mjs src/gateway/server-methods/channels.status.test.ts — 15/15 passed.
  • Targeted oxfmt --check and git diff --check passed.
  • node scripts/check-changed.mjs -- extensions/matrix/src/matrix/probe.ts extensions/matrix/src/matrix/probe.test.ts passed all selected extension/test typecheck, lint, dependency, plugin-boundary, database/media/runtime, and import-cycle gates. The remote ci-fast provider was unavailable, so the repository wrapper used its documented local fallback.
  • Fresh Codex-backed autoreview: clean, no accepted/actionable findings; patch is correct (0.99).

The final head was mechanically rebased onto repaired main 36c440aa2b1e5bb6821945956295f7b01a553f06 after current-main CI fixes landed. All focused proof, the changed gate, and autoreview were rerun on the final head. The changed gate passed with the environment ratchet restored to 502/502.

Controlled local Matrix HTTP proof used synthetic credentials and made no sends:

{
  "invalid": { "ok": false, "status": 401, "error": "Invalid access token" },
  "matching": { "ok": true, "userId": "@bot:example.org" },
  "mismatched": { "ok": false, "error": "Matrix access token user does not match configured userId" },
  "jsonProbeOk": false,
  "humanProbeFailed": true,
  "requestCount": 3,
  "onlyWhoamiGets": true,
  "sends": 0
}

Production LOC: +7/-3 (net +4). The four added lines enforce the authenticated-identity boundary and configured/token identity match without adding a second probe path. Tests: +25/-7.

ClawSweeper Review

The merge-risk move is resolved by explicit maintainer decision: production net +4 is approved because the authenticated-versus-configured identity comparison is the required owner-boundary invariant. ClawSweeper also concluded that no safe net-neutral refactor is evident, identified no actionable finding or security concern, and judged this the best fix location. The optional exact-head-check move remains the landing gate and will be completed before merge.

AI-assisted: yes. The operator approved the invariant and landing; the implementation, dependency source, tests, controlled behavior proof, and final diff were independently reviewed.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 14, 2026 17:21
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: XS maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 1:48 PM ET / 17:48 UTC.

ClawSweeper review

What this changes

The PR makes Matrix credential probes authenticate the token even when a configured Matrix user ID is present, then rejects a token that authenticates as a different user.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This maintainer-owned PR fixes a real Matrix false-green probe path and has no blocking patch finding; land after exact-head required checks are green.

Likely related people: @steipete (high confidence; introduced the current probe path and recent Matrix SDK work).

Priority: P2
Reviewed head: 3ae55dfeb27a5b7d6121d057a033b9d04ab5d742

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with credible controlled after-fix behavior proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body contains after-fix controlled Matrix HTTP output for invalid, matching, and mismatched credentials, including whoami-only requests and no sends.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body contains after-fix controlled Matrix HTTP output for invalid, matching, and mismatched credentials, including whoami-only requests and no sends.
Evidence reviewed 6 items Current wrapper behavior: The Matrix client returns the SDK local user ID when present and only calls authenticated whoami otherwise, creating the false-green path addressed here.
Probe entry path: The Matrix account-status adapter resolves account credentials and forwards the configured user ID into the probe.
PR repair: The reviewed head creates the probe client without a seeded user ID, obtains the authenticated identity, and fails configured/token mismatches.
Findings None None.
Security None None.

How this fits together

The Matrix plugin’s channel-status probe creates a temporary Matrix client from configured account credentials and reports whether that account can authenticate. Its result feeds the shared channel-status command so operators can distinguish healthy credentials from invalid or mismatched ones.

flowchart LR
  A[Configured Matrix account] --> B[Channel status probe]
  B --> C[Temporary Matrix client]
  C --> D[Authenticated identity check]
  D --> E[Probe result]
  E --> F[Operator status output]
Loading

Before merge

  • Resolve merge risk (P1) - Existing Matrix configurations whose token belongs to a different user than configured userId will now report an actionable probe failure instead of a false-green result.
  • Complete next step (P2) - No repair lane is needed: this active maintainer-owned PR has no actionable patch finding and awaits exact-head validation.
Agent review details

Security

None.

PR surface

Source +4, Tests +18. Total +22 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 3 +4
Tests 1 25 7 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 32 10 +22

Review metrics

Metric Value Why it matters
Production vs test LOC production +7/-3 (net +4); tests +25/-7 (net +18) The production growth is the owner-local authenticated identity comparison; the changed test replaces a local-identity assertion with the invalid-token regression.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #123763
Summary: This PR is the candidate repair for the linked Matrix probe bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept authenticated identity validation (recommended)
    Land after exact-head checks pass, accepting that mismatched configured identities now fail the health probe with an actionable error.

Technical review

Best possible solution:

Keep authenticated identity validation in the Matrix plugin and merge after green exact-head checks.

Do we have a high-confidence way to reproduce the issue?

Yes—current source shows a configured user ID short-circuits authenticated whoami resolution, and the PR body supplies a controlled after-fix Matrix HTTP scenario.

Is this the best way to solve the issue?

Yes—the Matrix plugin owns client construction and probe identity validation; changing shared status policy or configuration would be broader and less maintainable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eab9cf5ea484.

Labels

Label changes:

  • add merge-risk: 🚨 auth-provider: Merging changes Matrix credential validation so previously false-green mismatched identity setups report a failure.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains after-fix controlled Matrix HTTP output for invalid, matching, and mismatched credentials, including whoami-only requests and no sends.

Label justifications:

  • P2: The PR repairs false-green Matrix credential probes, a bounded operator-facing reliability defect.
  • merge-risk: 🚨 auth-provider: Merging changes Matrix credential validation so previously false-green mismatched identity setups report a failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body contains after-fix controlled Matrix HTTP output for invalid, matching, and mismatched credentials, including whoami-only requests and no sends.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains after-fix controlled Matrix HTTP output for invalid, matching, and mismatched credentials, including whoami-only requests and no sends.

Evidence

What I checked:

Likely related people:

  • steipete: Current probe behavior blames to this contributor’s August 14 commit, with earlier Matrix SDK refactor history in the same area. (role: introduced current probe path and recent Matrix SDK contributor; confidence: high; commits: 1f61c9e29512, 5402ef192d54; files: extensions/matrix/src/matrix/probe.ts, extensions/matrix/src/matrix/sdk/client-core.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for green exact-head required checks before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-14T17:28:09.013Z sha 3ae55df :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as draft August 14, 2026 17:42
@steipete
steipete marked this pull request as ready for review August 14, 2026 17:42
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 14, 2026
@steipete
steipete force-pushed the fix/autoqa-refill-channel-probes branch from 3ae55df to 36b400f Compare August 14, 2026 20:02
@steipete
steipete merged commit 8cd749f into main Aug 14, 2026
108 of 109 checks passed
@steipete
steipete deleted the fix/autoqa-refill-channel-probes branch August 14, 2026 20:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

[Bug]: Matrix probe trusts configured userId without authenticating token

1 participant