Repository navigation
fix(agent-ipc): give no pickup to a broker-stub kirocrew-core element - #33192
Conversation
with_ipc_pickups matched the element name only, so when an operator stubs kirocrew-core through the gateway broker the pickup landed on the stub's environment. The stub never takes it out, so a same-uid shell in the session could read it from /proc/<pid>/environ and redeem it for a capability that reaches the internal routes. A pickup now goes only on an element that launches the server directly; an argv running the broker stub module, or one that cannot be read, gets none. The enforced-spawn e2e child also runs with -B so it writes no bytecode into the checkout it imports. Refs #31016, #33177
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix stops the pickup from being issued to the stub element at all. Before the agent socket existed, a brokered Notes
[DESIGN-REVIEWED] dc41a67 Description read[DESCRIPTION-READ] 56936e6a50a14a69cea70f7e4735ecab598ba3a7f75925be39e6e2e172f8dc06 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This fixes a pickup leak to broker stubs, and a test that fails on base proves it. The stub predicate is now the fourth private copy of one argv scan, which is a note and does not block. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: keep an enforced harness's same-uid processes from redeeming an agent-socket pickup read out of a broker stub's environment. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] dc41a67 Description read[DESCRIPTION-READ] 166c044882f1eab3ce225c4dc2f3961857637338de1eabc2d7e1e6f454c8fe2c That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving as part of a bulk merge pass over readiness: passed PRs.
…#33192) with_ipc_pickups matched the element name only, so when an operator stubs kirocrew-core through the gateway broker the pickup landed on the stub's environment. The stub never takes it out, so a same-uid shell in the session could read it from /proc/<pid>/environ and redeem it for a capability that reaches the internal routes. A pickup now goes only on an element that launches the server directly; an argv running the broker stub module, or one that cannot be read, gets none. The enforced-spawn e2e child also runs with -B so it writes no bytecode into the checkout it imports. Refs #31016, #33177 (cherry picked from commit b4a5645) Original author: Ray Xu (#33192).
…#33192) with_ipc_pickups matched the element name only, so when an operator stubs kirocrew-core through the gateway broker the pickup landed on the stub's environment. The stub never takes it out, so a same-uid shell in the session could read it from /proc/<pid>/environ and redeem it for a capability that reaches the internal routes. A pickup now goes only on an element that launches the server directly; an argv running the broker stub module, or one that cannot be read, gets none. The enforced-spawn e2e child also runs with -B so it writes no bytecode into the checkout it imports. Refs #31016, #33177 (cherry picked from commit b4a5645) Original author: Ray Xu (#33192).
Problem / Motivation
Goal: A broker-stub
kirocrew-corenever carries an agent-socket pickup, so no other process in an enforced-harness session can redeem one.acp/ipc_pickup.with_ipc_pickupsput a pickup on any array element namedkirocrew-core. When an operator stubskirocrew-corethrough the gateway broker (mcp_gateway.stub_servers; it is the managed stub leader) and the session runs on an enforced backend such as codex, the element is the broker stub, which never takes the pickup out of its environment and stays dumpable. A same-uid process in the session, such as the agent's shell, can read the pickup from/proc/<stub>/environ, redeem it at/api/ipc/redeem(its ancestry reaches the runtime root and no holder exists yet), and get a capability thattoken_authaccepts as internal auth. Found by Opus on the 0.12.1 backport #33177; the same code is onmain.Why it matters
The credential mask exists to keep an enforced harness's process tree off the internal routes. With a stubbed
kirocrew-core, the agent's shell could get that reach, skipping the PreToolUse gate andkirocrew-core's own tool exclusions.Not a goal
kirocrew-coreredeems.What changed (motivation → approach → change)
with_ipc_pickups(src/kiro_crew/acp/ipc_pickup.py) puts a pickup on akirocrew-coreelement only when_launches_server_directlysays it starts the server itself: an argv that runs-mmcp_gateway.STUB_MODULE(read throughexpand_stub_flags, the same reading the codex and opencode mirrors use), or one that cannot be read, gets none. A stubbedkirocrew-coretherefore gets no pickup, which is the behaviour it had before the agent socket.The enforced-spawn e2e child also runs with
-B, so importing this checkout writes no bytecode intosrc/.The docs spec
docs/system-specs/modules/security.md(agent socket, issuance) records the stub exclusion.Backwards compatibility
Compatible: a direct
kirocrew-coreelement gets its pickup exactly as before; only a broker-stub element of that name loses one it should not have had.Removes nothing.
Tests
Proof: PROVEN test/test_agent_ipc_client.py::test_a_broker_stub_for_kirocrew_core_gets_no_pickup[plain], test/test_agent_ipc_client.py::test_a_broker_stub_for_kirocrew_core_gets_no_pickup[enveloped], test/test_agent_ipc_client.py::test_a_broker_stub_for_kirocrew_core_gets_no_pickup[unreadable] (head dc41a67)
With the stub check removed, all three cases fail (
AssertionError: assert ('KIROCREW_IPC_PICKUP' not in ...); with it they pass.New
test_a_broker_stub_for_kirocrew_core_gets_no_pickup(test/test_agent_ipc_client.py), three cases: a plain stub argv, one carried in a--stub-flags-b64envelope, and an unreadable envelope. Each asserts no pickup on the element and nothing in the store. Determinism: 10 of 10 repeats, and all 26 tests in the file pass in a shuffled order.test/test_agent_ipc.py,test/test_agent_ipc_client.py,test/test_agent_ipc_enforced_spawn_e2e.py(the real masked spawn, not skipped here): 49 passed.The 19 test files that import a touched or calling module: 1615 passed, 2 failed.
test_harness_parity.py::test_is_kiro_cli_is_positivefails the same way on cleanmainon this host.test_agent_ipc_enforced_spawn_e2e.pyfailed once under that batch's load ("server exited before answering") and passed in 3 of 3 runs on its own.black, isort, flake8, mypy (
--platform linux), docs-lint, comment-history, brand, file-line-cap, harness-parity and the flake-pattern ratchet pass.Manual verification
N/A - the stub path is covered by the unit test; the direct path by the masked-spawn e2e.
Screenshots / video
N/A - no frontend file changes.
Related Issues
Refs #31016, #33177.
Sibling sweep
Siblings: none --
with_ipc_pickupsis the only place a pickup is put on an element; both array builders (runtime_session_setup._mirrored_session_mcp,client_mcp_array) call it.Pattern harvest
Rule candidate: a credential handed to a server by element
envgoes only to an element that launches that server directly, never to a broker stub registered under its name.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.