Skip to content

fix(identity): carry session identity to every granted Crew MCP server - #12476

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/identity-bound-crew-servers-12464
Sep 21, 2026
Merged

NicholasRBowers merged 1 commit into
mainfrom
fix/identity-bound-crew-servers-12464

Conversation

@NicholasRBowers

@NicholasRBowers NicholasRBowers commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

On the kiro backend, every tool on kirocrew-dashboard -- session_send, session_read_message, the chat_folder_* set -- is refused before it runs, in any session whose agent spec grants @kirocrew-dashboard:

tool 'session_read_message' is unavailable because this server could not prove which
session it acts for (identity_unattested): the gateway refused the tool-policy read ...
because the request carried no session token

The audit trail shows the server resolved its session key and only the token was missing (session_key=dashboard:chat-479-...,token=absent). The same holds for the other opt-in Crew servers (kirocrew-work, kirocrew-crew-log, kirocrew-panel) on both launch paths, and for kirocrew-computer when it is not routed through the broker.

Why it matters

The peer-session tools are how one session hands work to another. The shipped conductor agents (kirocrew-conductor, kirocrew-pipeline-conductor, kirocrew-security-conductor) mount kirocrew-dashboard by construction and so are broken out of the box on kiro: the server comes up, advertises its tools, and refuses every call. An operator who grants the server to their own agent gets the same present-but-unusable result with no remedy named.

What changed (motivation → approach → change)

Punch line A Crew server a spec grants now receives the session's identity, whichever of the two ways it is launched, and the token cannot be captured by code the launch could pick up on the way.
kiro backend (acp/session_mcp.py) kiro_control_plane_servers re-emits the element for every granted server in IDENTITY_BOUND_SERVERS, so the session token reaches it.
broker (mcp_gateway/gatewayd.py) CONTROL_PLANE_BACKENDS is the same set, read from the mcp_cleanup leaf, so any routed Crew server is handed the per-frame token after the same binary/args/env check. That check, and the pre-spawn scrub of the daemon's inherited env, deny LD_* / DYLD_* alongside PYTHON* (env._SPEC_ENV_DENIED_PREFIXES).
managed launch (agent.py, mcp_discovery.py) Every module-form invocation of a Crew server is <python> [-s] -P -m kiro_crew <sub>: -P keeps the spawn CWD off sys.path, so a kiro_crew/ package in the user's project cannot shadow this install.
docs (docs/architecture/mcp.md) The token-recipient section names the widened set, the widened fence and the ratchet that pins them.

Every managed Crew server reads the session's tool policy from the gateway on each call, and the gateway accepts a declared session key only behind an X-Session-Token attestation. Two things carry that token to a Crew server: on the kiro backend the runtime is session-unbound, so identity travels per MCP element and kiro_control_plane_servers re-emits those elements with the token in their env; on the pooled path gatewayd injects the token into the caller block. The first covered only CONTROL_PLANE_SERVERS, the two always-on servers; the second covered those two plus kirocrew-dashboard. An opt-in server is launched by kiro-cli straight from the spec with env: {}, so on that path no attestation ever reached it.

Handing the token to more servers makes the launch itself worth hardening. kiro-cli spawns a managed server with the user's project as its working directory, and the generic module-form fallback put that directory first on sys.path; the Windows bundle branch already pinned -P and the reason the generic branch did not (Python 3.10 support) no longer holds under requires-python >= 3.12. On the pool, the ownership check refused a child env carrying PYTHON* but not the dynamic-loader channels kiro_crew.env already treats as the same class.

IDENTITY_BOUND_SERVERS is derived from the managed server list (control plane first, in its existing order, then kirocrew-computer and the opt-in servers), so a server added to that list later is covered by construction and a session that grants only the control plane emits exactly what it emitted before. Both paths resolve a granted opt-in name's expected invocation with managed_mcp_spec_entry(name, include_opt_in=True); it still answers None for an unmanaged name or a closed spec gate. The grant itself is untouched: the spec's tools allowlist still decides what is mounted, an element whose declared command or args differ from Crew's own invocation is still withheld, and CONTROL_PLANE_SERVERS, the set that decides what every session mounts and what survives disabledTools, is unchanged.

Backwards compatibility

Breaking, narrowly: a Crew control-plane backend whose spawn env carries a non-empty LD_* or DYLD_* variable is now denied the session token, the same way a PYTHON* variable already was; and the managed module-form argv gains -P, so a spec written before this change carries the old argv until the spec writer regenerates it (require_fresh_derived_spec), during which the pool's args comparison denies the token rather than granting it. Writer sweep on origin/main 20261b763: both writers of a Crew server's env already strip exactly env._SPEC_ENV_DENIED_PREFIXES (sanitize_spec_env for spec-declared env; gatewayd's resolver for the daemon's inherited env), so no supported configuration reaches the new denial. Nothing else changes shape: a spec granting only kirocrew-core/kirocrew-cron produces the same elements in the same order, and a granted opt-in server gains an env token it never had.

Tests

  • test_kiro_identity_projection_covers_a_granted_opt_in_server (dashboard, work, crew-log): a spec granting the server yields its element beside the control plane's, with the managed command and args.
  • test_kiro_identity_projection_leaves_an_ungranted_opt_in_server_out: widening the set does not widen the grant.
  • test_identity_bound_set_is_every_managed_server: derived from the managed list, no duplicates, control plane leads in its own order.
  • TestGrantedOptInResolution: every opt-in managed server resolves under include_opt_in=True and not without it; the flag leaves the control plane's answer unchanged; kiro_control_plane_servers is pinned to pass exactly include_opt_in=True, so dropping the keyword fails a test instead of silently un-granting every opt-in server.
  • test_control_plane_backends_contain_session_mcp_and_justify_the_difference (gatewayd ratchet): the set equals IDENTITY_BOUND_SERVERS, the control plane is a strict subset, the token-only extras are pinned by name to the opt-in servers plus kirocrew-computer, and each extra is a managed server that is not unconditionally mounted.
  • test_the_real_dashboard_entry_rejects_native_loader_injection (LD_PRELOAD, DYLD_INSERT_LIBRARIES): the real managed invocation is denied the token and the warning names the key; an empty value is still accepted.
  • test_control_plane_target_resolver_strips_inherited_native_loader_env: an LD_PRELOAD the daemon inherited is removed from a control-plane spawn env and kept for a third-party backend.
  • test_agent.py _kirocrew_mcp_invocation assertions pin -s -P -m kiro_crew <sub> for every module-form fallback.
  • Existing identity tests stub managed_mcp_spec_entry with a keyword-tolerant double, since kiro_control_plane_servers passes include_opt_in=True.

Manual verification

N/A -- unit coverage sufficient: the change is two set-membership widenings, one resolver call, one argv flag and one env-prefix widening, each pinned above; the end-to-end shape (a kiro session's session/new element carrying the token) is already covered by test_kiro_unpooled_control_plane_receives_session_token, which runs unchanged.

Related Issues

Fixes #12464

Pattern harvest

Rule candidate: review-prompt
Pattern: an identity/credential carriage keyed on a hand-enumerated allowlist of names, while the set it should track is derived elsewhere -- a member added to the source set silently comes up unauthenticated.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

@NicholasRBowers
NicholasRBowers requested a review from a team September 21, 2026 06:44
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

Intent: A Crew MCP server that an agent spec grants (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log, kirocrew-computer) receives the session's identity on the kiro backend and in the broker pool, so its tools work instead of refusing every call as identity_unattested.
Not a goal: Widening any grant (the spec's tools allowlist still decides what is mounted), changing what a spec-less session receives, or carrying identity to these servers on the codex/opencode mirror projections, which continue to withhold them.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 21, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) September 21, 2026 06:44
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 49ce00564c6e2929a342b7ca94be877bbd92f815 — 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 bundle argv reorder rests on symmetry alone and widens the stale-spec token-denial window; a 382-line semgrep gate rides along that main already carries.

Not justified as shipped

  • Item 3 — rides along: the LD_*/DYLD_* token denial is hardening the description itself separates from the fix ("makes the launch itself worth hardening"); named cause (token capture), declared, sweep shown.
  • Item 4 — rides along: -P on the generic fallback; the deleted Python-3.10 pin is refuted by requires-python = ">=3.12" (pyproject.toml:14), which I verified.
  • Item 5 — unjustified move: the bundle branch's -P -s → -s -P swap is supported only by "Keep the shared -s -P -m order" — both orders behave identically, and the swap makes every pre-change Windows-bundle spec's argv mismatch (token denied) until regeneration, a window only this reorder creates for that branch.
    Subtraction: revert the flag swap in _kirocrew_mcp_invocation's .cmd branch; only the generic fallback needed -P added.
    Clears when: the swap is dropped, or a consumer requiring one canonical order is named.
  • Item 6 — duplicate of semgrep/mock-pid-allocatable.yaml on main: semgrep/mock-pid-allocatable.yaml, semgrep-tests/mock-pid-allocatable.py and test/test_mock_pid_gate_wiring.py appear nowhere in the description and are byte-identical to main commit 3042f6614 (ci(semgrep): refuse a fabricated mock pid a live process could own #12590) — grepped the checkout, 1 existing copy.
    Subtraction: rebase onto main so the diff carries only the identity change.
    Clears when: a push or rebase removes these three files from the diff.

What this change ships

Inventory (8 items) — 4 justified

Intent: make the Crew MCP servers an agent spec grants actually usable by carrying the session's identity token to them on both launch paths — a FIX (issue #12464, tests added).

  1. Granted opt-in Crew servers (dashboard, work, crew-log, panel) now work on the kiro backend instead of refusing every call — justified
  2. Those servers plus kirocrew-computer now receive the token on the pooled/broker path — justified
  3. A control-plane spawn env carrying non-empty LD_*/DYLD_* is now denied the token, and the daemon's inherited copies are scrubbed — rides along (declared hardening with a named cause)
  4. Managed module-form servers now launch with -P, keeping the project CWD off sys.path — rides along (declared; stale pin refuted with evidence)
  5. Windows-bundle argv reordered -P -s → -s -P — unjustified move (symmetry only; enlarges the stale-spec denial window)
  6. A semgrep gate rejecting allocatable mock pids, with fixtures and a wiring test — duplicate of semgrep/mock-pid-allocatable.yaml on main (3042f6614, ci(semgrep): refuse a fabricated mock pid a live process could own #12590), undeclared
  7. IDENTITY_BOUND_SERVERS derived from the managed set, ratchet-pinned equal to gatewayd's — justified
  8. docs/architecture/mcp.md updated in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] 49ce005

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

Stripping all LD_* from control-plane spawn env risks breaking core/cron spawns on interpreters that need LD_LIBRARY_PATH; the compat analysis covers only the denial path.

Watch

The backwards-compat sweep proves "no supported configuration reaches the new denial," but env_target_resolver now also removes inherited LD_*/DYLD_* before a Crew control-plane spawn (denied_env_prefixes = _SPEC_ENV_DENIED_PREFIXES). A daemon launched from an environment where the interpreter or its shared libs resolve via LD_LIBRARY_PATH (HPC modules, shared-lib Python builds) spawns children that fail to start — kirocrew-core/kirocrew-cron are mounted in every session, and the spec cannot restore the variable because a non-empty LD_* now denies the token. The PYTHONHOME precedent accepted this class already, but LD_LIBRARY_PATH is far more commonly load-bearing than any PYTHON* key.
Clears when: the PR states (or a test/manual check shows) a control-plane child spawned by absolute interpreter path starts without inherited LD_LIBRARY_PATH, or the compat note extends to this runtime-dependency side with the operator remedy named.

[DESIGN-REVIEWED] 49ce005

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

The project requires Python ≥3.12, so -P (3.11+) is safe on every supported interpreter — the removed comment referencing 3.10 was stale. That path is not a defect.

On the given candidate: stripping LD_*/DYLD_* from control-plane children is a deliberate hardening consistent with the classifier that denies the token when those are present (the strip is precisely what lets the control plane keep its token when such a var is inherited). The failure it posits requires an install whose interpreter needs an inherited LD_LIBRARY_PATH — control planes run Kiro Crew's own relocatable bundle or a system/venv Python that carries its own RPATH. That input is a "might," not a condition I can show occurs in practice, and the candidate self-rates low confidence. It does not survive falsification at 80+.

No findings.

[OPUS-REVIEWED] 49ce005

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

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

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 49ce00564c6e2929a342b7ca94be877bbd92f815 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 49ce005

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

@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 21, 2026
@NicholasRBowers
NicholasRBowers force-pushed the fix/identity-bound-crew-servers-12464 branch from 87dfc01 to 4a842ec Compare September 21, 2026 07:09
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/apps/builtins/aws_control/backend/backup.py since this head went green (34fe0de -> 1dd5a03). The one red on 87dfc01 was mypy on that file -- main's own defect at 34fe0de, fixed on main by 1dd5a03 -- so this is a rebase-only re-sync with the diff unchanged; CI re-running on 4a842ec.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 21, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 21, 2026
@NicholasRBowers
NicholasRBowers force-pushed the fix/identity-bound-crew-servers-12464 branch from 4a842ec to 9b1f9a1 Compare September 21, 2026 17:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Sep 21, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/agent.py, src/kiro_crew/mcp_gateway/gatewayd.py and test/test_mcp_gateway_stub_session_token.py since this head went green (1dd5a03 -> 53cfc5d; conflict with #12459, which added kirocrew-dashboard to CONTROL_PLANE_BACKENDS and managed_mcp_spec_entry(include_opt_in=True)). Resolved by adopting #12459's resolver on both identity paths and dropping this PR's managed_mcp_granted_entry; the diff no longer touches agent.py. CI re-running.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 21, 2026
@NicholasRBowers
NicholasRBowers force-pushed the fix/identity-bound-crew-servers-12464 branch from 9b1f9a1 to 0c0f956 Compare September 21, 2026 18:27
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 0c0f956d3e7c53f97e403fc05d24011acae8268a; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

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

@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 21, 2026
@NicholasRBowers
NicholasRBowers force-pushed the fix/identity-bound-crew-servers-12464 branch from 0c0f956 to 6fa78f8 Compare September 21, 2026 19:36
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: -P on every module-form managed invocation (agent._kirocrew_mcp_invocation)

  • Module fallback can execute a project shadow with the session token span=5b73f976724d

fixed in 6fa78f8.
Verified: the generic fallback emitted <python> [-s] -m kiro_crew <sub> with no -P; kiro-cli spawns it in the project CWD, which -m puts first on sys.path, so a project kiro_crew/ package would run with the token. The Windows bundle branch already pinned -P; the stated reason the generic branch did not (Python 3.10 support) is stale under requires-python >= 3.12.
Every module-form invocation is now [-s] -P -m kiro_crew <sub> (generic sentinel fallback, .cmd unwrap and its sys.executable fallback), which is the CWD-independent invocation the docstring promises; gatewayd's argv comparison derives from the same helper so both sides move together, and a pre-change spec is denied (not granted) until the writer regenerates it.
Pinned by the _kirocrew_mcp_invocation assertions in test/test_agent.py and the module-entry fixture in test/test_mcp_gateway_stub_session_token.py; test_the_real_managed_entry_matches_itself and the dashboard parity test still pass.

@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: control-plane env fence and pre-spawn scrub both read env.SPEC_ENV_DENIED_PREFIXES (LD, DYLD_, PYTHON)

  • New token recipients permit native-loader injection span=0e21ddd67f91

fixed in 6fa78f8.
Verified: _spawns_own_control_plane denied a child env carrying a non-empty PYTHON* key but not LD_* / DYLD_*, while spawn_env.update(declared) forwards spec-declared env before the verdict; kiro_crew.env already classes all three prefixes as launcher-execution channels.
The fence and the control-plane branch of the inherited-env scrub (env_target_resolver) now use that shared tuple: a non-empty LD_PRELOAD / DYLD_INSERT_LIBRARIES denies the token and the warning names the key, an empty value is still accepted, and an inherited loader variable is stripped before a control-plane spawn while a third-party backend keeps it.
Opposite-mode check: no first-party path writes LD_* / DYLD_* into a control-plane spawn env before the verdict (PYTHONSAFEPATH, PYTHONNOUSERSITE and the UTF-8 pins are applied after it); both writers of a Crew server's env already strip these prefixes, so no supported configuration reaches the new denial.
Pinned by test_the_real_dashboard_entry_rejects_native_loader_injection and test_control_plane_target_resolver_strips_inherited_native_loader_env.

@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 21, 2026
An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464
@NicholasRBowers
NicholasRBowers force-pushed the fix/identity-bound-crew-servers-12464 branch from 6fa78f8 to 49ce005 Compare September 21, 2026 20:05
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/computer_use/launch_macos.py, src/kiro_crew/computer_use/launch_windows.py, src/kiro_crew/crew_log/emit.py and src/kiro_crew/crew_log/projection.py (importers of modules this PR touches) since this head went green (20261b7 -> 14eb805); diff unchanged, overlap-scoped tests green locally; CI re-running on 49ce005.

@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 Sep 21, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author
  • Item 3 — LD_*/DYLD_* token denial rides along span=998d8d5a1fc8

rebutted. This is not an opportunistic hardening: the GPT lane raised it as a security-class BLOCKING finding on this PR's head 0c0f956 (span=0e21ddd67f91, "New token recipients permit native-loader injection") and its adjudication upheld it, so readiness could not pass without it.
It is causally tied to the fix: this PR is what hands the per-frame token to every managed Crew server, so the fence that decides who is Crew-owned has to be complete for the widened population; kiro_crew.env._SPEC_ENV_DENIED_PREFIXES already classed the three prefixes together and the fence read only one of them.
The description separates it into its own row and sentence precisely so a reader can see it is a consequence of widening the recipients, not part of the identity carriage itself. The declared-vs-inherited boundary raised by the Design lane's Watch item is being narrowed in the next head.

@NicholasRBowers

Copy link
Copy Markdown
Contributor Author
  • Item 4 — -P on the generic fallback rides along span=2142f94ebbda

rebutted. The GPT lane raised this as a security-class BLOCKING finding on head 0c0f956 (span=5b73f976724d, "Module fallback can execute a project shadow with the session token") and its adjudication upheld it; the PR could not converge without it.
It is tied to the fix's own mechanism: kiro_control_plane_servers re-emits the managed invocation with the session token in its env for every granted server, and kiro-cli launches that invocation in the user's project directory. Without -P, -m kiro_crew puts that directory first on sys.path, so a project kiro_crew/ package would run with the token this PR now carries to more servers.
The reviewer's own verification agrees the deleted Python-3.10 rationale is refuted by requires-python = ">=3.12"; the change restores the CWD-independence the function's docstring already promised.

@NicholasRBowers

Copy link
Copy Markdown
Contributor Author
  • Item 6 — duplicate of semgrep/mock-pid-allocatable.yaml rides along span=e719c1e68631

rebutted: those three files are not in this PR's diff. GitHub's file list for #12476 at head 49ce005 is exactly eight paths (docs/architecture/mcp.md, acp/session_mcp.py, agent.py, mcp_discovery.py, mcp_gateway/gatewayd.py, test/test_agent.py, test/test_mcp_gateway_stub_session_token.py, test/test_session_token_identity.py), and git diff --stat origin/main...HEAD from the merge base 14eb805 shows the same eight.
The cited main commit 3042f66 (#12590) landed AFTER this head's base 14eb805, so a two-dot comparison against main's tip shows its files as differing; the three-dot diff the PR is reviewed on does not contain them. A rebase would make the artifact disappear, but it cannot remove files that were never part of the change.

@buluoray buluoray 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.

Verified at head 49ce0056. Approving. The identity carry and the loader-namespace hardening are both sound, and I checked the two advisory CONCERNS against source rather than relaying them -- one holds and deserves an answer before merge, one reduces to cosmetics, and one item is already stale.

The hardening's own rationale is the strongest part of this change and worth restating so it does not get lost in the CONCERNS. A control-plane backend is exactly the process that holds a session identity token, and LD_* / DYLD_* replace code in every binary of the spawn chain -- so an operator-environment variable reaching that child is code injection into the token holder. Stripping the namespace in env_target_resolver and then denying any non-empty entry still present at the verdict is the right pair, and the ORDER is what makes it a guarantee rather than a hope: the classifier sees a cleaned environment, so anything remaining came from a hand-declared overlay. The prefix rule fails closed when Python or a loader adds a variable, which is the correct direction for a list that can go stale.


Design Review's CONCERNS holds and is the one item I would want answered before merge. Not because the strip is wrong -- it is within the threat the change names -- but because it has no operator remedy, and I confirmed both halves in the diff: env_target_resolver removes the namespace from the inherited environment, and the verdict then denies the token on any non-empty entry (if loader_env: return _deny_control_plane(...)). So on a host where the interpreter or its shared libraries resolve through LD_LIBRARY_PATH -- HPC module systems, shared-lib Python builds -- the control-plane child fails to start, and the spec cannot put the variable back, because declaring it is precisely what denies the token. That lands on kirocrew-core and kirocrew-cron, which are mounted in every session.

The PYTHONHOME precedent does accept this class, and Design is right that it is not the same bet: LD_LIBRARY_PATH is load-bearing on far more real installs than any PYTHON* key. The compat sweep in the description covers the denial path thoroughly and does not cover the runtime-dependency side. Either evidence that a control-plane child spawned by absolute interpreter path starts without an inherited LD_LIBRARY_PATH, or a compat note naming what an affected operator does instead, closes it. A host whose work stops with no record that anyone chose to lose it is the outcome worth spending a paragraph to avoid.


First Principles item 5 is mechanically correct but its consequence does not materialise. The verbatim comparison is real -- gatewayd.py:254-256 is if argv != expected_argv: return _deny_control_plane(...), a plain list compare with no normalisation -- so a spec carrying the old -P -s order really would be denied against a launcher emitting -s -P. What closes the window is that entry["command"] / entry["args"] are host-owned and rewritten on the existing-config refresh path at gateway start (agent.py:2507-2515 documents the fresh-build and refresh paths applying the same ownership logic, with args set by the caller on both). You cannot be running the new launcher without having restarted, and that restart rewrites the spec before any session launches an MCP server. So the finding reduces from "denies tokens on every pre-change Windows bundle" to "an unnecessary change" -- which it still is, since both orders behave identically and FP's suggested subtraction costs nothing. Your call, but it is cosmetics rather than a regression.

First Principles item 6 is stale -- do not act on it. It reports semgrep/mock-pid-allocatable.yaml, semgrep-tests/mock-pid-allocatable.py and test/test_mock_pid_gate_wiring.py riding along as byte-identical duplicates of main's 3042f6614. At this head they are not in the diff: the three-dot file list against origin/main is exactly the eight files this PR owns, and mock-pid matches zero of them. Nothing to rebase out.

Item 4 checks out as FP states it -- requires-python = ">=3.12" at pyproject.toml:14, so the deleted Python-3.10 pin was dead weight rather than a dropped guard.


Both blocking-capable lanes carry real verdicts at this head, which I checked by matching the SHA and taking the latest comment rather than reading the rollup: GPT 5.6 and Opus 4.8 both clean at 49ce0056 (20:15 and 20:17). The three "review incomplete" comments in the thread belong to the earlier 9b1f9a19 and 0c0f956d and are not outstanding -- worth knowing, because the repo's App installation has been returning rate limit exceeded on the shared Resolve human override preflight this evening, which is what produces that comment and what is currently reddening review lanes on other PRs.

@NicholasRBowers
NicholasRBowers merged commit 0140fdd into main Sep 21, 2026
93 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/identity-bound-crew-servers-12464 branch September 21, 2026 20:50
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 21, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
kirodotdev#12476)

An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since kirodotdev#12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
kirodotdev#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes kirodotdev#12464

Co-authored-by: Nicholas Bowers <NicholasRBowers@users.noreply.github.com>
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
kirodotdev#12476)

An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since kirodotdev#12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
kirodotdev#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes kirodotdev#12464

Co-authored-by: Nicholas Bowers <NicholasRBowers@users.noreply.github.com>
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.

fix(identity): opt-in Crew MCP servers refuse every call with identity_unattested on the kiro backend

2 participants