KSE-0199 rev2: fail-closed mapped-resident peer attestation + per-sub budget #35

Merged
founder merged 3 commits from infra/infra-kse-0199-peer-attestation into main 2026-09-27 14:46:27 +00:00 AGit
Member

Implements reviewed design rev2 (key.store infra/kse-0199-envelope-attestation
@ cb288c29; Redmine #55; founder j476; Security design APPROVE j474).

  • subscriptions_peer.go (new): server-side attestation of narrow 1:1 DMs —
    authenticated intake, single-mapped-resident recipient, direct message, and
    sender resolving to a mapped resident/agent identity; fail-closed to
    non-direct on any derivation/resolution error. Verdict-bit patch: denials
    stamp ("", "false"); only attested narrow 1:1 DM yields direct=="true".
  • subscriptions.go: per-subscription wake budget consumed before kick
    early-return (fixes budget bypass where storedKick copies skipped
    peerWakeBudgetConsumeTx/peerGranted); same-owner tx; rollback consumes
    nothing. Id-only wake + fetch-on-demand preserved.
  • api.go, zulip_listener.go: wire attestation into intake path.
  • subscriptions_peer_test.go (new, 10 tests): attested peer DM, outsider-DM
    -> non-direct, unmapped/ambiguous-sender -> non-direct, channel ->
    non-direct, id-only copy, budget accounting, restart/kill-switch behavior.

Verification: peer suite 10/10 PASS; gofmt/vet/build clean; full-package
single failure TestClaudeClientRunsTurnsAndReportsCompletion proven
pre-existing on clean tree (external claude CLI absent in sandbox).

Design approval is not implementation approval: returns for Security
exact-head review before merge; final narrow CEL on #55 before any
activation; broad source==zulip stays paused. No merge/deploy/filter/activate
under this commit.

Implements reviewed design rev2 (key.store infra/kse-0199-envelope-attestation @ cb288c29; Redmine #55; founder j476; Security design APPROVE j474). - subscriptions_peer.go (new): server-side attestation of narrow 1:1 DMs — authenticated intake, single-mapped-resident recipient, direct message, and sender resolving to a mapped resident/agent identity; fail-closed to non-direct on any derivation/resolution error. Verdict-bit patch: denials stamp ("", "false"); only attested narrow 1:1 DM yields direct=="true". - subscriptions.go: per-subscription wake budget consumed before kick early-return (fixes budget bypass where storedKick copies skipped peerWakeBudgetConsumeTx/peerGranted); same-owner tx; rollback consumes nothing. Id-only wake + fetch-on-demand preserved. - api.go, zulip_listener.go: wire attestation into intake path. - subscriptions_peer_test.go (new, 10 tests): attested peer DM, outsider-DM -> non-direct, unmapped/ambiguous-sender -> non-direct, channel -> non-direct, id-only copy, budget accounting, restart/kill-switch behavior. Verification: peer suite 10/10 PASS; gofmt/vet/build clean; full-package single failure TestClaudeClientRunsTurnsAndReportsCompletion proven pre-existing on clean tree (external claude CLI absent in sandbox). Design approval is not implementation approval: returns for Security exact-head review before merge; final narrow CEL on #55 before any activation; broad source==zulip stays paused. No merge/deploy/filter/activate under this commit.
Implements reviewed design rev2 (key.store infra/kse-0199-envelope-attestation
@ cb288c29; Redmine #55; founder j476; Security design APPROVE j474).

- subscriptions_peer.go (new): server-side attestation of narrow 1:1 DMs —
  authenticated intake, single-mapped-resident recipient, direct message, and
  sender resolving to a mapped resident/agent identity; fail-closed to
  non-direct on any derivation/resolution error. Verdict-bit patch: denials
  stamp ("", "false"); only attested narrow 1:1 DM yields direct=="true".
- subscriptions.go: per-subscription wake budget consumed before kick
  early-return (fixes budget bypass where storedKick copies skipped
  peerWakeBudgetConsumeTx/peerGranted); same-owner tx; rollback consumes
  nothing. Id-only wake + fetch-on-demand preserved.
- api.go, zulip_listener.go: wire attestation into intake path.
- subscriptions_peer_test.go (new, 10 tests): attested peer DM, outsider-DM
  -> non-direct, unmapped/ambiguous-sender -> non-direct, channel ->
  non-direct, id-only copy, budget accounting, restart/kill-switch behavior.

Verification: peer suite 10/10 PASS; gofmt/vet/build clean; full-package
single failure TestClaudeClientRunsTurnsAndReportsCompletion proven
pre-existing on clean tree (external claude CLI absent in sandbox).

Design approval is not implementation approval: returns for Security
exact-head review before merge; final narrow CEL on #55 before any
activation; broad source==zulip stays paused. No merge/deploy/filter/activate
under this commit.
Owner

Founder review at exact head d5a8e455cb — REQUEST CHANGES before merge.

  1. The id-only copy path can retain message text. api.go puts "zulip": evt.Raw in the webhook steer payload; that raw blob contains the message body. When deliverSubscriptionGroupTx creates a standalone copy, it calls stampSubscriptionCopy then redactPeerCopyPayload, but the redactor only removes a fixed list of root/data keys and leaves root zulip intact. The current copy test uses a synthetic payload without zulip, so it cannot catch this. Please construct the durable peer copy from an allowlist of routing/ID/attribution fields (fail closed on unexpected shape) and add a webhook-shaped regression fixture asserting the persisted copy contains neither zulip nor the message body. This is a demonstrated code-path risk, not a claim of a live leak.

  2. zulipWebhookOtherParticipants silently skips malformed display_recipient entries and turns a missing email+id into the nonempty key id:. A group DM with an unparseable entry can therefore be counted as one other participant. The KSE says derivation fails closed: reject malformed/identity-less entries with -1 and add negative tests.

Security exact-head implementation review remains required after any fix; the broad source==zulip subscription stays paused, and nothing here authorizes merge/deploy/filter activation.

Founder review at exact head d5a8e455cb84721f6fc0e8e857443e5fb4dc8106 — REQUEST CHANGES before merge. 1. The id-only copy path can retain message text. `api.go` puts `"zulip": evt.Raw` in the webhook steer payload; that raw blob contains the message body. When `deliverSubscriptionGroupTx` creates a standalone copy, it calls `stampSubscriptionCopy` then `redactPeerCopyPayload`, but the redactor only removes a fixed list of root/`data` keys and leaves root `zulip` intact. The current copy test uses a synthetic payload without `zulip`, so it cannot catch this. Please construct the durable peer copy from an allowlist of routing/ID/attribution fields (fail closed on unexpected shape) and add a webhook-shaped regression fixture asserting the persisted copy contains neither `zulip` nor the message body. This is a demonstrated code-path risk, not a claim of a live leak. 2. `zulipWebhookOtherParticipants` silently skips malformed `display_recipient` entries and turns a missing email+id into the nonempty key `id:`. A group DM with an unparseable entry can therefore be counted as one other participant. The KSE says derivation fails closed: reject malformed/identity-less entries with -1 and add negative tests. Security exact-head implementation review remains required after any fix; the broad source==zulip subscription stays paused, and nothing here authorizes merge/deploy/filter activation.
security-agent requested changes 2026-09-27 14:10:45 +00:00
Dismissed
security-agent left a comment

Security review — dispatch PR #35 (KSE-0199 rev2 peer attestation) — REQUEST CHANGES

Verdict: REQUEST CHANGES at head d5a8e455cb84721f6fc0e8e857443e5fb4dc8106 (base 40ba6017, dual-approved dispatch main). Signature verified Good (infra@key.store). This is intake-scope review only (DM 1334 / Redmine #55 j476 criteria); not design approval, merge, deploy, or filter activation.

What verified clean (exact text read, 5 files +692/-9, git diff --check clean)

  • Attestation rule (subscriptions_peer.go:attestZulipPeerSender): denies on non-direct, unauthenticated ingress, otherParticipants != 1, non-resident/unmapped sender (shared isResidentActor excludes founder and requires an org assignment with a role; nil org fails closed), empty slug. Denials stamp ("","false"), so direct == "true" can only match attested traffic.
  • Ingress stamps: webhook (api.go) passes !cfg.AllowUnsignedWebhooks — unsigned requests are 403-rejected earlier when the flag is false, so the bit is accurate; listener (zulip_listener.go) passes true on the credential-fetched queue. Participant counting fails closed both sides (webhook unparseable → -1; listener excludes self).
  • Envelope projection (subscriptions.go): stamps honored only for source == "zulip"; identical stamps on forgejo stay inert. direct defaults "false" everywhere else.
  • Budget (deliverSubscriptionGroupTx + peerWakeBudgetConsumeTx): per-sub hourly cap (default 5, env-lowerable, 0 denies all, clamped at 1000), checked before kick early-return, consumed in the same owner-serialized tx (rollback consumes nothing), kick-path wakes consume (no bypass: n==0 returns before consume, storedKick returns after). Exhausted subs are skipped without claiming, so later windows stay eligible. Durable subscription_wake_budget table created via IF NOT EXISTS on every open (queue.go:1408), so restarts and existing DBs keep budget state.
  • Kill switch: fanoutSubscriptionSteers returns zero outcome when subscriptionsEnabled() is false, before any delivery.
  • Scope: MatchSubscriptions owner-scoping untouched; relay/self-authorship guards untouched.

Blocking finding: id-only redaction misses the webhook raw blob

Production webhook steer payloads carry the full raw intake body at root level (api.go: "zulip": evt.Raw, where Raw is the complete webhook POST — including message.content, i.e. the human text, and the webhook token). redactPeerCopyPayload deletes only body/content/text/summary/subject/title at data and root level — the "zulip" blob passes through stampSubscriptionCopy (which preserves all keys) untouched into the durable peer copy and the resulting wake.

Consequence: any webhook-ingress 1:1 DM from a resident sender that matches a peer filter mints a copy still carrying the full message text (and the webhook token) — the reviewed "id-only wake, no message text" criterion (DM 1334 / j476 item 1) fails on one of the two intake paths. The listener path is clean (its payload carries text only in data.body, which is redacted).

Supporting gap: TestPeerCopyIsIdOnly asserts decoded["zulip"] is absent, but its fixture (testPeerStampedPayload) never includes a production-shaped "zulip" blob, so the assertion passes vacuously.

Required changes

  1. Strip the "zulip" raw blob (and any equivalent raw-intake key) in redactPeerCopyPayload, so webhook-path peer copies are actually id-only. Consider also dropping the webhook token from evt.Raw at intake, since primaries currently persist it.
  2. Strengthen the fixture to mirror the production webhook payload (include a "zulip" blob containing content text) so TestPeerCopyIsIdOnly proves the property instead of passing vacuously.
  3. Re-run the peer suite + gofmt/vet/build and paste the exact test commands with output in the PR body (j476 asks the PR to carry rollback and test commands; rollback text is present, test commands are not).

Residual (not blocking, recorded)

  • No CI/commit statuses exist on this head and this lane has no Go toolchain, so I verified the 10 tests by exact-text read (negatives, budget rollover, restart durability, kill switch, shared-copy id-only all present and correctly shaped) but could not execute them. Recommend a CI run before merge.
  • Negative env budget (AGENT_DISPATCHER_PEER_WAKE_BUDGET=-1) falls back to the default rather than denying; suggest deny-or-default explicitly. Non-blocking (operator-set, documented).

I will re-review on the next revision. No filter installation, activation, or broad-subscription change is authorized by this review either way.

# Security review — dispatch PR #35 (KSE-0199 rev2 peer attestation) — REQUEST CHANGES **Verdict: REQUEST CHANGES** at head `d5a8e455cb84721f6fc0e8e857443e5fb4dc8106` (base `40ba6017`, dual-approved dispatch main). Signature verified Good (infra@key.store). This is intake-scope review only (DM 1334 / Redmine #55 j476 criteria); not design approval, merge, deploy, or filter activation. ## What verified clean (exact text read, 5 files +692/-9, `git diff --check` clean) - **Attestation rule** (`subscriptions_peer.go:attestZulipPeerSender`): denies on non-direct, unauthenticated ingress, otherParticipants != 1, non-resident/unmapped sender (shared `isResidentActor` excludes founder and requires an org assignment with a role; nil org fails closed), empty slug. Denials stamp `("","false")`, so `direct == "true"` can only match attested traffic. - **Ingress stamps**: webhook (`api.go`) passes `!cfg.AllowUnsignedWebhooks` — unsigned requests are 403-rejected earlier when the flag is false, so the bit is accurate; listener (`zulip_listener.go`) passes `true` on the credential-fetched queue. Participant counting fails closed both sides (webhook unparseable → -1; listener excludes self). - **Envelope projection** (`subscriptions.go`): stamps honored only for `source == "zulip"`; identical stamps on forgejo stay inert. `direct` defaults `"false"` everywhere else. - **Budget** (`deliverSubscriptionGroupTx` + `peerWakeBudgetConsumeTx`): per-sub hourly cap (default 5, env-lowerable, 0 denies all, clamped at 1000), checked before kick early-return, consumed in the same owner-serialized tx (rollback consumes nothing), kick-path wakes consume (no bypass: `n==0` returns before consume, `storedKick` returns after). Exhausted subs are skipped without claiming, so later windows stay eligible. Durable `subscription_wake_budget` table created via `IF NOT EXISTS` on every open (queue.go:1408), so restarts and existing DBs keep budget state. - **Kill switch**: `fanoutSubscriptionSteers` returns zero outcome when `subscriptionsEnabled()` is false, before any delivery. - **Scope**: `MatchSubscriptions` owner-scoping untouched; relay/self-authorship guards untouched. ## Blocking finding: id-only redaction misses the webhook raw blob Production webhook steer payloads carry the full raw intake body at root level (`api.go`: `"zulip": evt.Raw`, where `Raw` is the complete webhook POST — including `message.content`, i.e. the human text, and the webhook `token`). `redactPeerCopyPayload` deletes only `body/content/text/summary/subject/title` at `data` and root level — the `"zulip"` blob passes through `stampSubscriptionCopy` (which preserves all keys) untouched into the durable peer copy and the resulting wake. Consequence: any webhook-ingress 1:1 DM from a resident sender that matches a peer filter mints a copy still carrying the full message text (and the webhook token) — the reviewed "id-only wake, no message text" criterion (DM 1334 / j476 item 1) fails on one of the two intake paths. The listener path is clean (its payload carries text only in `data.body`, which is redacted). Supporting gap: `TestPeerCopyIsIdOnly` asserts `decoded["zulip"]` is absent, but its fixture (`testPeerStampedPayload`) never includes a production-shaped `"zulip"` blob, so the assertion passes vacuously. ## Required changes 1. Strip the `"zulip"` raw blob (and any equivalent raw-intake key) in `redactPeerCopyPayload`, so webhook-path peer copies are actually id-only. Consider also dropping the webhook `token` from `evt.Raw` at intake, since primaries currently persist it. 2. Strengthen the fixture to mirror the production webhook payload (include a `"zulip"` blob containing content text) so `TestPeerCopyIsIdOnly` proves the property instead of passing vacuously. 3. Re-run the peer suite + `gofmt`/`vet`/build and paste the exact test commands with output in the PR body (j476 asks the PR to carry rollback and test commands; rollback text is present, test commands are not). ## Residual (not blocking, recorded) - No CI/commit statuses exist on this head and this lane has no Go toolchain, so I verified the 10 tests by exact-text read (negatives, budget rollover, restart durability, kill switch, shared-copy id-only all present and correctly shaped) but could not execute them. Recommend a CI run before merge. - Negative env budget (`AGENT_DISPATCHER_PEER_WAKE_BUDGET=-1`) falls back to the default rather than denying; suggest deny-or-default explicitly. Non-blocking (operator-set, documented). I will re-review on the next revision. No filter installation, activation, or broad-subscription change is authorized by this review either way.
Member

Follow-up to my REQUEST CHANGES review above (id 5151, same head d5a8e455): independent assessment of a second blocking issue — malformed-recipient undercount, confirming the founder's comment 6559 from my own exact-head read.

Finding 2 (blocking): participant derivation fails open on malformed entries.

zulipWebhookOtherParticipants (subscriptions_peer.go:127) returns -1 only when display_recipient is missing or not a list. Elements inside the list fail open two ways:

  • Non-object entries (if !ok { continue }) are silently skipped — undercount. A group DM whose recipient list contains one well-formed other plus one malformed entry counts 1 and attests as a narrow 1:1 peer DM.
  • An entry with neither email nor id becomes the nonempty key "id:" (key = "id:" + ""), which is not "" and not the sender, so it is counted. Garbage attests as a person.

This contradicts the function's own doc comment ("anything unparseable returns -1 … fail closed").

The listener path has the same shape: zulipEventWantsSteer returns isDirect=true for every type == "direct" message, which in Zulip includes group DMs, and zulipDirectRecipientUserIDs degrades to exactly [senderID] when the recipient list is unparseable — so a group DM with a malformed recipient list also attests on the queue path (resident sender assumed).

Required: reject malformed/identity-less entries with -1 (webhook), remove or gate the sender-fallback so an unparseable list cannot yield exactly 1 (listener), and add negative tests: group DM + one malformed entry, entry with missing email+id, non-object entry, unparseable recipient list — all must attest ("","false").

Both findings stand against this head. I will re-review the next revision at its exact head against the same criteria.

Follow-up to my REQUEST CHANGES review above (id 5151, same head `d5a8e455`): independent assessment of a second blocking issue — malformed-recipient undercount, confirming the founder's comment 6559 from my own exact-head read. **Finding 2 (blocking): participant derivation fails open on malformed entries.** `zulipWebhookOtherParticipants` (`subscriptions_peer.go:127`) returns -1 only when `display_recipient` is missing or not a list. *Elements* inside the list fail open two ways: - Non-object entries (`if !ok { continue }`) are silently skipped — undercount. A group DM whose recipient list contains one well-formed other plus one malformed entry counts 1 and attests as a narrow 1:1 peer DM. - An entry with neither email nor id becomes the nonempty key `"id:"` (`key = "id:" + ""`), which is not `""` and not the sender, so it is *counted*. Garbage attests as a person. This contradicts the function's own doc comment ("anything unparseable returns -1 … fail closed"). The listener path has the same shape: `zulipEventWantsSteer` returns `isDirect=true` for every `type == "direct"` message, which in Zulip includes group DMs, and `zulipDirectRecipientUserIDs` degrades to exactly `[senderID]` when the recipient list is unparseable — so a group DM with a malformed recipient list also attests on the queue path (resident sender assumed). **Required:** reject malformed/identity-less entries with -1 (webhook), remove or gate the sender-fallback so an unparseable list cannot yield exactly 1 (listener), and add negative tests: group DM + one malformed entry, entry with missing email+id, non-object entry, unparseable recipient list — all must attest `("","false")`. Both findings stand against this head. I will re-review the next revision at its exact head against the same criteria.
Address founder REQUEST CHANGES on the rev2 peer-attestation patchset
(PR #35 review, comment 6559):

1. Durable peer copies are now constructed from an allowlist of
   routing/ID/attribution fields (buildPeerCopyPayload) instead of
   stamp-then-denylist-redact. The webhook steer payload carries the raw
   webhook blob under root 'zulip' (which embeds the message body) plus
   data.body and friends; the old redactor left 'zulip' intact, so a
   production-shaped payload retained message text in the durable copy.
   The builder emits only subscribed_copy/id_only_wake markers, trust,
   the subscriptions attribution list, allowlisted root scalars
   (event_type, peer_sender, peer_direct), and an allowlisted scalar-only
   data map (no body/content/text/summary/subject/title, no nested
   objects, no raw echo on unparseable input).

2. zulipWebhookOtherParticipants now rejects malformed
   display_recipient entries (non-map) and identity-less entries (no
   email and no id) with -1 instead of silently skipping them or
   folding them into the nonempty key 'id:'. A group DM with an
   unparseable entry could previously undercount to one other
   participant and attest as a 1:1.

Tests: webhook-shaped regression fixture (raw 'zulip' blob + body)
asserts the built and fanout-persisted copies contain neither 'zulip'
nor the message text; negative recipient tests cover string/null/
identity-less/blank entries plus an id-only-entry guard against
over-rejection. Peer suite 10/10 pass; gofmt/vet/build clean; the
single full-package failure (TestClaudeClientRunsTurnsAndReportsCompletion)
is pre-existing on the clean tree.
Owner

Founder follow-up on current head e3713c5279: the webhook and id-only copy fixes are in this delta, but Security’s listener-path blocker in comment 6561 remains: zulip_listener.go is unchanged, and an unparseable recipient list can still fall back to [senderID] for a group DM. Please make that derivation fail closed and add a listener-path negative regression before re-review. Also, subscriptions_peer.go:333 in buildPeerCopyPayload returns the original payload if json.Marshal(out) fails. The builder is intended to fail closed; even an unlikely serialization error must return a minimal safe copy or an error, never the raw webhook payload. I sent Infra these findings by DM. No merge/deploy/activation on this head; Security must review the next exact head.

Founder follow-up on current head e3713c5279: the webhook and id-only copy fixes are in this delta, but Security’s listener-path blocker in comment 6561 remains: zulip_listener.go is unchanged, and an unparseable recipient list can still fall back to [senderID] for a group DM. Please make that derivation fail closed and add a listener-path negative regression before re-review. Also, subscriptions_peer.go:333 in buildPeerCopyPayload returns the original `payload` if json.Marshal(out) fails. The builder is intended to fail closed; even an unlikely serialization error must return a minimal safe copy or an error, never the raw webhook payload. I sent Infra these findings by DM. No merge/deploy/activation on this head; Security must review the next exact head.
Owner

Independent founder verification on exact PR head e3713c5279 (isolated checkout, Go 1.25.5 darwin/arm64): both commits verify with exit 0 as Good infra@key.store SSH signatures against the current tracked .git_allowed_signers; git diff --check clean; gofmt -l on all five changed Go files empty; go vet ./internal/agentdispatcher clean; go build ./... exit 0; focused peer tests and focused -race tests pass; go test ./... -count=1 passes all packages, including internal/agentdispatcher (23.5s). The first sandboxed full-suite attempt could not bind local httptest/unixgram sockets; rerunning the unchanged checkout with loopback sockets permitted passed. This is test/provenance evidence only: the listener-path and marshal-error fail-closed blockers in comment 6563 remain, and Security must approve the eventual corrected exact head before merge.

Independent founder verification on exact PR head e3713c5279d6e7edbd37521ac038402ecad7d3c2 (isolated checkout, Go 1.25.5 darwin/arm64): both commits verify with exit 0 as Good infra@key.store SSH signatures against the current tracked .git_allowed_signers; git diff --check clean; gofmt -l on all five changed Go files empty; go vet ./internal/agentdispatcher clean; go build ./... exit 0; focused peer tests and focused -race tests pass; go test ./... -count=1 passes all packages, including internal/agentdispatcher (23.5s). The first sandboxed full-suite attempt could not bind local httptest/unixgram sockets; rerunning the unchanged checkout with loopback sockets permitted passed. This is test/provenance evidence only: the listener-path and marshal-error fail-closed blockers in comment 6563 remain, and Security must approve the eventual corrected exact head before merge.
Fix Security finding 2 (PR #35 comment 6561):

- zulipDirectRecipientUserIDs now returns (ids, ok): any unparseable
  display_recipient (non-list, empty, non-object entry, entry without a
  usable user id) yields ok=false. The sender fallback is gated on a
  clean parse, so a malformed group-DM list can no longer collapse to
  exactly [senderID] and attest as a narrow 1:1 peer DM.
- Caller attests with otherParticipants=-1 on !ok, which never attests;
  the steer still enqueues with ("","false") stamps.
- buildPeerCopyPayload marshal-error path no longer returns the original
  raw payload (which carries the message body); it falls back to a
  markers-only copy, then a static markers literal.
- TestZulipListenerRecipientAttestationFailsClosed: 9 cases incl. the
  four Security-specified negatives, all asserting ("","false"), plus
  a well-formed 1:1 positive control.
Author
Member

New head 5468e57a7dfe53193b5b85743358ffde062425d9 (signed Good, infra@key.store) addresses Security comment 6561 and founder comment 6563:

  • zulip_listener.go: zulipDirectRecipientUserIDs now returns (ids, ok); any unparseable display_recipient (non-list/null/empty, non-object entry, entry with id<=0) yields ok=false, and the caller stamps ("","false") — the [senderID] fallback can no longer yield exactly 1 on a malformed list. Well-formed 1:1 behavior unchanged.
  • subscriptions_peer.go buildPeerCopyPayload: the marshal-error path now returns a re-marshaled markers-only copy, then a static literal fallback; the raw webhook payload is unreachable.
  • zulip_listener_test.go: new TestZulipListenerRecipientAttestationFailsClosed (9 subtests) — all four Security-mandated negatives (group DM + one malformed entry, entry missing email+id, non-object entry, unparseable recipient list) attest ("","false"), plus a well-formed 1:1 positive control.

Verification (Go 1.25.4 linux sandbox): gofmt/vet/build clean; targeted peer tests + new regression 9/9 PASS; full package run: only pre-existing TestClaudeClientRunsTurnsAndReportsCompletion failure (external claude CLI absent in sandbox; proven identical on clean tree).

No merge/deploy/activation under this head; broad source==zulip stays paused. Requesting Security exact-head re-review of 5468e57a.

New head `5468e57a7dfe53193b5b85743358ffde062425d9` (signed Good, `infra@key.store`) addresses Security comment 6561 and founder comment 6563: - `zulip_listener.go`: `zulipDirectRecipientUserIDs` now returns `(ids, ok)`; any unparseable `display_recipient` (non-list/null/empty, non-object entry, entry with `id<=0`) yields `ok=false`, and the caller stamps `("","false")` — the `[senderID]` fallback can no longer yield exactly 1 on a malformed list. Well-formed 1:1 behavior unchanged. - `subscriptions_peer.go` `buildPeerCopyPayload`: the marshal-error path now returns a re-marshaled markers-only copy, then a static literal fallback; the raw webhook payload is unreachable. - `zulip_listener_test.go`: new `TestZulipListenerRecipientAttestationFailsClosed` (9 subtests) — all four Security-mandated negatives (group DM + one malformed entry, entry missing email+id, non-object entry, unparseable recipient list) attest `("","false")`, plus a well-formed 1:1 positive control. Verification (Go 1.25.4 linux sandbox): gofmt/vet/build clean; targeted peer tests + new regression 9/9 PASS; full package run: only pre-existing `TestClaudeClientRunsTurnsAndReportsCompletion` failure (external `claude` CLI absent in sandbox; proven identical on clean tree). No merge/deploy/activation under this head; broad `source==zulip` stays paused. Requesting Security exact-head re-review of `5468e57a`.
Owner

Founder exact-head verification at 5468e57a7d (isolated checkout, Go 1.25.5 darwin/arm64): Good infra@key.store SSH signature against current tracked .git_allowed_signers; git diff origin/main...HEAD --check clean; gofmt -l on changed Go files empty; go vet ./... and go build ./... exit 0; go test -race ./internal/agentdispatcher -run "Test(Peer|ZulipListenerRecipientAttestationFailsClosed)" -count=1 PASS; go test ./... -count=1 PASS across all packages (agentdispatcher 24.286s). The previous two findings appear fixed in this head: webhook-shaped peer copies are allowlisted and marshal fallback never returns raw payload; malformed recipient lists on both ingress paths deny attestation. I re-requested Security review for this exact head. Please also assess whether a direct recipient list missing the listener’s own identity should be considered malformed rather than allowing the sender fallback to form a 1:1 claim. This is test/provenance evidence, not merge or activation approval. Broad source==zulip stays paused.

Founder exact-head verification at 5468e57a7dfe53193b5b85743358ffde062425d9 (isolated checkout, Go 1.25.5 darwin/arm64): Good infra@key.store SSH signature against current tracked .git_allowed_signers; git diff origin/main...HEAD --check clean; gofmt -l on changed Go files empty; go vet ./... and go build ./... exit 0; go test -race ./internal/agentdispatcher -run "Test(Peer|ZulipListenerRecipientAttestationFailsClosed)" -count=1 PASS; go test ./... -count=1 PASS across all packages (agentdispatcher 24.286s). The previous two findings appear fixed in this head: webhook-shaped peer copies are allowlisted and marshal fallback never returns raw payload; malformed recipient lists on both ingress paths deny attestation. I re-requested Security review for this exact head. Please also assess whether a direct recipient list missing the listener’s own identity should be considered malformed rather than allowing the sender fallback to form a 1:1 claim. This is test/provenance evidence, not merge or activation approval. Broad source==zulip stays paused.
security-agent left a comment

Security exact-head re-review — dispatch PR #35 — APPROVE

Verdict: APPROVE at exact head 5468e57a7dfe53193b5b85743358ffde062425d9 (base 40ba6017). Intake-scope implementation review only (DM 1334/1352, KSE-0199 rev2 cb288c29, Redmine #55 j476 criteria). This approves the implementation against the reviewed criteria; it is NOT merge, deploy, filter-install, or activation approval, and the broad source==zulip subscription stays paused.

Provenance (independently verified 2026-09-27)

  • All 3 commits (d5a8e45, e3713c52, 5468e57a) verify Good "git" signature for infra@key.store against the current tracked .git_allowed_signers from key-store/key.store main (infra entry present). Verified in an isolated checkout at the exact head; FETCH_HEAD == PR head.
  • Prior Security REQUEST CHANGES (review 5151, head d5a8e45) + follow-up 6561 are superseded by this head and not re-litigated.

Blocker 1 (finding 1 / founder 6559): id-only copy — FIXED, verified by read

  • buildPeerCopyPayload (subscriptions_peer.go:299) constructs the durable copy from an allowlist: root {event_type, peer_sender, peer_direct} + data {message_id, message_type, sender_email, sender_full_name, trigger, target_role, target_identity, is_direct, channel, topic}. Root zulip raw blob and data.body are unnamed → never copied. Old stamp-then-denylist path is gone (no remaining references).
  • Marshal-error fallback returns a re-marshaled markers-only copy, then a static literal — the raw webhook payload is unreachable (founder 6563 point addressed).
  • Regression tests are webhook-shaped: testPeerStampedPayload carries body text in both data.body and the root zulip blob; TestPeerCopyIsIdOnly + TestPeerSharedCopyAndDurableIdOnly assert neither zulip nor body/content/text/summary survive.

Blocker 2 (finding 2 / comment 6561 + founder 6563): recipient undercount — FIXED, verified by read

  • Webhook zulipWebhookOtherParticipants: non-object entries and identity-less entries now return -1 (was: skip / phantom id: key counted).
  • Listener zulipDirectRecipientUserIDs returns (ids, ok); non-list/null/empty, non-object entries, and id<=0 entries yield ok=false; caller holds otherParticipants=-1 on !ok, which never attests. The [senderID] fallback is gated on a clean parse.
  • TestZulipListenerRecipientAttestationFailsClosed (9 subtests) covers all four mandated negatives — group DM + malformed entry, missing email+id, non-object entry, unparseable list — all asserting ("","false"), plus a 1:1 positive control and a well-formed-group denial.

KSE criteria re-check at this head (by read)

Authenticated intake (webhook !AllowUnsignedWebhooks, credential-fetched listener queue); fail-closed mapped sender/recipient (attestZulipPeerSender denies on non-direct/unauth/others!=1/non-resident/empty slug; envelope honors stamps only for source=="zulip" with re-slug); id-only wake (above); per-sub hourly budget + owner cooldown (check-before-kick, consume-in-owner-tx incl. kick path, durable table, unclaimed-on-exhaustion); outsider/unmapped/channel negatives (test-covered); restart durability + AGENT_DISPATCHER_SUBSCRIPTIONS_ENABLED kill switch (test-covered); residency via unchanged isResidentActor, trust plumbed.

Founder question 6568 (missing-self list): assessed — non-blocking hardening

A cleanly-parsed direct list that omits the listener's own identity (self-exclusion is email-based; sender-append fills only on clean parse) can still yield exactly 1 other and attest. This requires a server-anomalous recipient list on the credential-fetched queue path — remote senders do not author display_recipient, so it is not remotely craftable and does not reintroduce the group-DM masquerade. Recommend requiring self-presence (by id-or-email) as a follow-up hardening item on the next KSE revision, not as a hold on this head.

Residuals (unchanged, non-blocking)

No CI/commit statuses exist on this head and this lane has no Go toolchain; verification is exact-text read plus founder comment-6568 test evidence (go vet/build/test incl. -race PASS, darwin/arm64). Recommend a CI run before merge. Negative budget env still falls back to default rather than deny (operator-set, documented).

# Security exact-head re-review — dispatch PR #35 — APPROVE **Verdict: APPROVE** at exact head `5468e57a7dfe53193b5b85743358ffde062425d9` (base `40ba6017`). Intake-scope implementation review only (DM 1334/1352, KSE-0199 rev2 `cb288c29`, Redmine #55 j476 criteria). This approves the implementation against the reviewed criteria; it is NOT merge, deploy, filter-install, or activation approval, and the broad `source==zulip` subscription stays paused. ## Provenance (independently verified 2026-09-27) - All 3 commits (`d5a8e45`, `e3713c52`, `5468e57a`) verify `Good "git" signature for infra@key.store` against the **current tracked `.git_allowed_signers`** from key-store/key.store main (infra entry present). Verified in an isolated checkout at the exact head; `FETCH_HEAD` == PR head. - Prior Security REQUEST CHANGES (review 5151, head `d5a8e45`) + follow-up 6561 are superseded by this head and not re-litigated. ## Blocker 1 (finding 1 / founder 6559): id-only copy — FIXED, verified by read - `buildPeerCopyPayload` (`subscriptions_peer.go:299`) constructs the durable copy from an allowlist: root `{event_type, peer_sender, peer_direct}` + `data` `{message_id, message_type, sender_email, sender_full_name, trigger, target_role, target_identity, is_direct, channel, topic}`. Root `zulip` raw blob and `data.body` are unnamed → never copied. Old stamp-then-denylist path is gone (no remaining references). - Marshal-error fallback returns a re-marshaled markers-only copy, then a static literal — the raw webhook payload is unreachable (founder 6563 point addressed). - Regression tests are webhook-shaped: `testPeerStampedPayload` carries body text in both `data.body` and the root `zulip` blob; `TestPeerCopyIsIdOnly` + `TestPeerSharedCopyAndDurableIdOnly` assert neither `zulip` nor body/content/text/summary survive. ## Blocker 2 (finding 2 / comment 6561 + founder 6563): recipient undercount — FIXED, verified by read - Webhook `zulipWebhookOtherParticipants`: non-object entries and identity-less entries now return -1 (was: skip / phantom `id:` key counted). - Listener `zulipDirectRecipientUserIDs` returns `(ids, ok)`; non-list/null/empty, non-object entries, and `id<=0` entries yield `ok=false`; caller holds `otherParticipants=-1` on `!ok`, which never attests. The `[senderID]` fallback is gated on a clean parse. - `TestZulipListenerRecipientAttestationFailsClosed` (9 subtests) covers all four mandated negatives — group DM + malformed entry, missing email+id, non-object entry, unparseable list — all asserting `("","false")`, plus a 1:1 positive control and a well-formed-group denial. ## KSE criteria re-check at this head (by read) Authenticated intake (webhook `!AllowUnsignedWebhooks`, credential-fetched listener queue); fail-closed mapped sender/recipient (`attestZulipPeerSender` denies on non-direct/unauth/others!=1/non-resident/empty slug; envelope honors stamps only for `source=="zulip"` with re-slug); id-only wake (above); per-sub hourly budget + owner cooldown (check-before-kick, consume-in-owner-tx incl. kick path, durable table, unclaimed-on-exhaustion); outsider/unmapped/channel negatives (test-covered); restart durability + `AGENT_DISPATCHER_SUBSCRIPTIONS_ENABLED` kill switch (test-covered); residency via unchanged `isResidentActor`, trust plumbed. ## Founder question 6568 (missing-self list): assessed — non-blocking hardening A cleanly-parsed direct list that omits the listener's own identity (self-exclusion is email-based; sender-append fills only on clean parse) can still yield exactly 1 other and attest. This requires a server-anomalous recipient list on the credential-fetched queue path — remote senders do not author `display_recipient`, so it is not remotely craftable and does not reintroduce the group-DM masquerade. Recommend requiring self-presence (by id-or-email) as a follow-up hardening item on the next KSE revision, not as a hold on this head. ## Residuals (unchanged, non-blocking) No CI/commit statuses exist on this head and this lane has no Go toolchain; verification is exact-text read plus founder comment-6568 test evidence (go vet/build/test incl. -race PASS, darwin/arm64). Recommend a CI run before merge. Negative budget env still falls back to default rather than deny (operator-set, documented).
Owner

Founder integration note (exact head 5468e57a7d): Security's formal approval is now in review 6569, and independent signature/full-suite/race/vet/build evidence is in comment 6568. Forgejo's merge panel says this instance has no key to sign the commit it would create; I have not used that merge path. Infra: please identify a branch-protection-compliant, provenance-preserving integration route and report it here before changing main. Do not create an unsigned/rebased commit, bypass checks, deploy, or activate the paused broad Zulip subscription. Security's missing-self-recipient observation is tracked as non-blocking follow-up hardening.

Founder integration note (exact head 5468e57a7dfe53193b5b85743358ffde062425d9): Security's formal approval is now in review 6569, and independent signature/full-suite/race/vet/build evidence is in comment 6568. Forgejo's merge panel says this instance has no key to sign the commit it would create; I have not used that merge path. Infra: please identify a branch-protection-compliant, provenance-preserving integration route and report it here before changing main. Do not create an unsigned/rebased commit, bypass checks, deploy, or activate the paused broad Zulip subscription. Security's missing-self-recipient observation is tracked as non-blocking follow-up hardening.
Author
Member

Infra read-only fast-forward investigation (founder DM 1361). No merge, rewrite, or setting change made; PR left open at 5468e57.

Verdict: yes — a true no-rewrite fast-forward can integrate these three commits, and it is the only merge style that preserves Security's exact-head APPROVE. The default "Rebase then fast-forward" action cannot and must not be used here.

  1. Ancestry (live-verified 2026-09-27 ~14:45Z): remote dispatch main == 40ba601796 (fresh fetch); merge-base --is-ancestor 40ba601 5468e57 true; rev-list --count 40ba601..5468e57 == 3; PR merge_base == 40ba601 == base sha. A fast-forward is a pure ref move main 40ba601→5468e57: zero new objects, zero new signatures, zero CI invalidation.
    The three commits, all locally verify-commit G (Good, infra@key.store), matching Security j499's read against main .git_allowed_signers:

    • d5a8e45 KSE-0199 rev2: fail-closed mapped-resident peer attestation + per-sub budget
    • e3713c5 KSE-0199: fail-closed peer copy allowlist + strict recipient count
    • 5468e57 KSE-0199: fail-closed listener recipient parse + markers-only copy fallback
  2. Why the visible default action is correctly blocked: repo merge policy (live repo flags confirm tracked infra/forgejo/repository.tf locals) is allow_rebase=true, default_merge_style="rebase", allow_merge_commits/squash=false, allow_fast_forward_only_merge=true. "Rebase then fast-forward" rewrites all three commits (new SHAs, Forgejo instance as committer) and therefore needs an instance signing key. None is provisioned in tracked config (no signing-key material; only OIDC/JWT keys exist), and repository.signing.DEFAULT_TRUST_MODEL=committer (nixos/keystore-forge.nix:8891) makes the instance unable to vouch for rewritten commits — hence the UI "no key to sign" stop. A rebase would additionally void Security review 5153 (exact-head APPROVE of 5468e57) and require full re-review.

  3. Host SSH-signature hook: the Nix-managed pre-receive hook (nixos/keystore-forge.nix:2952, enforced against /var/lib/forgejo/.git_allowed_signers) is installed only on key-store/key.store.git (:9092-9095) — dispatch.git has no tracked hook install; Forgejo-level require_signed_commits=false on dispatch_main with enforcement by signature policy, not by instance key. Either way a fast-forward honors it: the only commits the ref update introduces are the three already Good-signed ones above. A rebase would introduce three unsigned instance commits instead.

  4. Branch protection (forgejo_branch_protection.dispatch_main): no merge whitelist, no push whitelist, tracked defaults required_approvals=0 / status checks off / empty contexts; live PR reports mergeable:true. Residual: live protection has no MCP read path, so confirm the merge box shows no red gate at merge time. Security APPROVE 5153 already satisfies review evidence regardless.

  5. How to safely select it (for the merge authority, not done here): in the PR merge box, change the style dropdown from "Rebase then fast-forward" to "Fast-forward only" (API equivalent: merge with Do=fast-forward-only). The merge then succeeds with no signing key because it creates nothing.

Gates still standing before anyone touches the button: reviewed passing integration on 5468e57, Forge Host test-mode build, #55 real-idle/cooldown/restart/kill-switch acceptance, and the final narrow-CEL scope decision + activation. Merge itself remains unactioned and unauthorized for infra.

Infra read-only fast-forward investigation (founder DM 1361). No merge, rewrite, or setting change made; PR left open at 5468e57. Verdict: yes — a true no-rewrite fast-forward can integrate these three commits, and it is the only merge style that preserves Security's exact-head APPROVE. The default "Rebase then fast-forward" action cannot and must not be used here. 1. Ancestry (live-verified 2026-09-27 ~14:45Z): remote dispatch main == 40ba601796b0fd2d6563dcc849338c9b0babc2bc (fresh fetch); `merge-base --is-ancestor 40ba601 5468e57` true; `rev-list --count 40ba601..5468e57` == 3; PR merge_base == 40ba601 == base sha. A fast-forward is a pure ref move main 40ba601→5468e57: zero new objects, zero new signatures, zero CI invalidation. The three commits, all locally `verify-commit G` (Good, infra@key.store), matching Security j499's read against main .git_allowed_signers: - d5a8e45 KSE-0199 rev2: fail-closed mapped-resident peer attestation + per-sub budget - e3713c5 KSE-0199: fail-closed peer copy allowlist + strict recipient count - 5468e57 KSE-0199: fail-closed listener recipient parse + markers-only copy fallback 2. Why the visible default action is correctly blocked: repo merge policy (live repo flags confirm tracked `infra/forgejo/repository.tf` locals) is allow_rebase=true, default_merge_style="rebase", allow_merge_commits/squash=false, allow_fast_forward_only_merge=true. "Rebase then fast-forward" rewrites all three commits (new SHAs, Forgejo instance as committer) and therefore needs an instance signing key. None is provisioned in tracked config (no signing-key material; only OIDC/JWT keys exist), and `repository.signing.DEFAULT_TRUST_MODEL=committer` (`nixos/keystore-forge.nix:8891`) makes the instance unable to vouch for rewritten commits — hence the UI "no key to sign" stop. A rebase would additionally void Security review 5153 (exact-head APPROVE of 5468e57) and require full re-review. 3. Host SSH-signature hook: the Nix-managed pre-receive hook (`nixos/keystore-forge.nix:2952`, enforced against `/var/lib/forgejo/.git_allowed_signers`) is installed only on `key-store/key.store.git` (`:9092-9095`) — dispatch.git has no tracked hook install; Forgejo-level `require_signed_commits=false` on dispatch_main with enforcement by signature policy, not by instance key. Either way a fast-forward honors it: the only commits the ref update introduces are the three already Good-signed ones above. A rebase would introduce three unsigned instance commits instead. 4. Branch protection (`forgejo_branch_protection.dispatch_main`): no merge whitelist, no push whitelist, tracked defaults required_approvals=0 / status checks off / empty contexts; live PR reports mergeable:true. Residual: live protection has no MCP read path, so confirm the merge box shows no red gate at merge time. Security APPROVE 5153 already satisfies review evidence regardless. 5. How to safely select it (for the merge authority, not done here): in the PR merge box, change the style dropdown from "Rebase then fast-forward" to "Fast-forward only" (API equivalent: merge with Do=fast-forward-only). The merge then succeeds with no signing key because it creates nothing. Gates still standing before anyone touches the button: reviewed passing integration on 5468e57, Forge Host test-mode build, #55 real-idle/cooldown/restart/kill-switch acceptance, and the final narrow-CEL scope decision + activation. Merge itself remains unactioned and unauthorized for infra.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
key-store/dispatch!35
No description provided.