Repository navigation
feat(channels): grade sender identifier authentication in the ingress kernel - #116281
omarshahine wants to merge 3 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:37 AM ET / 10:37 UTC. ClawSweeper reviewWhat this changesThe branch replaces the shared channel-ingress boolean mutable-identifier filter with graded entry and per-message sender-authentication claims used by direct-message, command, route, and origin-subject authorization. Merge readinessKeep open for maintainer review. This is still-needed kernel work for an open RFC stack: current main retains the boolean mutable-identifier policy, while this branch creates a compatibility-sensitive public authorization contract whose trusted-evidence semantics must be accepted before merge. Priority: P2 Review scores
Verification
How this fits togetherChannel plugins normalize inbound sender identities into shared ingress state, then the common access graph decides whether direct messages, commands, routes, and callback events may proceed. This branch carries authentication facts from adapters into those common authorization gates. flowchart LR
A[Inbound channel event] --> B[Identity normalization]
B --> C[Ingress state]
C --> D[Authentication threshold]
D --> E[Direct and command gates]
D --> F[Route and event gates]
E --> G[Admission decision]
F --> G
Decision needed
Why: The implementation is coherent, but it introduces public authorization inputs whose permanent security semantics and compatibility commitment require maintainer ownership. Before merge
Findings
Agent review detailsSecurityNeeds attention: No dependency or supply-chain change is present, but this branch changes a shared sender-authorization boundary and needs maintainer-approved trust semantics before merge. PR surfaceSource +388, Tests +557. Total +945 across 10 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Accept or narrow the RFC’s trusted-evidence and SDK-compatibility contract, then merge this kernel change as the canonical ingress policy foundation for the stacked SDK follow-up. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect reproduction: this is a new authorization capability. The PR nevertheless provides a current-head gateway transcript for its changed Telegram command-authorization path, and source confirms the same policy reaches direct, command, and origin-subject gates. Is this the best way to solve the issue? Unclear: the branch is internally coherent and preserves existing defaults, but the best permanent solution depends on maintainer acceptance of the RFC’s public trust-evidence contract before an authorization API lands. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against dabba0ce108f. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
2de290a to
bdc1f3b
Compare
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
bdc1f3b to
d402de6
Compare
… kernel Implements PR 2 of openclaw/rfcs#51. Replaces the two-level mutable-identifier gate with an ordered `IdentifierAuthentication` scale (verified > asserted > unverified > mutable) plus a per-message subject strength map, so a channel can say how strongly an identifier names its holder AND how strongly one message proved the sender holds it. The gate takes min(entry, subject). Behavior is unchanged for every channel on main: an undescribed entry resolves to `asserted` (clears the shipped minimum), `dangerous: true` resolves to `mutable`, and `mutableIdentifierMatching` maps onto the same scale. No new SDK-exported names (the surface budget enforces this); the types stay internal until the RFC's SDK-surface PR. `subjectAuthentication` is optional on the public `ChannelIngressState` so external constructors are not broken. Test fixtures use neutral example addresses. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WxM7Yy33nFJM71NCaBqhyz
d402de6 to
3b8a607
Compare
galiniliev
left a comment
There was a problem hiding this comment.
This PR replaces the message-access kernel's boolean mutable-identifier filter with a graded entry/per-message authentication policy. That matters because the same sender gate authorizes DMs, pairing-store entries, and command access, so a bypass here becomes an access-control regression.
LOC: +698/-37 (10 files)
By: Omar Shahine (@omarshahine, acct 2014-12-29) | OpenClaw: 109 PRs, 43 issues, 68 commits/12mo | GitHub: 1594 commits, 483 PRs, 160 issues, 22 reviews
Findings:
- [blocking]
dmPolicy: "open"still admits a rejected wildcard sender.applyIdentifierAuthenticationPolicycorrectly rejects a weak wildcard by clearingmatch.matchedand moving the entry into disabled diagnostics, but it leaveshasWildcardset.senderGateForDirectthen checksdm.hasWildcardbeforedm.match.matched, soallowFrom: ["*"]plusdmPolicy: "open"dispatches even when the subject side isunverifiedand the new minimum isasserted. This contradicts the PR's own wildcard invariant inidentifier-authentication.test.tsthat "A wildcard waives the allowlist, not authentication"; that test coversallowlistmode but misses theopenbranch. I reproduced by adding the same wildcard fixture with{ ...allowlistPolicy, dmPolicy: "open" }; the focused test fails withexpected admission: "drop", received"dispatch". Fix by making the filtered allowlist clearhasWildcardwhen the wildcard entry is rejected, or by making the open-DM branch rely on a post-policy wildcard/match fact instead of the rawhasWildcard. Seesrc/channels/message-access/allowlist.ts:151andsrc/channels/message-access/sender-gates.ts:88.
Best-fix verdict: too narrow until the wildcard/open-DM path is fixed. The graded gate is a coherent owner-boundary fix for identifier strength, but this bypass leaves one default ingress branch outside the new invariant.
Alternatives considered: applying the gate only in senderGateForDirect was rejected because command and group/route allowlists already share the policy helper; the shared helper is the right place to preserve derived facts. Rejecting dmPolicy: "open" wildcard support entirely was rejected because current behavior intentionally uses allowFrom: ["*"] to make open DMs explicit.
Code read: src/channels/AGENTS.md, src/channels/message-access/allowlist.ts, src/channels/message-access/sender-gates.ts, src/channels/message-access/decision.ts, src/channels/message-access/state.ts, src/channels/message-access/runtime.ts, src/channels/message-access/runtime-identity.ts, src/channels/message-access/runtime-types.ts, src/channels/message-access/types.ts, src/channels/message-access/message-access.test.ts, and src/channels/message-access/identifier-authentication.test.ts.
Validation: in a detached PR-head worktree, I added a focused regression test for dmPolicy: "open" + wildcard + addressAuthentication: "unverified" and ran node scripts/run-vitest.mjs src/channels/message-access/identifier-authentication.test.ts; it failed with 1 failed / 21 passed, receiving admission: "dispatch" instead of "drop". The first run without the main checkout's installed dependencies failed before Vitest; rerunning with a temporary node_modules symlink reached Vitest.
Provenance: N/A; this is new feature behavior in #116281.
Remaining uncertainty: I did not run the full channel suite or live Crabbox proof after the local negative test because this is a review-only pass and the focused test already isolates the bypass.
The graded identifier-authentication gate rejected a weak wildcard by clearing its allowlist match, but three ingress branches still read pre-policy facts and dispatched it anyway: - Open DM policy checked `hasWildcard` before `match.matched`, so `allowFrom: ["*"]` + `dmPolicy: "open"` dispatched an `unverified` subject under an `asserted` minimum. It now authorizes on the post-policy `match.matched` and uses `hasWildcard` only to label the reason (galiniliev review on #116281). - A wildcard could borrow strength from an identifier field the subject never carried. `effectiveEntryAuthentication` now returns `mutable` for a wildcard whose kind is absent from the subject, threaded via `subjectIdentifierKinds`. - The event gate matched an origin subject on identity equality alone. It now requires the matched origin identity's authentication to meet the minimum, via a new `originSubjectAuthentication` strength on state. Regression tests cover all three in identifier-authentication.test.ts. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01WxM7Yy33nFJM71NCaBqhyz
|
Fixed in Reviewing the shared policy helper surfaced two sibling paths with the same pre-policy-fact bug, fixed here too:
Regression tests for all three in Validation: |
Autoreview flagged that two optional fields on the public `ChannelIngressState` were treated as mandatory by authorization, so a caller constructing state directly without them would hit silent ingress denials. - allowlist.ts: only downgrade a wildcard to `mutable` when the subject's carried identifier kinds are actually known. An absent `subjectIdentifierKinds` no longer weakens the entry, consistent with the "an absent claim does not weaken" rule directly below it. The resolver always supplies the kinds, so the missing-identity downgrade still holds on the real ingress path. - decision.ts: a matched origin subject that omits its strength defaults to the baseline `asserted` (now a shared export) instead of being dropped, so the minimum is applied uniformly rather than failing a matched legacy state. Compat regression tests for both in identifier-authentication.test.ts. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01WxM7Yy33nFJM71NCaBqhyz
Implements PR 2 of the stack in openclaw/rfcs#51. Do not merge before that RFC is accepted.
What Problem This Solves
The ingress kernel has one question it can ask about a sender identifier: is it
dangerousor not.applyMutableIdentifierPolicyreads that boolean and either keeps an allowlist entry or drops it, andmutableIdentifierMatchingflips which way. Two values, one axis.That is enough for a transport that authenticates the session. Once the session is established, every identifier it reports is as good as the session, so identifier strength is a static property of the field and never changes between messages.
It is not enough for a transport that authenticates the message. On email the same address is strong or weak depending on what arrived with it: a DKIM signature aligned to the sender's domain, an unaligned one, or nothing at all. The kernel currently has no way to be told that, so an allowlisted address authorizes its sender whether or not the message carrying it proved anything. There is no value of
dangerousthat expresses "this identifier is exact and stable, and this particular message did not prove the sender holds it".Why This Change Was Made
Replaces the boolean with an ordered scale and a second axis.
IdentifierAuthenticationisverified > asserted > unverified > mutable. Two independent claims feed it:The gate takes
min(entry, subject). An unforgeable identifier proves nothing when the message carrying it was never authenticated, and an authenticated message proves nothing when the identifier it carries is an alias anyone can adopt.unverifiedandmutableare kept apart although both sit below the default minimum. A display name is weak because it is an alias: two senders can hold it at once. An unauthenticatedFrom:is weak because nothing bound it: it is exact and stable, and its claimed ownership is simply unproven. Collapsing them makes an unauthenticated email address read as a nickname in the diagnostic.Matching is kind-scoped, so an entry's subject-side claim is the claim made for its own kind. A wildcard entry is built from the primary identity field and therefore carries the primary kind, which makes "how well do we know who this is" the question it answers, with no special case in the gate.
User Impact
None on any channel on
main. The compatibility argument is mechanical:dangerousasserteddangerous: truemutableassertedmutableIdentifierMatching: "enabled"mutableassertedclears anassertedminimum andmutabledoes not, so every existing admission and rejection is preserved, including the alias case reaching its long-standingmutable_identifier_disabledreason code. The newidentifier_authentication_too_weakcode appears only for weakness the two-level policy could not express.Three deliberate restrictions keep it that way:
authentication. It does not re-derive fromdangerous, which can be a predicate over the value and so can disagree between the entry and subject sides for the same field. Weakening per message stays opt-in.assertedandmin()cannot climb above it, so a channel cannot satisfy averifiedminimum by never saying anything. Reachingverifiedis an explicit claim.ChannelIngressState.subjectAuthenticationis optional. The type is public and callers construct it, so a required field is a breaking change; absent reads the same as empty.Evidence
All on Blacksmith Testbox warmed from this branch, at head
2de290a2:node scripts/run-vitest.mjs src/channels/message-access/pnpm tsgonode scripts/run-oxlint.mjs src/channels/message-accessoxfmt --check src/channels/message-accesspnpm deadcode:fullpnpm check:test-typesThe 30 span the pre-existing
message-access.test.ts(unmodified, 9 tests, includingrequires explicit dangerous identifier matching— the direct compatibility regression test) and the newidentifier-authentication.test.ts(21 tests).Hosted CI on
2de290a2: green, zero non-passing checks.Runtime proof (Crabbox,
tbx_01kyspcm3x21r2zrp0y77jj4f8). Unit tests and a type-level argument are not enough for a "no channel changes behaviour" claim, so this also ran against a real gateway driving the real Telegram plugin through a Crabline local provider, no live credentials:That scenario is the admit → reject → admit cycle: an allowlisted operator issues a native command and is authorized,
allowFromis emptied and the command is rejected,allowFromis restored and authorization returns. Command authorization runs throughapplyIdentifierAuthenticationPolicyon the command allowlists, so this exercises the changed gate end to end at runtime.Runtime proof refreshed at current head
00ca77be. The transcript above ran on2de290a2; the two commits since then changed wildcard, origin-subject, and legacy-state authorization, so the same scenario and the same Crabline driver were re-run at the current head on Blacksmith Testbox (tbx_01kyxqvxdq3w8q8b9yyytws092):Same admit → reject → admit cycle, now on the head that carries the wildcard/origin-subject/legacy-state fixes. The WhatsApp proof gap below is unchanged (harness limitation, not this change).
Proof gap, stated rather than papered over. The two WhatsApp access-control scenarios (
whatsapp-pairing-block,whatsapp-access-control-group-disabled) could not run. They fail atsuite partitionwithtimed out waiting for whatsapp ready … running: false— the transport never starts, before any ingress decision. The cause is the harness, not this change:extensions/qa-lab/src/crabline-transport.ts:414returns the adapter config unchanged for any channel other thantelegram(with asignalbranch at :411), so WhatsApp gets no account wiring under Crabline. The pairing-store call site therefore has unit coverage (message-access.test.ts›keeps pairing-store entries DM-policy scoped) but no runtime coverage here.Separately worth noting for the repo rather than this PR: every access-control QA scenario is bound to a channel-specific lane; none exists on the generic
qa-channellane. That is why a kernel-level ingress change has no cheap runtime proof available, and it looks like a coverage gap worth its own issue.New tests cover the scale ordering and
min(), the two mappings in the table above, per-message weakening and that it applies only to its own kind, weaker-wins when one kind is described twice, wildcard entries, the raised-minimum cases in both directions, command-gate parity, and that no raw sender value reaches state or a decision.Three findings, all from building this rather than reasoning about it. The first two are folded back into the RFC:
ChannelIngressPolicyInput,ChannelIngressState,ChannelIngressIdentityField,ChannelIngressIdentitySubjectInput, andIngressReasonCodeare all already re-exported fromsrc/plugin-sdk/channel-ingress-runtime.ts, so the fields land on public types no matter where the code lives. What is achievable, and what this PR does, is adding no new exported names: the surface budget rejected the two type exports I first added (public exports 4776 > 4774), and per the RFC those belong in PR 3 with thedangerousdeprecation.verifiedmessage cannot lift an entry the channel never described. My first fixture assumed it could. This is the RFC's stated intent working correctly, but it means PR 4's channel migration is load-bearing for any strict posture, not optional polish.subjectAuthenticationstarted out required onChannelIngressStateand brokeextensions/qqbot, which constructs that type directly. A public type nobody is supposed to build turns out to be built. Now optional.Non-test LOC is +274. The growth is a new primitive replacing a boolean, and roughly half of the new module is the reasoning behind the scale. The deletions land in PR 3 and PR 4, when
dangerousandmutableIdentifierMatchingcome out.