Skip to content

feat(channels): grade sender identifier authentication in the ingress kernel - #116281

Closed
omarshahine wants to merge 3 commits into
mainfrom
omarshahine/rfc-0027-kernel
Closed

omarshahine wants to merge 3 commits into
mainfrom
omarshahine/rfc-0027-kernel

Conversation

@omarshahine

@omarshahine omarshahine commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

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 dangerous or not. applyMutableIdentifierPolicy reads that boolean and either keeps an allowlist entry or drops it, and mutableIdentifierMatching flips 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 dangerous that 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.

IdentifierAuthentication is verified > asserted > unverified > mutable. Two independent claims feed it:

  • Entry side, static: how strongly this field names its holder. Declared per identity field.
  • Subject side, per message: what this message proved. Supplied only by channels that authenticate messages.

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.

unverified and mutable are 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 unauthenticated From: 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:

today resolves to
entry with no dangerous asserted
dangerous: true mutable
default policy minimum asserted
mutableIdentifierMatching: "enabled" minimum mutable

asserted clears an asserted minimum and mutable does not, so every existing admission and rejection is preserved, including the alias case reaching its long-standing mutable_identifier_disabled reason code. The new identifier_authentication_too_weak code appears only for weakness the two-level policy could not express.

Three deliberate restrictions keep it that way:

  • The subject side reads only an explicit authentication. It does not re-derive from dangerous, 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.
  • Silence caps an entry at asserted and min() cannot climb above it, so a channel cannot satisfy a verified minimum by never saying anything. Reaching verified is an explicit claim.
  • ChannelIngressState.subjectAuthentication is 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:

gate result
node scripts/run-vitest.mjs src/channels/message-access/ 30 passed / 30
pnpm tsgo clean
node scripts/run-oxlint.mjs src/channels/message-access exit 0
oxfmt --check src/channels/message-access exit 0
pnpm deadcode:full exit 0
pnpm check:test-types exit 0

The 30 span the pre-existing message-access.test.ts (unmodified, 9 tests, including requires explicit dangerous identifier matching — the direct compatibility regression test) and the new identifier-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:

[qa-suite] gateway ready: http://127.0.0.1:40373
[qa-suite] scenario pass (1/1): telegram-repeated-command-authorization
[qa-suite] run complete: passed=1 failed=0 skipped=0 total=1

That scenario is the admit → reject → admit cycle: an allowlisted operator issues a native command and is authorized, allowFrom is emptied and the command is rejected, allowFrom is restored and authorization returns. Command authorization runs through applyIdentifierAuthenticationPolicy on 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 on 2de290a2; 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):

provider=blacksmith-testbox id=tbx_01kyxqvxdq3w8q8b9yyytws092 sync=delegated auth=blacksmith
00ca77be4d9705e6ae21fecb14dcba06108afc18
$ node scripts/run-node.mjs qa suite --channel-driver crabline --channel telegram --scenario telegram-repeated-command-authorization
[qa-suite] run start: scenarios=1 concurrency=1 transport=qa-channel channelDriver=crabline channel=telegram
[qa-suite] lab ready: http://127.0.0.1:35207
[qa-suite] provider ready: live
[qa-suite] gateway ready: http://127.0.0.1:33963
[qa-suite] scenario pass (1/1): telegram-repeated-command-authorization
[qa-suite] run complete: passed=1 failed=0 skipped=0 total=1

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 at suite partition with timed 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:414 returns the adapter config unchanged for any channel other than telegram (with a signal branch 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-channel lane. 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:

  1. The RFC bills PR 2 as "internal types only; SDK surface unchanged". That is not achievable. ChannelIngressPolicyInput, ChannelIngressState, ChannelIngressIdentityField, ChannelIngressIdentitySubjectInput, and IngressReasonCode are all already re-exported from src/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 the dangerous deprecation.
  2. A verified message 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.
  3. subjectAuthentication started out required on ChannelIngressState and broke extensions/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 dangerous and mutableIdentifierMatching come out.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 30, 2026
@omarshahine
omarshahine marked this pull request as ready for review July 30, 2026 07:16
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:37 AM ET / 10:37 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 4 items remain

Keep 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
Reviewed head: 00ca77be4d9705e6ae21fecb14dcba06108afc18
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused current-head gateway proof and regression coverage support the patch; the remaining blocker is the deliberately deferred RFC decision on public authorization semantics.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body includes current-head Testbox live output from a real gateway using the Telegram plugin, showing the changed command-authorization path pass an admit–reject–admit scenario.
Patch quality 🐚 platinum hermit (4/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body includes current-head Testbox live output from a real gateway using the Telegram plugin, showing the changed command-authorization path pass an admit–reject–admit scenario.
Evidence reviewed 6 items Current main still has the existing boolean policy: The existing ingress policy admits every entry when mutable matching is enabled and otherwise removes entries marked dangerous; the proposed graded authentication model is not present on current main.
Current ingress surface is publicly re-exported: The plugin SDK already re-exports identity, policy, state, and reason-code types from the ingress subsystem, so fields added to those types become an external channel-plugin compatibility commitment.
Branch adds authorization claims to public inputs: The branch adds authentication to identity-field and inbound-subject inputs; these claims determine whether a matched allowlist entry can authorize a sender.
Findings None None.
Security Needs attention Define trusted evidence for verified claims: The new authentication field can authorize sender identities across shared ingress gates, so the RFC must define what transport evidence legitimately supports verified before plugins rely on it.

How this fits together

Channel 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
Loading

Decision needed

Question Recommendation
Should OpenClaw accept the RFC-defined graded sender-authentication contract, including the trusted transport evidence required for a channel to claim verified, before merging this kernel PR? Accept the RFC contract: Approve the ordered authentication model and its evidence standards, then proceed with this kernel PR and the SDK follow-up.

Why: The implementation is coherent, but it introduces public authorization inputs whose permanent security semantics and compatibility commitment require maintainer ownership.

Before merge

  • Resolve security concern: Define trusted evidence for verified claims - The new authentication field can authorize sender identities across shared ingress gates, so the RFC must define what transport evidence legitimately supports verified before plugins rely on it.
  • Resolve merge risk (P1) - authentication can alter whether an allowlisted identity authorizes commands and messages; without an approved definition of the transport evidence required for verified, channel implementations could make inconsistent trust claims.
  • Resolve merge risk (P1) - The branch extends SDK-re-exported ingress types and deprecates the existing boolean vocabulary, so the permanent compatibility and migration direction should not be selected by an implementation PR alone.

Findings

  • [medium] Define trusted evidence for verified claims — src/channels/message-access/runtime-types.ts:54
Agent review details

Security

Needs 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 surface

Source +388, Tests +557. Total +945 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 9 455 67 +388
Tests 1 557 0 +557
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 1012 67 +945

Review metrics

Metric Value Why it matters
Public authorization inputs 3 new inputs: identity-field authentication, per-message authentication, and a minimum authentication threshold These extend SDK-re-exported ingress contracts and can change future channel authorization outcomes.

Stored data model

Persistent data-model change detected: serialized state: src/channels/message-access/state.ts, unknown-data-model-change: src/channels/message-access/state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Approve the contract before merge (recommended)
    Confirm the RFC’s evidence model and public SDK direction before merging a shared authorization-boundary change.
  2. Retain the established policy
    Decline the new public strength contract and keep the existing mutable-identifier policy until a narrower design is accepted.

Technical review

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

Labels

Label justifications:

  • P2: This is a significant shared-channel authorization improvement, but no active user-facing regression is demonstrated.
  • merge-risk: 🚨 compatibility: The branch extends public ingress identity, subject, policy, and state contracts re-exported to channel plugins.
  • merge-risk: 🚨 security-boundary: The new claims directly control whether allowlisted identities pass message and command authorization.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes current-head Testbox live output from a real gateway using the Telegram plugin, showing the changed command-authorization path pass an admit–reject–admit scenario.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes current-head Testbox live output from a real gateway using the Telegram plugin, showing the changed command-authorization path pass an admit–reject–admit scenario.

Evidence

Security concerns:

  • [medium] Define trusted evidence for verified claims — src/channels/message-access/runtime-types.ts:54
    The new authentication field can authorize sender identities across shared ingress gates, so the RFC must define what transport evidence legitimately supports verified before plugins rely on it.
    Confidence: 0.9

What I checked:

  • Current main still has the existing boolean policy: The existing ingress policy admits every entry when mutable matching is enabled and otherwise removes entries marked dangerous; the proposed graded authentication model is not present on current main. (src/channels/message-access/allowlist.ts:89, 78486e27511c)
  • Current ingress surface is publicly re-exported: The plugin SDK already re-exports identity, policy, state, and reason-code types from the ingress subsystem, so fields added to those types become an external channel-plugin compatibility commitment. (src/plugin-sdk/channel-ingress-runtime.ts:18, b6b440d07680)
  • Branch adds authorization claims to public inputs: The branch adds authentication to identity-field and inbound-subject inputs; these claims determine whether a matched allowlist entry can authorize a sender. (src/channels/message-access/runtime-types.ts:46, 00ca77be4d97)
  • Branch applies the model across shared authorization paths: Command allowlists, direct-message sender gates, and origin-subject callback authorization all apply the new threshold rather than leaving a sibling path on pre-policy facts. (src/channels/message-access/decision.ts:107, 00ca77be4d97)
  • Compatibility and regression coverage are substantial: The added test suite covers the default mapping, per-message weakening, wildcard behavior, command authorization, origin-subject authorization, and raw-identifier redaction; the PR body also supplies current-head Testbox gateway output for the Telegram command authorization cycle. (src/channels/message-access/identifier-authentication.test.ts:93, 00ca77be4d97)
  • Feature provenance and release context: Peter Steinberger introduced the current message-access subsystem in commit 78486e2 on July 31, 2026; it post-dates release v2026.7.1 from July 13, 2026. The reviewed branch is not on current main, whose current tip is dabba0c. (src/channels/message-access/allowlist.ts:89, 78486e27511c)

Likely related people:

  • Peter Steinberger: Introduced the current shared message-access subsystem, including its allowlist, decision, identity, state, and sender-gate files, in commit 78486e2. (role: feature introducer and recent area contributor; confidence: high; commits: 78486e27511c; files: src/channels/message-access/allowlist.ts, src/channels/message-access/decision.ts, src/channels/message-access/runtime-types.ts)
  • galiniliev: The PR timeline records assignment, and the contributor credits review feedback for the open-DM wildcard authorization correction included in the branch. (role: assigned reviewer and adjacent authorization reviewer; confidence: medium; files: src/channels/message-access/sender-gates.ts)

Rank-up moves

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

  • Obtain explicit RFC or maintainer confirmation of the trusted-evidence standard for verified and the intended SDK compatibility surface.

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 (7 earlier review cycles)
  • reviewed 2026-07-30T07:26:08.528Z sha b3d29a9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T07:35:17.142Z sha 2de290a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T14:58:57.622Z sha 2de290a :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T02:52:14.429Z sha 3b8a607 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T18:52:07.552Z sha 0b99df3 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T22:31:05.752Z sha 00ca77b :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T04:47:51.540Z sha 00ca77b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 30, 2026
@omarshahine
omarshahine force-pushed the omarshahine/rfc-0027-kernel branch from 2de290a to bdc1f3b Compare July 31, 2026 02:40
@omarshahine
omarshahine requested review from a team as code owners July 31, 2026 02:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser app: android App: android labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 00ca77be4d9705e6ae21fecb14dcba06108afc18

@omarshahine
omarshahine force-pushed the omarshahine/rfc-0027-kernel branch from bdc1f3b to d402de6 Compare July 31, 2026 02:41
… 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
@omarshahine
omarshahine force-pushed the omarshahine/rfc-0027-kernel branch from d402de6 to 3b8a607 Compare July 31, 2026 02:47
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Jul 31, 2026

@galiniliev galiniliev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. applyIdentifierAuthenticationPolicy correctly rejects a weak wildcard by clearing match.matched and moving the entry into disabled diagnostics, but it leaves hasWildcard set. senderGateForDirect then checks dm.hasWildcard before dm.match.matched, so allowFrom: ["*"] plus dmPolicy: "open" dispatches even when the subject side is unverified and the new minimum is asserted. This contradicts the PR's own wildcard invariant in identifier-authentication.test.ts that "A wildcard waives the allowlist, not authentication"; that test covers allowlist mode but misses the open branch. I reproduced by adding the same wildcard fixture with { ...allowlistPolicy, dmPolicy: "open" }; the focused test fails with expected admission: "drop", received "dispatch". Fix by making the filtered allowlist clear hasWildcard when the wildcard entry is rejected, or by making the open-DM branch rely on a post-policy wildcard/match fact instead of the raw hasWildcard. See src/channels/message-access/allowlist.ts:151 and src/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
@omarshahine

Copy link
Copy Markdown
Contributor Author

Fixed in 0b99df3. The open-DM branch no longer trusts pre-policy hasWildcard — it authorizes on the post-policy match.matched and uses hasWildcard only to label the reason (src/channels/message-access/sender-gates.ts:88). Your repro (dmPolicy: "open" + allowFrom: ["*"] + unverified subject under an asserted minimum) now drops instead of dispatching; added it as a regression test.

Reviewing the shared policy helper surfaced two sibling paths with the same pre-policy-fact bug, fixed here too:

  • A wildcard could borrow strength from an identifier kind the subject never carried. effectiveEntryAuthentication now returns mutable for a wildcard whose kind is absent from the subject, threaded via a new subjectIdentifierKinds (allowlist.ts, state.ts).
  • 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 an originSubjectAuthentication strength on state (decision.ts, state.ts).

Regression tests for all three in identifier-authentication.test.ts.

Validation: identifier-authentication.test.ts 25/25, full message-access suite 34/34, tsgo:core clean, oxfmt clean.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants