Skip to content

fix(agent-ipc): give no pickup to a broker-stub kirocrew-core element - #33192

Merged
chenmingwei23 merged 1 commit into
mainfrom
crew/slack/ipc-pickup-skip-stub
Nov 8, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
crew/slack/ipc-pickup-skip-stub

Conversation

@buluoray

@buluoray buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A broker-stub kirocrew-core never carries an agent-socket pickup, so no other process in an enforced-harness session can redeem one.

acp/ipc_pickup.with_ipc_pickups put a pickup on any array element named kirocrew-core. When an operator stubs kirocrew-core through 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 that token_auth accepts as internal auth. Found by Opus on the 0.12.1 backport #33177; the same code is on main.

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 and kirocrew-core's own tool exclusions.

Not a goal

  • Changing what a capability admits, or how a direct kirocrew-core redeems.
  • Giving a broker stub a way to redeem a pickup.

What changed (motivation → approach → change)

with_ipc_pickups (src/kiro_crew/acp/ipc_pickup.py) puts a pickup on a kirocrew-core element only when _launches_server_directly says it starts the server itself: an argv that runs -m mcp_gateway.STUB_MODULE (read through expand_stub_flags, the same reading the codex and opencode mirrors use), or one that cannot be read, gets none. A stubbed kirocrew-core therefore 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 into src/.

The docs spec docs/system-specs/modules/security.md (agent socket, issuance) records the stub exclusion.

Backwards compatibility

Compatible: a direct kirocrew-core element 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-b64 envelope, 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_positive fails the same way on clean main on this host. test_agent_ipc_enforced_spawn_e2e.py failed 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_pickups is 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 env goes only to an element that launches that server directly, never to a broker stub registered under its name.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 8, 2026 13:35
@buluoray
buluoray requested a review from Zedmor November 8, 2026 13:35
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision dc41a67d0d0e95ad5bae8226052350b3987331a4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of dc41a67d0d0e95ad5bae8226052350b3987331a4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 kirocrew-core got no pickup either.

Notes

  • A brokered kirocrew-core in an enforced session still has no agent-socket reach. If brokering ever needs that reach, it should come from a gateway-side handoff and never from the stub's env. Both points are out of scope here.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of dc41a67d0d0e95ad5bae8226052350b3987331a4 — 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 does not.

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

  • Item 1 — duplicate of providers/mirrors/codex.py::_stub_registered_servers: the -m STUB_MODULE scan through expand_stub_flags already appears at codex.py:113, opencode.py:129 and acp/mcp_mount_check.py:91. The hunk token == "-m" and i + 1 < len(argv) and argv[i + 1] == STUB_MODULE adds a fourth (grepped STUB_MODULE under src/). Subtraction: drop _launches_server_directly's own loop and test with one shared predicate. Keep the reading that an unreadable argv counts as not direct, because the mirrors' None means "not a stub" there.

What this change ships

Inventory (3 items) — 2 justified

Intent: 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.

  1. A kirocrew-core element that is a broker stub, or whose argv cannot be read, no longer gets a pickup or gateway pid — duplicate of providers/mirrors/codex.py::_stub_registered_servers
  2. The enforced-spawn e2e child runs with -B, so it writes no bytecode into src/ — rides along
  3. The security spec records the stub exclusion — justified

[FIRST-PRINCIPLES-REVIEWED] dc41a67

Description read

[DESCRIPTION-READ] 166c044882f1eab3ce225c4dc2f3961857637338de1eabc2d7e1e6f454c8fe2c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of dc41a67d0d0e95ad5bae8226052350b3987331a4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] dc41a67

False positive or not applicable? A repository writer can comment:
/ai-review override gpt dc41a67d0d0e95ad5bae8226052350b3987331a4 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] dc41a67

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable dc41a67d0d0e95ad5bae8226052350b3987331a4 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 8, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving as part of a bulk merge pass over readiness: passed PRs.

@chenmingwei23
chenmingwei23 merged commit b4a5645 into main Nov 8, 2026
105 checks passed
@chenmingwei23
chenmingwei23 deleted the crew/slack/ipc-pickup-skip-stub branch November 8, 2026 14:30
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
…#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).
buluoray added a commit that referenced this pull request Nov 8, 2026
…#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).
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.

2 participants