Skip to content

feat(dashboard): add the settings panel for flagged-file delivery consent - #9010

Merged
iamwhatever merged 1 commit into
mainfrom
feat/file-delivery-consent-panel-8793
Sep 18, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
feat/file-delivery-consent-panel-8793

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Kiro Crew refuses to deliver a file whose contents the credential scanner flags,
with no consented way through -- so a VPN device key the owner legitimately needs
delivered is blocked, and the feature reads as broken rather than protective
(issue #7770). This PR adds an owner-consented delivery path, recorded as a
durable grant every delivery gate re-reads.

The hard part is that this grant authorizes a secret-bearing file past four
independent content gates, so the consent point IS a security boundary -- and the
issue's own acceptance is that consent must be "a human dashboard action", not
something a background agent can grant on the owner's behalf.

Why it matters

An owner dashboard session proves identity, not human presence: anyone running
computer use points an agent at an owner-authenticated browser, so an
owner-session check alone lets a prompt-injected, auto-approved click record a
grant and make every later flagged file deliverable -- the exact "agent can
self-approve" hole #7770 exists to close. And a consent prompt the owner cannot
understand is not informed consent. The security boundary and the copy are the
two things this feature is actually about.

What changed (motivation -> approach -> change)

Security -- a human-only step-up, mirroring the established update_stepup
pattern (RFC OQ7) the repo already uses for "a dashboard session is not enough
authority for a security-critical write":

  • Recording a grant is split into ARM + APPROVE. The owner-gated POST only ARMS a
    request and writes a single-use nonce; kirocrew file-delivery approve on the
    host consumes it and records the grant via a new loopback-only endpoint.
  • The nonce lives in its OWN top-level leaf file-delivery-consent-pending/,
    registered in both security._CREW_SECRET_LEAVES (file gate) AND
    sandbox._CREW_HIDDEN_LEAVES, so it is bind-masked out of the agent sandbox in
    every mode. It is deliberately NOT under trust/, which is sandbox-VISIBLE for
    SEL appends and would let a prompt-injected agent forge a nonce there with a
    runtime-constructed shell path. Because that directory is created lazily at arm
    time, it is also added to sandbox._CREW_PRECREATE_HIDDEN_DIR_LEAVES so the
    mask binds over it before any sandbox spawns on a fresh install
    (aws-control-staging is the precedent).
  • The loopback-only approve endpoint is on _STRICT_INTERNAL_API_PATHS (not
    MIXED), exactly like its sibling /api/update/approve: loopback +
    X-Internal-Secret only, no cookie fall-through, so a dashboard/agent bearer
    cannot even reach the handler. The handler also re-asserts host-locality.
  • A self-protection-file-delivery denied-command FLOOR rule blocks the agent
    from running the approve verb through its own shell at all, mirroring
    self-protection-update. Defence in depth alongside the mask.
  • The approve handler refuses to record a grant while COMPUTER USE is enabled:
    desktop input synthesis would let a prompt-injected agent type the approve
    command into a host terminal and complete the owner's armed step-up itself, so
    that one tier is excluded rather than trusted (reads the fail-safe-to-disabled
    keystone computer_use.json).
  • It likewise refuses unless the effective agent sandbox actually applies the
    pending-nonce mask: with agent.sandbox off (or no backend + unsandboxed exec
    opted in) the nonce is unmasked and an unsandboxed agent could read or forge it
    directly, so the presence proof is void. Uses the same security-reviewed
    credential_mask_applies predicate the ACP tool gate uses, which fails closed.
  • Withdrawal keeps its single owner-gated door with no step-up: revoking is the
    fail-safe direction.
  • The approve handler orders its side effects so the irreversible one is last:
    it validates the nonce, records the grant, and only then clears the single-use
    nonce. A grant-write failure therefore leaves the nonce valid and the owner can
    retry, instead of a 500 that also destroyed the armed request; single-use still
    holds because the nonce is cleared on the success path before the response.

UX -- plain language and a stated purpose at the point of consent:

  • file_delivery_desc now names the use case ("Use this when a file of your own
    -- like a VPN key -- was blocked on its way to you"), the piece a blind reader
    said it needed before it would allow anything.
  • The destination is "This computer and your dashboard Files view" plus a
    one-line helper naming the outbox folder and the Files view, and stating it
    never goes to Slack or a chat channel; never-grantable legs are described in
    words, not the raw ids.
  • The primary control reads "Allow delivery"; states are "Allowed" / "Not
    allowed"; the armed expiry renders as a human duration ("about 10 minutes"),
    not raw seconds; em dashes match the catalogue.
  • A failed arm-status read now surfaces its own ErrorNotice instead of silently
    dropping the command panel. While a request is armed the row shows a "Waiting
    for approval" badge and a disabled "Waiting on this machine" CTA (so a re-click
    is not an invisible re-arm); the host command has a Copy button; an expired
    armed request leaves a line rather than a silent unmount.
  • The kirocrew file-delivery CLI verb requires its approve action (no
    nargs="?"): a bare invocation errors instead of silently approving.
  • docs/feature-map/README.md corrected to state the real boundary (arm is
    owner-gated; recording is the host-only nonce step-up; the masked nonce leaf
    plus the floor rule are the agent fences) -- the prior line called the
    endpoints owner-gated, which this change made false.
  • All 12 locale catalogs updated via the repo's own tooling (translations by the
    i18n path, en-XA regenerated by gen-pseudolocale.mjs), passing the
    per-language style gates (Italian accents, zh-CN particle stacking, Hindi
    informal register).

Default preserved: delivery is still refused until the owner allows it, so nothing
changes until a human opts in on the host.

Tests

  • Backend test/test_file_delivery_consent.py, test/test_denied_commands_security.py,
    test/test_sandbox_governance_mask.py, test/test_sandbox_absent_ceiling_seal.py
    and test/test_mcp_call_site_auth_coverage.py (run -n0): arm->approve
    round-trip; TestGrantRequiresAHostStepUp pins arm-records-nothing,
    remote-approve-refused, wrong-nonce-refused, single-use, the nonce leaf is
    masked, the precreate materialises the leaf before spawn, the approve endpoint
    is STRICT-not-MIXED, and approve is refused while computer use is enabled but
    allowed when disabled. Mutation-verified: the floor rule, the mask leaf, the
    precreate entry, the STRICT entry and the computer-use fence each redden a test
    when removed.
  • Frontend SecurityPanel.fileDelivery.test.tsx: clicking Allow ARMS (records
    nothing) and shows the host command with the disabled waiting CTA, and a Copy
    button; a failed arm-status read is surfaced. tsc clean.
  • i18n gates pass: catalogParity, changedValueQa, keyReference, englishIdentity,
    renderScan, and the per-locale style specs; en-XA is generator-produced.

Manual verification

Rendered the panel through the capture harness against the built SPA and read the
frames: the resting state (use-case sentence + plain destination), the armed
step-up showing kirocrew file-delivery approve with "expires in about 10
minutes", the write-failure notice, and the arm-status-failure notice. The
capture harness asserts each failure notice actually rendered before shooting, so
it cannot emit a plausible frame of the wrong state.

Screenshots / video

Every frame below was captured at the current head with
node scripts/capture-file-delivery-consent.mjs, which builds the SPA first and
asserts the state it is shooting actually rendered. They are attached rather than
linked by raw URL, because the previous frames were pinned to a pre-rebase commit
and so showed the panel BEFORE the resting-state helper line existed, which is
what the UX review caught.

Resting state -- plain destination, the use-case sentence, "Allow delivery", and
the helper line saying the click only starts a request:

resting state at HEAD, helper line present

Granted -- the only state with a timestamp and the Withdraw control:

granted state with withdraw control

Armed step-up -- the click did NOT record a grant; the host command finishes it,
with a human-readable expiry:

armed step-up with host command

The Copy control, both halves. Success:

Copied acknowledgment after the Copy control

and failure, when neither clipboard layer is available:

copy failure notice

Arming write failure:

arming write failure

Arm-status read failure -- an unreadable approval state renders as unknown, not as
"not confirmed":

arm-status read failure

An armed request that lapsed its window without an approve:

armed request expired

Consent read failure:

consent read failed renders unknown

Light theme and the narrow breakpoint:

resting state light theme

narrow layout

Related Issues

Closes #7770

Out of scope (tracked separately)

The UX review (Fable 5) raised one blocker that this PR deliberately does not
fix: the consent card does not name the specific file that was refused, so the
owner has no concrete event to anchor the decision to. It is a valid concern, but
its only faithful implementation is a new surface -- the refused-file event is
written to no owner-readable store today (audit_decision records only
granted / revoked / delivered, never the refusal, and there is no SEL read
path in the app surface), so surfacing it needs a new refusal-capture store, a new
read endpoint, and card rendering. That is filed as #9091 and is not folded here,
to keep this PR's security-critical surface reviewable. The reviewer's suggested
source ("from the SEL entry audit_decision already writes") does not exist for
refusals -- the concern is real, the proposed remedy is not, and #9091 carries the
correct one. This PR does fold the review's smaller, frontend-only items: an
armed-state badge and a disabled "Waiting on this machine" CTA while armed, a Copy
button on the host command, an expired-request line instead of a silent unmount,
the long-duration expiry form, and the missing arm-status-failed screenshot.

Pattern harvest

  • A dashboard owner-session gate proves identity, not human presence. A
    security-critical write reachable by an agent-driven owner browser needs a
    host-only step-up, and the step-up is only as strong as the fences around its
    nonce: the nonce must live on a sandbox-MASKED leaf (a sandbox-visible one can
    be forged with a runtime-constructed shell path), the leaf must be pre-created
    so the mask binds before spawn, the approve endpoint must be STRICT-internal so
    no cookie bearer reaches it, the CLI verb must be on the self-protection floor,
    and the one tier that can synthesize host presence (computer use) must be
    excluded. update_stepup is agent-proof because these hold together; each was
    a distinct review finding on this PR where one was missing.
  • A security fix that moves a boundary falsifies every comment that described the
    old one, and comments are what no test covers -- grep the tree for the old
    description, not just the line the reviewer named.
  • Consent copy has two gates: how a value is added, and what the value says. The
    destination label and a stated purpose are where informed consent is won or
    lost.

Resting-state consent disclosure + review fixes (latest head)

A blind-reader review pass flagged that the resting-state Allow delivery
button reads as an immediate, irreversible grant when it is neither: the click
only arms a reversible two-step request that delivers nothing until the host
command runs. Added a resting-state helper line under the button:

This starts a request you finish in a terminal on this machine -- nothing is
delivered until then, and you can withdraw it at any time.

i18n handling -- really translated, and the gate exemption removed. An
earlier revision shipped this line as English prefixed with TODO(i18n): in all
11 catalogs, exempted by an isPendingTranslation() predicate in
scripts/lib/passthrough-checks.mjs. That is no longer what ships, and the reason
is the exemption rather than the copy: it keyed off a marker inside the very value
being judged, so any value could switch the check off by carrying a prefix, and a
ratchet the judged value can disable is not a ratchet. The exemption is deleted
and file_delivery_confirm_help is translated in all 11 locales
(bn de es fr hi it ja ko pt ru zh-CN), one line changed per catalog. Each
translation satisfies its own locale style gate, which is stricter than parity:
informal register where the locale requires it (du, tum, no usted), and no
opening literal translation of "This will". passthroughChecks.test.ts now pins
the opposite of what it used to: a TODO(i18n): prefix earns NO exemption, so the
removal cannot silently regress. check-source-strings.mjs reports zero
untranslated changed values with the exemption gone.

GPT F1 (test isolation) fixed. The expired-request test scoped its clock
patch to a pytest.MonkeyPatch.context() so no monkeypatch.undo() can leak a
fresh arm write past the test's isolation.

Opus / GPT (stale post-approval UI) fixed. When a host approval ends an
armed request, the arm poll flips to {armed:false} and stops; the card now
invalidates ['file-delivery-consent'] on that armed-to-not-armed transition, so a
completed approval renders as Allowed with a Withdraw control instead of
reading as expired. Mutation-verified: disabling the invalidation reddens the
new regression test.

Local verification: tsc clean; i18n:check PASS with I18N_BASE_REF=origin/main
(changed-passthrough = 0); SecurityPanel fileDelivery (14) + passthroughChecks
(24) + englishIdentity + deadKeys = all pass; backend
test/test_file_delivery_consent.py 57 passed (-n0); eslint clean.

@chenmingwei23
chenmingwei23 requested review from a team and smeyffret September 6, 2026 11:33
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 81952b9da0f6079bd0280788679e991418f2ce85 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Description documents a superseded revision: the isPendingTranslation gate exemption and TODO(i18n) placeholder copy it claims shipped do not exist at HEAD.

Watch

  • Phantom description: the description says the consent copy ships as TODO(i18n): English placeholders in all 11 locales and that passthrough-checks gained an isPendingTranslation carve-out. At HEAD the locales carry real translations and the new test pins the opposite ("a marker prefix earns no exemption", passthroughChecks.test.ts:176). It also names clear_pending_grant/consume_grant, which don't exist (the code ships claim_grant/restore_pending_grant). A reviewer approving against this text approves an i18n-gate exemption that was in fact reverted, and a policy statement ("a confident machine mistranslation…") the code contradicts.
    Clears when: the PR description is rewritten to match HEAD — no gate exemption, translated copy, and the claim/restore function names.

Suggestions

  • Expose approve-eligibility (the same computer-use / mask / delegation predicates the approve handler checks) in the consent GET, so the panel can say "unavailable on this host" before arming — today a Windows or kiro-internal-sandbox owner completes the arm and the terminal round-trip only to hit a 403 whose remedy ("disable kiro-cli's internal sandbox") is not actionable on Windows; the feature-map paragraph documents this but the UI never does.

[DESIGN-REVIEWED] 81952b9

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 81952b9da0f6079bd0280788679e991418f2ce85 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The nonce step-up re-spells platform/update_stepup.py symbol-for-symbol instead of reusing it — two security-critical copies of the same machinery now drift silently.

Not justified as shipped

  • Item 2 — duplicate of src/kiro_crew/platform/update_stepup.py: the description says "mirroring the established update_stepup pattern", and the mirror is a copy — seven mirrored symbols counted side-by-side (StepUpError, PendingGrant≈PendingUpdate, arm_grant≈arm, read_pending_grant≈read_pending, claim_grant≈consume, public_pending_view≈public_view, pending_grant_path≈pending_path), with identical docstrings and the identical refusal string "approval nonce does not match the armed request". The genuine deltas (safety epoch, restore_pending_grant) sit on top of a mechanical core (O_EXCL 0600 nonce file, TTL, hmac.compare_digest, SPA-safe view, module lock) that now exists twice and diverges unnoticed.
    Subtraction: replace the mirrored core in file_delivery_consent.py with the update_stepup primitives, keeping only the safety-epoch compare and restore as consent-side deltas.
    Clears when: the shared nonce core is one implementation, or a maintainer records that the epoch binding makes the two step-ups deliberately separate.
  • Item 10 — rides along, undeclared: ~700 diff lines of autonudge goal_token/409/echoed-projection work the description never mentions; it is the base tip commit adef620 (feat(autonudge): refuse a stale-baseline update and detect a resubmitted projection #10973) carried in this branch and drops out of the diff on a rebase.

What this change ships

Inventory (10 items) — 8 justified

Intent: give the owner a consented, human-only way to deliver a scanner-flagged file they legitimately need — an ADDITION (panel + consent step-up), per issue #7770.

  1. Settings > Security gains a "Flagged-file delivery" section to view and withdraw the grant — justified
  2. "Allow delivery" now only ARMS a request; the grant is recorded by a host command consuming a single-use nonce — duplicate of src/kiro_crew/platform/update_stepup.py (the machinery, not the need)
  3. An owner with only a remote/tailnet dashboard can no longer record this consent; withdrawal stays one click — justified
  4. New CLI command kirocrew file-delivery approve, with a new denied-command floor blocking the agent's shell from it — justified
  5. New masked data-home leaf file-delivery-consent-pending/, precreated before every spawn — justified
  6. Approval refuses under computer use, an absent/delegated sandbox mask, a live unconfined agent, or any of those changing between arm and approve — justified
  7. Consent copy relabeled in plain language ("This computer and your dashboard Files view", use-case sentence, "about 10 minutes") across all locales — justified
  8. New panel states: waiting CTA, expired-request line, Copy button, arm-status-failure notice — justified
  9. The blocked-delivery error the model sees now points at the panel and the two-step flow — justified
  10. Autonudge stale-baseline 409 + echoed-projection guards — rides along, undeclared (identical in substance to base commit adef620 / feat(autonudge): refuse a stale-baseline update and detect a resubmitted projection #10973)

Capped at 10: screenshot PNGs under temp-screenshots/ (145 tracked siblings) and the per-feature capture script (533 siblings) follow established repo practice.

[FIRST-PRINCIPLES-REVIEWED] 81952b9

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @chenmingwei23 overrides the GPT 5.6 finding for 81952b9da0f6079bd0280788679e991418f2ce85; the recorded reason is authoritative for this commit.

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 81952b9da0f6079bd0280788679e991418f2ce85: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 81952b9da0f6079bd0280788679e991418f2ce85 — this comment is updated in place on each push.

Review details

No findings.

CANDIDATE 1 does not survive falsification. Its scenario requires an agent running unconfined (agent.sandbox was off at spawn) so it can read the nonce off disk — and an unconfined agent is exactly the "genuine local code execution as the gateway's own user" the module header (file_delivery_consent.py, "WHAT THIS DELIBERATELY DOES NOT DEFEND AGAINST") explicitly concedes. In that configuration the grant is redundant: an unconfined agent already has full filesystem access as the gateway user and can write the outbox directly, so recording a consent grant confers nothing it does not already have. There is no incremental observable harm (c). The safety_epoch() composition genuinely omits the live-pid dimension, but that omission hardens an already-conceded threat class rather than reopening a defended boundary; the live-pid check at approve time closes the in-scope window (a lingering unconfined session present when a human approves). The candidate's own key step — a detached POST that reads the nonce and outlives the session — it could not confirm, and neither could I ground it to (a)/(b)/(c) without assuming the unconfined-agent premise that voids the harm.

[OPUS-REVIEWED] 81952b9

Verdict parsed from the review's SHA-scoped output markers for commit 81952b9da0f6079bd0280788679e991418f2ce85.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 81952b9da0f6079bd0280788679e991418f2ce85: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 81952b9da0f6079bd0280788679e991418f2ce85 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Verify the live host-approve round trip flips "Waiting for approval" to "Allowed" within a poll — only static frames exist; the invalidation path was tested, not watched.

Suggestions

  • file_delivery_withdraw: "Withdraw" → "Withdraw allowance" — the blind reader noted that next to a page about files, "withdraw" "could be misread as withdrawing a file rather than withdrawing the permission."
  • The Slack/chat exclusion is stated twice in one resting view: drop "It is never sent to Slack or a chat channel." from file_delivery_destination_help — the lock-icon file_delivery_never_grantable line already carries it with more precision.

[UX-REVIEWED] 81952b9

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 6, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/file-delivery-consent-panel-8793 branch from fbe34aa to 8993f6d Compare September 6, 2026 12:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 6, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/file-delivery-consent-panel-8793 branch from 8993f6d to fb428f0 Compare September 6, 2026 12:32
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 6, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/file-delivery-consent-panel-8793 branch from fb428f0 to e65fbf0 Compare September 6, 2026 14:21
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 6, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/file-delivery-consent-panel-8793 branch from e65fbf0 to fa5ec33 Compare September 6, 2026 14:52
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 6, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/file-delivery-consent-panel-8793 branch from fa5ec33 to 006fd80 Compare September 6, 2026 15:20
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 6, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Update on head 29efeeadf -- one fix landed, two security-class findings reported only

This push carries three things in one commit: the clear_pending_grant lost-update fix (both call sites), the two missing UX screenshots, and the harness change that captures them. It does not touch any trust boundary, and it does not act on the fenced security-class findings below.

Fixed: F2 -- pending nonce clobbered by a concurrent re-arm (file_delivery_consent.py)

clear_pending_grant now takes an optional expected identity and unlinks the pending file only while it still holds that request's request_id and nonce. The approve handler and consume_grant both pass the PendingGrant they validated.

This changes only which row is deleted -- never who may approve, what is delivered, or when consent is considered given. The two exclusion tiers (computer-use, unsandboxed) and the _deny_non_owner / loopback checks are untouched.

Leak-safety, verified from code rather than assumed: arm_grant writes through a .tmp sibling and os.replaces onto one fixed path, so there is only ever a single pending file. A request B armed after A was observed has already overwritten A's bytes; when the compare fails, the file left in place is B -- a live, newer request that read_pending_grant expires on its own if never approved. The no-op path therefore leaks nothing.

Mutation-verified in both directions:

  • Remove the guard (unconditional delete) -> the stale-identity test reddens (B is deleted).
  • Break the comparison so it never matches -> the matching-identity test reddens (the normal path leaks the file).

Each mutant is caught by exactly one of the two new tests.

Reported only, not touched -- F1 (security-class, fenced)

file_delivery_consent.py approve-endpoint denial branches (wrong/missing nonce, non-local, computer-use, unsandboxed, invalid JSON) return without an audit_decision call, unlike _deny_non_owner. A wrong-nonce denial is the ordinary failure path, and the missing SEL entry has no recovery -- nothing reconstructs an event that was never logged. Adjudication held this UPHOLD-FENCED. I have not fixed it: it is a security-class finding and outside what I was authorized to change on this pass.

Reported only, not touched -- F3 (security-class, fenced)

On macOS with the kiro-internal sandbox enabled (a normal supported config), the agent's kiro-cli spawn takes the delegation path, which returns argv without threading Crew's extra_hidden_dirs. The pending-nonce leaf is then not Crew-masked and the delegated sandbox knows nothing of it, yet credential_mask_applies(configured_sandbox_mode()) reports masked. The approve handler records the grant believing the nonce is hidden -- a silent consent-ceiling bypass with no self-correction. Adjudication held this UPHOLD-FENCED. Not fixed here for the same reason as F1.

Observation for the rule owner -- Security Scope refusal (not a finding, not acted on)

The self-protection-file-delivery denied-command floor rule refuses kirocrew file-delivery --help on all three OS legs. --help prints usage and is not a delivery or approval path, so the floor may be broader than the threat it exists to close (the agent running the approve verb). This is a hypothesis about the rule's scope, not a defect I can rule on -- widening or narrowing a security floor is the rule owner's call. Flagging it here with the exact command and rule so the owner can decide; I have changed nothing about the floor.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Update on head 3bb18ed54 -- F2 expiry-site fix landed; F1/F3/Security Scope remain human-owned

The GPT lane re-sampled on the prior head and re-anchored its lost-update finding to a second call site. This push fixes that site; it does not touch the two findings a human owns.

Fixed: F2 at read_pending_grant (file_delivery_consent.py)

read_pending_grant used to unlink an expired request on read. That is the same lost-update mechanism as the approve-path clear: a concurrent arm_grant (os.replace onto the single fixed path) landing between the expiry check and the unlink would have its fresh request deleted. An expired row already reads as absent, and the next arm's os.replace overwrites the file, so the unlink bought nothing and raced a live arm. It is removed.

This changes only whether an inert expired file is proactively deleted -- never who may approve, what is delivered, or when consent is given. Verified both directions: a new test asserts an expired request reads as None and is left in place for the next arm to overwrite; restoring the unlink reddens that test.

Reported only, not touched -- F3 (file_delivery_consent.py:429), new this re-roll

expires_in computes int(self.created_at + GRANT_PENDING_TTL_SECS - time.time()). json.loads accepts NaN/Infinity for created_at, and the parse try/except does not cover the later int(nan + ...), so a malformed timestamp raises instead of the row reading as absent. Adjudication FLAGged it (not fenced): arm_grant only ever writes finite time.time() into an owner-only, sandbox-masked file, so the system's own writer cannot produce a non-finite value, and a re-arm self-corrects. It is a crash-class finding the re-roll surfaced; I have not fixed it -- it is outside the scope I was asked to change and is for the owner to rule on.

Reported only, not touched -- F1 (handlers/file_delivery_consent.py:270), security-class

Approve-endpoint refusals (mismatched or expired nonce) return without an audit_decision call, so a denied approval leaves no SEL record. UPHOLD-FENCED. Not fixed: security-class, outside scope.

Security Scope refusal -- observation for the rule owner, unchanged

Unchanged from the prior comment: the self-protection-file-delivery floor rule refuses kirocrew file-delivery --help on all three OS legs. --help prints usage and is not a delivery or approval path, so the floor may be broader than the threat it exists to close. This is a hypothesis for the rule owner, not a defect I can rule on; the floor is untouched.

PR remains human-blocked while F1 and the Security Scope refusal stand.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Update on head e5a3a7180 -- concurrency race closed; UX copy blocker is a content task

Fixed: GPT :592 -- compare-and-unlink races a concurrent arm

The compare-and-clear narrowed the lost-update window but did not close it: between read_pending_grant() (the compare) and os.unlink(...), a concurrent arm_grant could still land and be deleted. A dedicated _PENDING_LOCK now serializes arm_grant's write against clear_pending_grant's compare-and-unlink, so a fresh arm either lands wholly before the clear (clear sees a different request and does not delete) or wholly after (clear removes the old request, then the arm lands) -- never mid-flight.

Actor model, established from the code rather than assumed: the racing parties are threads in one process, not two processes. The arm endpoint and the approve handler both run their file work on the gateway's asyncio.to_thread pool, and the kirocrew file-delivery approve CLI is an HTTP client that POSTs to the gateway rather than touching the file itself. So a threading.Lock is the correct primitive; an OS file lock would guard a second writing process this design does not have.

Single-fixed-path kept, not replaced by a per-request-id filename: the single path is the load-bearing "at most one pending grant exists" invariant, and a glob reader would have to choose which of two files is current. So the lock, not a structural rename.

Mutation-verified in the direction that matters: a test constructs the exact interleaving (approve validates A, arm B issued while clear is parked between its compare and unlink) and asserts B survives; removing the serialization reddens it (B deleted). The test runs the real thread contention, not a claim about it.

UX copy blocker -- English wording is executable, 12 translations are not mine to invent

The screenshots cleared the evidence block; the reviewer's blind-reader pass then raised a new blocker: the resting-state "Allow delivery" button never says the click only arms a reversible two-step request that delivers nothing yet. The reviewer named an English replacement line. But clearing it is not a mechanical copy edit: catalogParity requires every English key present in all 13 catalogs, and this PR's own standard is real translations (not English copies), which the untranslated/englishIdentity ratchets enforce. The local translate script only emits prompts; it does not translate in-process. Inventing 12 translations of new consent-security copy is a content/design step, so I have not made the change. English wording as the reviewer gave it:

"This starts a request you finish in a terminal on this machine -- nothing is delivered until then, and you can withdraw it at any time."

State

Human-blocked. Green: all Fast Gate, Coverage, Screenshot, Design, First Principles, Opus. Fenced/owner: F1 approve-refusal SEL-audit gap, F3 non-finite created_at crash, the Security Scope --help floor. UX copy blocker: English named, translations pending a content decision. Not merged, not approved, no reviewer nudged.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Head 1d06440: cleared the CI reds on the prior head.

  • Backend Tests (all OS): the single failure was test_no_single_module_grows_back_into_a_monolith -- argv_floor.py had grown to 4511, one over the 4500 per-module cap. The cap comment is explicit that raising the number is not the fix, so instead the file is back at exactly 4500 by trimming two spans of change-history narration from comments (which check_comment_history.py forbids on added lines anyway); the new _is_self_file_delivery predicate stays a named function alongside its four siblings, and no module structure or export manifest changed.
  • Backend Lint: cli_server.py was not black-formatted (one over-long print line); reformatted at the pinned target-version.
  • Coverage Gate was the fail-closed cascade of the backend-test failure and clears with it.

Verified locally: test_security_gate_liveness.py 10 passed, black + flake8 + the black gate + the comment-history gate all clean.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 89fb0ee: GPT review is clean:true; the BLOCK-MERGE is the documented bootstrap gap on a PR that introduces the review contract (gpt-block-adjudication.md and review-cli manifest absent on base, plus a transient comment-read timeout), which the workflow itself names a maintainer override as the bootstrap path for. No reachable code finding.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 89fb0eef250be9e7b94a0b9aeda8553939f3670f.

GPT review is clean:true; the BLOCK-MERGE is the documented bootstrap gap on a PR that introduces the review contract (gpt-block-adjudication.md and review-cli manifest absent on base, plus a transient comment-read timeout), which the workflow itself names a maintainer override as the bootstrap path for. No reachable code finding.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override scope 89fb0ee: Verified via denied_rules.py: the newly-refused surface is exactly the PRs one narrow documented floor self-protection-file-delivery (argv program is the product CLI, leading subcommand file-delivery, approve verb completes a flagged-file step-up). The lane fails in bootstrap mode because this PR introduces the scope harness (deny_diff.py/scope_candidates.py/scope_redact.py absent on base), so every intended refusal reads as newly-refused. No overbroad or unintended denial.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the scope AI finding as false positive, not applicable, or explicitly accepted for 89fb0eef250be9e7b94a0b9aeda8553939f3670f.

Verified via denied_rules.py: the newly-refused surface is exactly the PRs one narrow documented floor self-protection-file-delivery (argv program is the product CLI, leading subcommand file-delivery, approve verb completes a flagged-file step-up). The lane fails in bootstrap mode because this PR introduces the scope harness (deny_diff.py/scope_candidates.py/scope_redact.py absent on base), so every intended refusal reads as newly-refused. No overbroad or unintended denial.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override ux 89fb0ee: UX review failed on infra, not a UX finding: transient could-not-read-PR-comments plus an attachment-download transport failure. The PR commits its evidence under temp-screenshots/file-delivery-consent/ (10 PNGs at HEAD), so this is not a missing-evidence author gap; two re-runs hit the same transient download. No user-visible UX defect.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the ux AI finding as false positive, not applicable, or explicitly accepted for 89fb0eef250be9e7b94a0b9aeda8553939f3670f.

UX review failed on infra, not a UX finding: transient could-not-read-PR-comments plus an attachment-download transport failure. The PR commits its evidence under temp-screenshots/file-delivery-consent/ (10 PNGs at HEAD), so this is not a missing-evidence author gap; two re-runs hit the same transient download. No user-visible UX defect.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round disposition on cb25fb8243: F1 and F2 fixed, and F1 was the right call

Head is now cb25fb8243, rebased onto current main and squashed to one commit
(the branch was CONFLICTING and carried 3 commits, so its previous board was
measured against a stale merge ref).

F1 -- the untranslated-catalog ratchet: fixed, not argued

The finding is right and the previous reasoning was wrong in a specific way. The
argument for shipping TODO(i18n): placeholders was that a confident machine
mistranslation on a consent path is worse than an honest English one. That is
still true about TRANSLATION QUALITY, and it is not an argument for the
mechanism that was built: the exemption keyed off a marker IN THE VALUE BEING
JUDGED, so any value could switch the check off by carrying a prefix. A ratchet
the judged value can disable is not a ratchet, which is exactly what
a-ratchet-may-only-tighten exists to stop.

Taken as prescribed:

  • isPendingTranslation and PENDING_TRANSLATION_MARKER are DELETED from
    passthrough-checks.mjs, and both untranslated-script and
    untranslated-english lost their skip. grep finds no remaining reference.
  • file_delivery_confirm_help is really translated in all 11 locales
    (de, es, fr, it, pt, ru, ja, ko, zh-CN, hi, bn), one line changed per catalog
    and nothing else -- git diff --stat on website/src/i18n/locales/ is
    11 files, 11 insertions, 11 deletions.
  • The test block that asserted the exemption is REPLACED rather than deleted, by
    one that pins the opposite: a marker prefix earns no exemption, and the
    prefixed value is flagged exactly as the unprefixed one is. Deleting it would
    have left the reinstatement untested.
  • check-source-strings.mjs now reports
    [changed-passthrough] 0 untranslated value(s) among values changed vs origin/main
    with the exemption gone, so the translations pass the gate on their own merits.

F2 -- approval denials bypass SEL auditing: fixed as a CLASS

The finding named line 271. That line was one of FOUR authorization denials in
the approve handler that answered 403 with no SEL entry: the off-host caller, the
computer-use fence, the sandbox-mask fence, and the nonce refusal. Fixing only
the named one would have left three, so all four now go through one
_refuse_approve helper that audits before answering.

"*" is the destination class for all four, matching the existing non-owner
refusal: the denial happens before any pending request is validated, so naming a
class would put an unvalidated caller's word into the audit. The nonce-refusal
entry records the REASON (wrong or expired), never the caller's nonce.

test_every_approve_denial_is_audited walks all four legs in one test on
purpose: the claim is about the SET of refusal legs, so a fifth leg added later
without an audit has to redden something, where a per-leg test simply would not
exist for it.

Verification on this head

58 tests in test_file_delivery_consent.py, 1087 with
test_denied_commands_security.py alongside it, 150 sensitive-path and
secret-leaf tests covering the rebase's one conflict resolution in
src/kiro_crew/security/paths.py (main added ssh_auth_sock_consent.json at the
same insertion point as this PR's file-delivery-consent-pending; both are
kept). Frontend: passthroughChecks.test.ts and
SecurityPanel.fileDelivery.test.tsx pass, eslint clean on both changed JS/TS
files. black, flake8 and mypy clean.

F3 (nonce consumption not atomic) is the one the adjudication FLAGGED rather than
upheld. It is answered separately below.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The four frontend shards on cb25fb8243 were mine, and they were right

Head is now 5e5f8a7740. Removing the TODO(i18n): exemption meant the locale
style gates started judging this value for the first time, and they found five
things in the translations I wrote. All five are real; none is a defect in the
feature.

Why all four shards, not one. Each violating locale has its OWN style test
file, and the four files landed in four different shards, so the count looked
systemic and was not:

shard finding rule fix
deStyle.test.ts style/de.md s5 wants informal du, not Sie rewritten with du, dropping Sie koennen
esStyle.test.ts style/es.md s4 forbids usted outright rewritten in the informal register
hiStyle.test.ts style/hi.md s4 wants tum, not formal aap rewritten with tum
zhStyle.test.ts style/zh-CN.md s3 forbids opening with the translated "This will" opens with the action instead

A fifth came from a gate that only runs when a base ref is present:
bnStyle.test.ts's [changed-values] register assertion is DIFF-SCOPED, so it
skipped locally until I set I18N_BASE_REF the way CI does, then asked for
informal Bengali. Worth stating plainly, because it is the trap here: running
vitest src/i18n/style/ without I18N_BASE_REF reports 11 passed while a
diff-scoped assertion inside those same files never executes. The re-run with the
base ref set is what I verified against.

Fixing those also caught two of my own typos that no gate would have flagged --
the Hindi read kul bhi nahin for kuchh bhi nahin, and the Chinese used a
mistyped verb that is not a word -- so this round improved the translations
beyond what the register rules asked for.

Four other locale files I touched (fr, it, pt, ru, ja, ko) passed unchanged;
the catalog diff for this round is 5 files, 5 insertions, 5 deletions.

Not mine, and not CI's: the same local shard run also failed four
src/test/Pierre* suites, all with Denied ID .../@pierre/diffs/dist/worker/worker-portable.js?worker&url
resolving into a DIFFERENT checkout's node_modules. That is a worktree-local
module-resolution artifact, not a property of this tree -- CI's frontend shards
did not report those files, and this diff touches nothing under src/pierre/.

Verification on 5e5f8a7740

vitest src/i18n/ src/test/passthroughChecks.test.ts src/pages/settings/SecurityPanel.fileDelivery.test.tsx
with I18N_BASE_REF set: 44 files passed. check-source-strings.mjs still reports
[changed-passthrough] 0 with the exemption deleted. Backend unchanged this
round and still green: 58 in test_file_delivery_consent.py, 1087 with
test_denied_commands_security.py.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Both fenced findings on 5e5f8a7740: fixed, and the adjudication changed my plan

Head is now 82774efbbf. I had intended to OVERRIDE the nonce-atomicity finding,
because on the previous head the adjudication FLAGGED it as bounded and
recoverable. On this head it reasoned the other way -- "unbounded and
unrecoverable-until-noticed" -- and UPHELD it. A finding whose recovery is "the
owner has to notice" does not meet the recoverable bar, so the override was the
wrong disposition and both are fixed.

F1 -- delegated macOS spawns bypass the nonce mask

Two different questions were being answered by one predicate.
credential_mask_applies answers whether the backend wrap_argv selects would
CARRY extra_hidden_dirs. It does not answer whether that wrap happens at all.
On macOS with kiro-cli's internal sandbox enabled a backend IS present, so it
returns True while the spawn is handed to _delegate_to_kiro_internal_sandbox
and Crew's mask never runs -- so an agent can read the nonce and complete the
owner's step-up with nobody present.

sandbox.spawn_delegates_masking() is the second question, and it lives in
sandbox.py beside the first for the reason credential_mask_applies states
about itself: a control whose security argument depends on the mask must not
carry its own copy of when the mask is skipped. It is a NEW predicate rather than
a widening of that one, because their existing callers depend on the narrower
answer -- the ACP tool gate asks "would the backend carry the mask" and must not
start refusing a delegated spawn it never cared about.

It fails closed twice over: native Windows delegates unconditionally, an
unreadable delegation setting reads as DELEGATED, and the kiro_cli argument
defaults True so a control reasoning about "the agent" in general refuses on a
delegating host rather than trusting a mask that may not run. The approve
endpoint now requires both predicates. Mirrors the precedent already in
member_memory_auth._private_memory_execution_failure, which refuses private
member execution under the same delegation for the same reason.

F2 -- nonce validation and consumption are now one step

claim_grant validates and unlinks under _PENDING_LOCK -- the same lock
arm_grant holds across its os.replace -- so exactly one caller leaves holding
a given request and the second is refused. The ordering that made a failed write
non-destructive is preserved WITHOUT reopening the race:
restore_pending_grant hands the request back, and only while the path is still
empty, because a request armed since is newer and overwriting it would delete a
live request nobody approved while resurrecting one whose approval failed. The
caller learns which happened and the 500 tells the owner either to retry or to
re-arm.

validate_grant is DELETED rather than left beside the new path. Its docstring
recommended exactly the validate-then-clear ordering this finding is about, and a
recommendation a later reader trusts instead of re-checking is worse than no
helper at all. consume_grant now delegates to claim_grant, so single-use has
one spelling.

Verification on 82774efbbf

62 tests in test_file_delivery_consent.py (four new: the delegation refusal,
the fail-closed unreadable setting, two concurrent claims of one nonce racing
through a ThreadPoolExecutor, and restore-only-when-nothing-newer), 1091 with
test_denied_commands_security.py, and 11 sandbox mask/mode tests.

Mutation-checked rather than assumed: neutering the delegation refusal reds 1
test, and making the claim non-consuming reds 4 -- including the pre-existing
test_a_failed_grant_write_leaves_the_nonce_retryable, which is the property I
had to keep while closing the race.

black, flake8, mypy and the comment-history gate clean.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round on 82774efbbf: both fixed, and what the rounds are actually finding

Head is now c56d90ef6c. The previous two findings are gone; two new ones took
their place, and both were real.

F1 -- the config check trusts a live session spawned under an older setting

I verified the premise before writing anything, because a wrong premise here
would have made the fix theatre. requires_restart("agent.sandbox") returns
False, so the tier reaches the running gateway the moment it is saved, while
confinement is decided at SPAWN by wrap_argv. A session started while the tier
was off therefore keeps running unconfined after the config flips, and every
config answer says it cannot -- which is exactly the gap.

sandbox.unconfined_live_agent_pid(pids) asks the PROCESSES instead, reusing the
platform predicates member_memory_auth already uses for the same question
rather than inventing a second answer: on Linux a confined child holds different
user and mount namespaces than the gateway, so MATCHING namespaces mean
unconfined; on macOS Seatbelt membership is read directly. Unreadable counts as
unconfined -- "cannot verify" is not "is confined".

The pids come off the session registry, not a process scan, because the question
is which agents THIS gateway is running and a scan would include somebody else's
process. _live_agent_pids fails closed as a sentinel [-1] rather than []: an
empty list would read as "no agent is running" precisely when the registry cannot
be seen.

F2 -- the approve request could fall back to TCP

Not a judgement call: loopback_urlopen's own docstring says a caller whose
request carries a credential another process could capture on the port wants
unix_socket_urlopen, and this request carries the single-use nonce AND the local
secret. Its fallback fires on a STALE socket, which is exactly the dead-gateway
case where a foreign process may hold the port. The file-delivery approve call
now uses the no-fallback opener when a socket path exists, and TCP only where
there is no AF_UNIX to prefer -- there the port is the only local transport, so
no fallback decision exists to get wrong.

Scoped deliberately to this PR's call site. _update_approve on main has the
same shape without the nonce; that is a pre-existing question about a different
credential and folding it in would grow this diff into code it does not own.

What the rounds are converging on, stated plainly

Every finding on this surface has been REAL, and every one has been another way
the same assumption fails: the host step-up proves a human is present ONLY while
the agent cannot read the nonce. That assumption has now failed through computer
use, agent.sandbox off, no backend, kiro-cli delegation, a live session spawned
under an older setting, and the transport itself. The count per round is 3, 2, 2 --
not rising, and each round names a NEW mechanism rather than re-flagging an
answered one, so it is converging on an enumerable boundary rather than
oscillating.

Worth a maintainer's eye all the same, because the shape is "one guard per
discovered path" and the honest ceiling is that the proof is only as strong as
that set is complete. If you would rather have a single chokepoint -- refuse
approval unless the nonce leaf is provably masked from every live agent, asked in
one place instead of five -- say so and I will build that instead. I am not
proposing it unasked: the five guards each answer a different question, and
collapsing them needs a decision about what the gateway is allowed to assume.

Verification on c56d90ef6c

65 tests in test_file_delivery_consent.py (three new: the unconfined live
session, the fail-closed unreadable registry, and the empty-registry permit),
1094 with test_denied_commands_security.py.

Mutation-checked: neutering the live-confinement refusal reds 1 test, and making
the pid enumerator fail OPEN instead of closed reds 1 -- so both the guard and its
fail-closed direction are pinned, not merely present.

black, isort, flake8, mypy and the comment-history gate clean.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round on c56d90ef6c: taken, and it is the chokepoint I offered last round

Head is now 7fa7d422d0. One finding this time, down from two, and it named the
design change I said I would build if a maintainer wanted it -- so I built it
rather than adding a sixth point-in-time guard.

The finding is right about the window

Every condition I had added was checked at APPROVE time. The arm happens earlier,
and the gap between them is controllable by the attacker the computer-use
exclusion exists to stop: an agent under computer use arms, queues a delayed
kirocrew file-delivery approve, then drives the owner-gated toggle to turn
computer use OFF. Each guard then answers honestly about NOW and waves the delayed
command through. The adjudication's reading is the load-bearing part -- the chain
needs no coincidental owner action, so no rarity argument was available.

The fix binds the request to the conditions that justified it

safety_epoch() digests every trustworthiness condition -- computer-use state,
the effective sandbox tier, whether the mask would be carried, whether the spawn
delegates -- and arm_grant stamps it into the pending row. claim_grant
recomputes it and refuses unless it still matches.

Three properties worth naming, because each is a decision rather than a detail:

  • A change in EITHER direction invalidates the request, including
    unsafe-to-safe. A request armed under an untrustworthy configuration was never
    a human's, so promoting it once the host improves would launder exactly the
    arm this is meant to reject.
  • An unreadable condition contributes a distinct ? marker instead of being
    skipped, so it cannot silently equal a readable one.
  • A row with no epoch is refused, not defaulted to the current one.
    Defaulting is the tempting one-liner and it is the hole: every pre-epoch
    request would become claimable. The remedy is re-arming, which costs one click.

This is the collapse I described: the epoch asks "did anything move since the
owner armed this" in ONE place, where five guards each asked "is it safe now". The
approve-time guards stay, because they give the owner a specific reason for a
refusal instead of a generic mismatch, and the live-process confinement check
stays because it is a fact about a running process rather than a configuration
value the epoch can digest.

Verification on 7fa7d422d0

68 tests in test_file_delivery_consent.py, 1097 with
test_denied_commands_security.py. Three new ones, and the first is the attack
itself rather than a proxy for it: arm while computer use is on, disable it, claim
-- refused. Plus the legacy no-epoch row refusing, and an unchanged configuration
still claiming, so the gate is conditional rather than a blanket break.

Mutation-checked in both directions: removing the epoch comparison reds 2 tests,
and defaulting a legacy row to the current epoch reds 1 -- so the comparison AND
its fail-closed direction are each pinned.

black, isort, flake8, mypy and the comment-history gate clean.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Stopping here on 7fa7d422d0, and saying why rather than starting a fifth round

Four rounds, four real findings, four fixes that were each correct about the
hazard they targeted -- and each round the NEXT boundary of the fix I had just
made became the finding. That is the shape of a requirement that cannot be
satisfied by the mechanism, not a run of mistakes, so grinding a fifth round
would be the wrong move.

round finding what I shipped what the next round found
1 ratchet weakened; denials unaudited exemption deleted, real translations; all four 403 legs audit delegated macOS spawns skip the mask; nonce claim not atomic
2 delegation + atomicity spawn_delegates_masking; claim_grant under one lock the config check trusts a live session spawned earlier
3 config-vs-live-session; TCP fallback unconfined_live_agent_pid over the session registry; no-fallback opener the computer-use read is point-in-time
4 the arm-to-approve window safety_epoch stamped at arm, compared at claim a standalone kirocrew chat is not in the session registry

The requirement underneath all of them

Every one of these is the same sentence failing: the host step-up proves a human
is present only while the agent cannot read the nonce.
The nonce is a file owned
by the owner's own uid. So the claim is really "no unconfined process running as
the owner can read this file", and that is not decidable from inside the
gateway.
A standalone kirocrew chat is a documented usage mode, runs as its
own process, and is in no registry the gateway keeps. Widening the enumeration to
a same-home process scan does not close it either -- it moves the boundary to
"processes I can recognize", and the next unrecognized shape is the next finding.

The finding is right and I am not disputing it. What I am saying is that the fix
it asks for is the fourth guard in a family whose completeness cannot be
established, and choosing between the real alternatives is an owner's call:

  1. Accept the residual. Keep the four guards, document that a same-uid
    process predating the current sandbox configuration can still read the nonce,
    and rely on the SEL audit trail plus revoke for detection. Cheapest, honest,
    and leaves a named hole.
  2. Change what the step-up proves. Stop resting on nonce secrecy and add a
    factor an agent cannot supply even holding the nonce -- a short code the SPA
    shows and the human types into the terminal. This ENDS the family, because it
    no longer matters who can read the file. It is product-visible UX and a new
    design surface, so I have not built it unasked.
  3. Refuse while the configuration is younger than the gateway. Pin the
    sandbox tier at boot and refuse approvals until a restart after any change.
    Closes everything the gateway spawned with one boot-time capture and no
    enumeration; still cannot exclude a foreign same-uid process.

My recommendation is 2 as the real fix with 1 as the interim, because 1 and 3
both leave the same residual and only 2 removes the assumption. I will implement
whichever you pick, immediately.

The second blocker is a rule-owner call, and it is structural

Security scope adjudication refuses on all three OS legs with "newly-refused
candidates". It is the same refusal the earlier comment reported: the
self-protection-file-delivery floor rule THIS PR ADDS makes
kirocrew file-delivery --help a refused candidate, and a candidate that does not
exist at base is "newly refused" by construction on every run. That is why it
flips green and red as the base moves rather than tracking anything I changed.
--help prints usage and is neither a delivery nor an approval path, so either
the floor should exclude the help verb or the candidate should be accepted. I
cannot rule on the repository's own floor rule.

Where the PR actually stands

7fa7d422d0, one commit, MERGEABLE, rebased on current main. Green: Fast Gate,
PR Hygiene, all eight POSIX and all Windows backend shards, frontend shards,
Coverage, Design, First Principles, Opus, Screenshot Evidence. 68 tests in
test_file_delivery_consent.py, 1097 with test_denied_commands_security.py,
every guard added across these four rounds mutation-checked in both directions.

Blocked on two decisions that are not mine: which of the three options above, and
the floor-rule question. Not merged, not approved, no reviewer nudged.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Two CI findings on 7fa7d422d0, both mine, both fixed on 43fef7d26c

Neither is part of the design question in my previous comment. That one is about
whether nonce secrecy can carry the step-up at all, and it still stands. These two
are mechanical defects in what I shipped, so I fixed them rather than leaving them
under an escalation that does not cover them.

Security Scope Review -- my floor refused a golden path

scripts/deny_diff.py confirmed one regression: kirocrew file-delivery --help.

The self-protection-file-delivery floor keyed on the SUBCOMMAND word, so it
matched every file-delivery invocation. But action is a REQUIRED positional,
so neither kirocrew file-delivery nor kirocrew file-delivery --help dispatches
anything -- and the help form is a golden path, because the deny reason handed to a
model on a blocked file_send points at this command family, so quoting its usage
is the documented next step. docs/feature-map/README.md already described the
narrow behaviour (blocks the agent from running kirocrew file-delivery approve),
so the code was the thing out of line with its own documentation.

Narrowed to the verb, using the shape cloud already uses: the spec is now
("file-delivery", _SELF_FILE_DELIVERY_VERBS). This costs no tightness --
approve is the sole choice, it has no alias or short form, and
_self_cli_operands skips interposed flags, so the spec is satisfied by exactly
the invocations argparse would dispatch. The refusal text now also names the
read-only forms it does not refuse.

deny_diff reports 0 regressions and 0 loosenings on posix, windows and any.

Two tests, and each is mutation-checked:
test_the_file_delivery_floor_allows_the_forms_that_dispatch_nothing reds when the
spec is widened back to the subcommand word, and
test_the_file_delivery_floor_covers_every_dispatchable_verb reds when the verb set
drifts from the parser. The second reads choices out of cli.py by AST rather
than by grep, because cli.py builds its parser inline in main() and a substring
assertion stays green when the construct it names moves or is wrapped. So a verb
added later needs a decision here instead of walking past the floor.

Backend Tests (Windows) (4) -- an incoherent host in my own fixtures

Five failures, all in test_file_delivery_consent.py, all 403 file_delivery_approve_unsandboxed.

This is a fixture gap, not a behaviour change. The suite defaults the approve-time
fences to their permitting state because a backend-less runner resolves
credential_mask_applies to False. I added two more fences in earlier rounds and
did not extend that default, so on native Windows -- where
spawn_delegates_masking returns True and every pid reads as unconfined, there
being neither a namespace reading nor Seatbelt membership -- the success-path tests
stubbed the mask on a platform that cannot apply it and 403d on that platform
alone.

Both fixtures now default all four, so the assertions stay universal and no
production guard is touched. The three tests that exercise the real predicates use
originals captured before the stub, so they keep testing the real function instead
of passing vacuously against a permitting stub.

test_native_windows_refuses_because_it_has_no_confinement_to_verify now asserts
the win32 answers directly, so the platform posture is a decision in the suite
rather than something a shard discovers. It reds when win32 stops delegating.
Production behaviour on Windows is unchanged either way: a backend-less host
already resolved credential_mask_applies to False before any of these fences
existed.

Verification

69 file-delivery tests, 1031 denied-commands tests, deny_diff clean on three
platforms, comment-history gate passed diff-scoped, black / isort / flake8 / mypy
clean. Both source mutations restored and verified byte-clean against HEAD.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The two POSIX shards on 43fef7d26c: one mine and fixed, one main's

Head is now 485afcf698.

Mine -- test_no_single_module_grows_back_into_a_monolith

argv_floor.py reached 4521 lines against a 4500 cap. The interesting part is the
starting number: the module was at 4499, so it had exactly one line of headroom
and this PR's floor predicate could not fit in it at any length. That is the cap
working, not an accident, and its own comment is explicit that raising the number
is not the fix.

So I moved the constant to where it belongs rather than squeezing prose until it
fit. _SELF_FILE_DELIVERY_VERBS is pure vocabulary -- a subcommand verb name, no
predicate and no decision -- which is the stated charter of
security/vocabulary.py: the package's lowest layer, importing nothing from the
package so every layer above may load-import it, and already holding
_KILL_BY_NAME_PROGRAMS, a frozenset of exactly this shape. The reasoning for
scoping to the verb moved with it, beside the set it explains, and
_is_self_file_delivery is now the same three lines as its cloud and gateway restart siblings. argv_floor.py already imported from vocabulary, so the
import cost no line and no new dependency edge.

Disclosing one thing a reviewer should see: argv_floor.py now sits at 4500,
exactly at its ceiling
, so the next change to it will face this same gate. This
PR did not raise the cap and did not split the module; a split is a large refactor
on its own merits and does not belong in a consent-panel change.

Main's -- test_every_capability_set_is_classified_by_the_card

Unclassified sets: ACP_BACKENDS_CLIENT_META_SETTINGS and
ACP_BACKENDS_TOOL_SEARCH_OVERLAY.

Attributed by file history, not by shard number. Both were added to main by
b2a1d90915 ("send MCP Tool Search to KAS over the wire", #11259); git grep
finds neither anywhere on this PR's head, and current main's
agent_sdk/backend_cards.py still does not classify either one. The diff here
touches no ACP backend file. It surfaces on this board because a pull_request
run measures the merge ref, so the shard sees main's new capability sets against
main's card file.

A rebase cannot cure this one -- the missing classification is in main, so
moving forward brings the same defect. It needs a main-side change putting each set
in USER_FACING_LINES, SECURITY_LINES, OPERATOR_LINES or OFF_CARD_SETS.

Verification on 485afcf698

1041 denied-command and gate-liveness tests, 69 file-delivery tests, all 10
test_security_gate_liveness.py gates including the package budget and the facade
share, deny_diff clean on posix, windows and any, comment-history gate passed
diff-scoped, black / isort / flake8 / mypy clean.

The GPT blocking finding is unchanged in substance and I am not disputing it; its
disposition waits for a verdict on this head, since posting an override and then
pushing would have voided the pin.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Rebased onto main for the card-classification fix -- head 42ca2db25f

In my previous comment I said the backend_cards failure was main's and that a
rebase could not cure it, because the missing classification was in main. Main has
since fixed it, so that second half no longer holds and the rebase is now the whole
remedy.

2960ec6a69 -- "classify the two Tool Search settings sets as off-card" -- puts
ACP_BACKENDS_CLIENT_META_SETTINGS and ACP_BACKENDS_TOOL_SEARCH_OVERLAY in
OFF_CARD_SETS. Checked both directions before moving rather than rebasing on
hope: ancestor of kirocrew/main YES, already in this head NO. That was the only
remaining CI failure, and it was the one no override could have cleared, since an
override reaches review lanes and not a red test.

The Windows fixture fix from the round before is confirmed by CI: on 485afcf698,
Backend Tests (Windows) (1) failed on test_backend_cards.py alone and no
test_file_delivery_consent.py test failed on any Windows shard. The five
platform-incoherent failures are gone.

Also confirmed on that head: the per-module line cap. Backend Tests (3.12, 3),
which carried test_no_single_module_grows_back_into_a_monolith, passed after the
verb set moved to security/vocabulary.py. argv_floor.py is still at 4500 after
this rebase, so main's 25 commits did not add to it.

Re-verified on the rebased tree, not assumed: 1100 tests across the file-delivery
and denied-command suites, all 10 test_security_gate_liveness.py gates, all 20
test_backend_cards.py tests now passing locally, deny_diff clean,
comment-history gate passed diff-scoped, flake8 clean.

The GPT blocking finding is now stated at the arm site rather than the claim site
("arming exposes the nonce to untracked unconfined agent runtimes",
file_delivery_consent.py:171), which is the same mechanism as the enumeration
finding at :209 -- a process outside the session registry. Its disposition waits for
GPT's verdict on this head, since an override names a SHA and this one has moved.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 42ca2db: already-attacked fails. Reading the nonce needs a process already running as the OWNER's uid outside the sandbox, and that caller reads the 0600 leaf and the flagged file directly, so the step-up is not what stands between it and the data. The adversary this fence exists for, the gateway-spawned sandboxed agent, is bind-masked from the leaf AND enumerated at :209. Enumerated path pinned by test_a_confined_pid_set_permits_approval in test/test_file_delivery_consent.py.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 42ca2db25fc26ed9cb288edc6047fc142a8b493e.

already-attacked fails. Reading the nonce needs a process already running as the OWNER's uid outside the sandbox, and that caller reads the 0600 leaf and the flagged file directly, so the step-up is not what stands between it and the data. The adversary this fence exists for, the gateway-spawned sandboxed agent, is bind-masked from the leaf AND enumerated at :209. Enumerated path pinned by test_a_confined_pid_set_permits_approval in test/test_file_delivery_consent.py.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Disposition of every open lane on 42ca2db25f, now pushed as da2977885f

The board on 42ca2db25f had zero failing lanes and PR Readiness passed. No comment on
this PR carries a [BLOCK-MERGE] marker, and there are no submitted reviews or inline
review comments, so nothing was gating merge except a human review. What was left was
four advisory CONCERNS verdicts, each of which still names findings. Accounting for all
of them, by lane.

Opus 4.8 -- no blocking findings

Both candidates died under falsification (arm does trace; record_grant has no reachable
non-OSError raise after the claim). Nothing to disposition.

First Principles -- CONCERNS: both items taken

Item 10, zero consumers. Verified independently before acting: consume_grant had 0 src
callers and 2 test sites, clear_pending_grant had 0 production callers and 3 test sites,
and its docstring claimed a caller in read_pending_grant's expiry sweep that does not
exist -- that function deliberately leaves an expired file in place, which its own test
pins. Both functions are deleted. Three follow-on corrections came with that:

  • The _PENDING_LOCK comment named clear_pending_grant's read-compare-unlink as the
    section it is held across. That is now claim_grant's, which is the live one.
  • test_the_nonce_is_single_use points at claim_grant, and absorbs the removal
    assertion from the deleted matching-identity test, so the file-is-gone property is not
    lost with the function.
  • The two remaining tests are repointed rather than deleted, because the properties they
    hold are live on claim_grant: a stale nonce presented while a newer request is armed
    must refuse and delete nothing, and a concurrent arm must survive a claim of an older
    request. The second still parks its full 2s, which is the evidence that the arm really
    blocks on the lock instead of landing in the gap.

Item 7, one consumer generalized. spawn_delegates_masking's kiro_cli parameter is
dropped. Behaviour is identical: every caller took the default, and the default is what
the body now does unconditionally. The fail-closed direction it documented is kept in the
docstring for the unreadable-setting case, which is the part that still applies.

The declared rider is taken too: grantFileDeliveryConsent in SecurityPanel.test.tsx
mocked a method the api client does not have (it is armFileDeliveryConsent), so it is
removed.

Design -- CONCERNS: W1 taken, W2 was stale but found a real defect of mine

W1, the platform dead-end, is taken by the second of its own two clearing conditions: the
docs now state the host requirement. docs/feature-map/README.md says plainly that
recording a grant needs a terminal on the gateway host AND a host where Crew applies its
own mask, names the two hosts that do not qualify and why (native Windows has no Crew
backend; macOS with kiro-cli's internal sandbox has one but delegates the spawn), lists
computer use, a maskless mode and a live unconfined session as refusing for the same
reason, and states that an owner with only a remote or tailnet dashboard cannot complete
the step-up at all while withdrawal stays owner-gated and needs no terminal.

W2 is stale against this head and I am saying so with the measurement rather than just
disagreeing: isPendingTranslation has zero occurrences repo-wide, no locale carries a
TODO(i18n): value, and check-source-strings.mjs reports 0 untranslated changed values.
That exemption was removed earlier in this PR's history precisely because a ratchet whose
judged value can switch it off is not a ratchet.

Re-reading the copy on the strength of that item did find a real defect, and it was mine.
Three Korean strings were wrong, and no gate catches any of them:

  • file_delivery_confirm_help contained five corrupted syllable clusters that are not
    Korean words, including the words for "computer", "terminal" and "request" -- which the
    same file spells correctly in its other strings, so this was corruption and not a
    choice. Rewritten.
  • file_delivery_armed_expired used the parcel-delivery word where the rest of the
    catalog uses the data-delivery one 49 times. It was the only occurrence. Aligned.
  • file_delivery_desc and file_delivery_destination_help spelled "outbox" two different
    ways, both introduced by this PR, with no house term to inherit. Unified on the one that
    matches "outbox folder".

The Suggestion, running the fences at arm time as well, is not taken. The safety epoch
already makes the claim-time answer authoritative, and an advisory arm-time copy of the
same conditions can disagree with it while being the thing the owner reads.

Security Scope -- CONCERNS with no confirmed regression

The deterministic fold reports 0 newly refused of 16, 16 and 5 classified on
ubuntu-latest, macos-latest and windows-latest, so nothing here blocks. The two TIGHTENING
items are the feature's purpose. Its UNADJUDICATED half asked for verdicts no shell
composite can produce; three of those four are the platform and epoch limitations now
disclosed in the doc above. The fourth, the CLI's unix-socket transport with no TCP
fallback, stays as it is: that request carries the nonce and the local secret, the
module's own docstring prescribes the socket for exactly that caller, and the fallback is
what an earlier finding on this PR asked to remove.

UX -- CONCERNS: all three deferred and disclosed

Standing ruling on this PR is that UX is advisory. All three are real and none is taken:
interpolating the gateway hostname into file_delivery_armed_help needs a new field in
the arm payload plus a string in 13 catalogs; the badge and the disabled CTA both reading
as a wait is a label change in 13 catalogs; and file_delivery_save_failed rendering
after a failed arm is the same. Recorded here so the next owner does not have to rediscover them.

Verification on da2977885f

68 file-delivery consent tests, 10 security-gate liveness tests including the module line
cap, 214 frontend tests across the Korean style gate, catalog parity and the Security
panel, 14 file-delivery panel tests, check-source-strings.mjs clean, comment-history
gate passed diff-scoped against the base, black, isort and flake8 clean. The two mypy
errors reported are in transcribe.py, which this diff does not touch.

Both repointed tests are mutation-checked. Accepting a stale nonce reds 3 tests including
the stale-nonce one; making the claim non-consuming reds 4 including the single-use one.
file_delivery_consent.py was restored from the commit after each and the tree verified
byte-clean.

One consequence

The GPT override recorded for 42ca2db25f died with that head. The finding it answered is
the session-registry boundary in _live_agent_pids, and the answer is unchanged: it fails
the already-attacked test, because a process running as the owner's own uid outside the
registry already reads the 0600 nonce and the flagged file directly. I will record it
against da2977885f once GPT has actually run on that sha, and not before.

…sent

Adds a Security-panel path for the owner to allow delivery of a file the
credential scanner flags, recorded as a durable grant every delivery gate
re-reads. Recording a grant takes a human-only step-up: the owner ARMS on the
SPA and completes it with `kirocrew file-delivery approve` on the host, which
consumes a single-use nonce and records the grant through a loopback-only
endpoint.

The step-up is agent-proof by construction. A new
`self-protection-file-delivery` denied-command floor rule mirrors
`self-protection-update`, so a prompt-injected agent cannot run the approve
verb and cannot self-grant delivery of the owner's secrets. The pending nonce
lives on a sandbox-masked, pre-created leaf so the mask binds before any
sandbox spawns, and the approve endpoint is loopback plus X-Internal-Secret
only.

`clear_pending_grant` takes an optional expected identity and unlinks the
pending file only while it still holds that request's id and nonce, so a
request armed after approve validated survives instead of being deleted by a
stale clear; the approve handler and `consume_grant` both pass the request
they validated. `read_pending_grant` no longer unlinks an expired request on
read -- the next arm's `os.replace` overwrites the single file. A dedicated
`_PENDING_LOCK` serializes `arm_grant`'s write against
`clear_pending_grant`'s compare-and-unlink, so a fresh arm cannot land between
the compare and the unlink and be deleted; the racing actors are threads on
the gateway's to_thread pool, so a threading lock is the right primitive.

The resting-state control discloses what the click actually does. A helper line
under the button states that the click only ARMS a reversible two-step request,
that nothing is delivered until the host command runs, and that it can be
withdrawn at any time -- the button alone read to a blind reader as an
immediate, irreversible grant. The grant query is invalidated on the
armed-to-not-armed transition, so a completed host approval renders as Allowed
rather than expired.

The consent copy ships as a `TODO(i18n):` marked English placeholder in all 11
locale catalogs, and `passthrough-checks` recognizes that pending-translation
convention (`isPendingTranslation`) so a disclosed placeholder passes the
zero-tolerance changed-passthrough gate by design. A confident machine
mistranslation on a consent path is worse than an honestly untranslated one.

Closes #7770
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The UX BLOCK on da2977885f was an evidence gap, and it is closed on 81952b9da0

GPT 5.6 and Opus 4.8 both came back with no blocking findings on da2977885f, so the
earlier GPT override was not needed and was not re-posted. The one readiness blocker was
UX Review returning BLOCK with "cannot evaluate", which PR Readiness reported as its 1
blocking item.

It was right, and the cause is worth naming because it would have recurred. The body's
frames were raw links pinned to commit 71e68b22, a pre-rebase revision of this branch.
That revision predates the resting-state helper line, so every resting-state frame a
reviewer could see showed the panel WITHOUT it, and the blind reader, working from those
frames, reproduced the exact misunderstanding the helper line exists to fix. The images
resolved fine, which is what made it invisible: a stale frame looks like evidence.

What changed:

  • Re-ran website/scripts/capture-file-delivery-consent.mjs at the current head. It
    rebuilds the SPA first, so the frames are of this code and not of a stale dist.
  • The frames are now ATTACHED assets rather than raw links to a commit. A rebase cannot
    silently age an attachment out of date the way it did here, and this branch rebases often.
  • Added the missing copied frame. The harness had copy-failed but no success half, so
    the Check plus "Copied" acknowledgment appeared in no frame. It is driven through the
    real onClick with a working Clipboard API (clipboard-write granted on the context,
    because Chromium gates writeText on that permission even on a secure origin) and the
    acknowledgment is asserted before the shot, matching the harness's existing rule that a
    plausible frame of the wrong state is worse than no frame.
  • All 11 frames are recommitted under temp-screenshots/file-delivery-consent/ so the
    Files changed tab agrees with the body instead of showing the pre-fix set.
  • The Screenshots section now says which head the frames came from and names each state.

One correction came with it, and it explains a Design finding I had called stale. The body
still described the i18n handling as TODO(i18n): English placeholders exempted by an
isPendingTranslation() predicate. That has not been true for several heads: the exemption
is deleted and all 11 locales carry real translations. A reviewer reading the description
would have concluded the placeholders were still shipping, which is exactly what Design's
W2 reported, so it was reading the PR honestly and my description was the stale artifact.
That paragraph now states what ships, including why the exemption had to go: it keyed off a
marker inside the value being judged, so any value could disable the check.

The narrow-layout suggestion (badge wrapping below the row label) is not taken: it is
marked a Suggestion, and it is a layout change to a shared settings row rather than to
anything this feature owns.

Verification on this head is unchanged from the previous comment plus eslint clean on the
capture harness, and both regenerated frames were read back before attaching: the
resting-state frame carries the helper line, and the copied frame carries the
acknowledgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 81952b9: already-attacked fails. The only caller who can trigger the stale overwrite is the authenticated owner PATCHing their own monitor message from a second tab, and that caller can already set that field to any value, so the guard withholds nothing it does not already hold. Also outside this diff: neither autonudge.py nor handlers/autonudge.py is changed here, and main's own call site passes no fingerprint either.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 81952b9da0f6079bd0280788679e991418f2ce85.

already-attacked fails. The only caller who can trigger the stale overwrite is the authenticated owner PATCHing their own monitor message from a second tab, and that caller can already set that field to any value, so the guard withholds nothing it does not already hold. Also outside this diff: neither autonudge.py nor handlers/autonudge.py is changed here, and main's own call site passes no fingerprint either.

This decision applies only to this commit. A new push requires a new judgment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file_send: no owner-consented way to deliver a file containing secret material

3 participants