Repository navigation
fix(mcp): fail closed when protected session probes raise - #12442
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
7 similar comments
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS New probe contract tells host overrides to return Watch
[DESIGN-REVIEWED] dac4ee1 |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The identity "fix" ships no behavior change — base already fails closed at Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: FIX — keep sandboxed MCP children bootable when
[FIRST-PRINCIPLES-REVIEWED] dac4ee1 |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNothing blocks; one advisory — the soft-fail's own notice is suppressed by the logger level this function set 40 lines earlier. FINDING — src/kiro_crew/cli.py:1128 — with [OPUS-REVIEWED] dac4ee1 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/member_memory_auth.py:153 -- |
ef4cef8 to
0b1af92
Compare
0b1af92 to
9ad9cc3
Compare
9ad9cc3 to
ec9d22a
Compare
620dc98 to
3edf79b
Compare
3edf79b to
bc8b9c1
Compare
bc8b9c1 to
df8db0a
Compare
…nding fence Under Seatbelt a sandboxed MCP child (Pi `spawn_run` -> `kirocrew mcp-core`) could not start: opening the `gateway.log` rotating file handler raised OSError and aborted CLI logging setup before the MCP handshake. Soft-fail that open for CONSOLE-backed setups only. `basicConfig` has already installed a console handler there, so the warning lands somewhere a human reads and the child still boots. A DETACHED process keeps failing loudly: it deliberately skips `basicConfig` (a console echo would double-write into the log stderr already points at), so swallowing the error would boot a long-lived gateway with no persistent log and no destination for the warning saying so. Bearer/JWT console redaction is installed before the early return, which the normal call site would otherwise skip. The member-binding probe keeps its fail-closed classification. An earlier revision of this change caught `PermissionError` from `protected_member_session_for_pid` in `mcp_caller.py` / `mcp_shared.py` and treated it as absence so token/env identity could win. That reopens the fallthrough the binding exists to fence: `KIROCREW_SESSION_KEY`, the signed token and the pid file are all writable by the same uid, and `chmod` needs only ownership, so a fenced process could make its OWN binding record unreadable and come back as the ambient session with that session's tool-policy exclusions and `spawn_run` identity. A core resolver cannot tell that induced EPERM from a sandbox deny; a host override can. So the distinction is documented as a contract on `protected_member_session_for_pid` instead: overrides return `None` for a binding that is missing OR unreadable, and `""` only for an explicitly invalid/revoked record. Tests pin both halves: a raising probe refuses across PermissionError, OSError and RuntimeError rather than reaching the env key; an EPERM probe is `resolution_failed` and asks the gateway for no policy; a detached unopenable `gateway.log` raises while a foreground one does not. Drop test/test_cli_logging.py from the black baseline now that it is clean.
df8db0a to
dac4ee1
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-09-28): readiness passed, required checks green on dac4ee1, no blocking review threads, security posture unchanged. Approving and merging.
Problem / Motivation
Goal: Keep sandboxed MCP children bootable when persistent logging is unavailable without weakening protected session identity fences.
A sandboxed
kirocrew mcp-corechild can be denied access togateway.log, which currently aborts CLI logging setup before the MCP handshake. The original report also showed a protected member binding probe raisingPermissionError, but treating that exception as absence would let a same-uid process make its own binding unreadable and fall through to an ambient session key.Why it matters
Sandboxed MCP children need to start with console logging when the host denies the persistent log path. At the same time, protected member sessions must not inherit the ambient session identity, tool exclusions, or spawn authority by inducing a binding-read failure.
Not a goal
Noneas no protected identity or""as an explicit refusal.Nonefor the unreadable binding.What changed (motivation → approach → change)
OSErrorwhile openinggateway.log, warns through the already-installed console handler, preserves long-lived-command redaction, and continues without a rotating file handler.CallerContext.from_env()now maps every exception fromprotected_member_session_for_pid()to the existing blank protected identity refusal instead of falling through to token, environment, or pid-file identity.Noneonly when they can classify a missing or expected unreadable binding, and to reserve""for an explicit invalid or revoked record.resolution_failedclass.Backwards compatibility
Compatible: successful protected probes, explicit blank refusals, normal persistent logging, and detached gateway behavior retain their existing contracts. Host kits that intentionally classify an expected sandbox denial can return
Nonethrough the documented seam.Tests
test_unwritable_gateway_log_soft_failsproves a console-backed MCP child can continue when the log file open is denied.test_unwritable_gateway_log_still_redacts_for_long_livedproves the soft-fail path still installs log redaction.test_unwritable_gateway_log_fails_loudlyproves a detached gateway does not start without persistent logging.test_a_raising_protected_probe_refuses_and_never_reaches_the_env_keycoversPermissionError,OSError, and unexpected exceptions and proves none can reach the ambient key.test_an_eperm_probe_is_resolution_failed_not_env_fallthroughproves tool-policy resolution refuses an unreadable protected binding without consulting ambient-session policy.test/test_cli_logging.pyandtest/test_session_token_consumer_identity.py.Manual verification
N/A for the fail-closed core behavior because the focused tests exercise both identity consumers and both logging topologies. End-to-end recovery of the original Seatbelt symptom remains a host-kit verification and requires that kit to return
Nonefor its expected unreadable binding.Screenshots / video
N/A, no user-visible frontend surface changes.
Related Issues
Related to #12380. This PR does not change the Pi MCP bridge wiring covered there.
Pattern harvest
Rule candidate: agents-md
Pattern: an exception from a protected identity probe is refusal, not absence; only the authority that can classify an expected sandbox denial may return the absence sentinel.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A, repository placeholder retained.