Repository navigation
fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key - #30643
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the fix mirrors KAS's URL and registry rules in Crew's KAS adapter, and it lists the one thing it takes away (the header-bearing Notes
[DESIGN-REVIEWED] ed3721f Description read[DESCRIPTION-READ] 0ae456e66e90f95ea636cd78c318f73297e295cfd1e8d6860230d90ea9ac1b12 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 Every item maps to an audit row in #30630 or a KAS rule the description cites. The KAS url check overlaps existing loopback helpers in name only: its accept set is deliberately narrower. What this change shipsInventory (9 items) — 9 justifiedIntent: on the KAS backend, users see which MCP servers will not run, and credentialed servers get their env/headers even in sessions that have no key yet. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ed3721f Description read[DESCRIPTION-READ] 03ce2988210d089cc85a6c3ff388cb81984ce4777f38f24a98d1248879809528 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
af53d2f to
069f274
Compare
|
Fixed in 069f274: Confirmed in code before fixing: |
069f274 to
89a3884
Compare
|
Fixed in 89a3884:
|
89a3884 to
aa98b13
Compare
…thout a session key - Bridge a remote server only when KAS itself would accept its url (https, or http to a loopback host, normalised as KAS's URL parser does). A plain http url to another host is named in the session notice instead of being bridged with its headers in cleartext. - A plain-http (loopback) bridge ignores environment proxies, so its headers never reach an http_proxy in cleartext. - In MCP registry mode, the notice names each server Crew withholds, and Crew's own servers, which KAS drops when the Kiro profile is registry-governed. - A session batch with no session key yet (background or pooled runtime) names its launch snapshots with a random key, so stdio env and streamable-HTTP headers still reach the server. - Move two config reads out of kas_agents.py for its line cap. Fixes #30630
aa98b13 to
ed3721f
Compare
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
Approving ed3721f.
What this does for users: on the KAS backend, an MCP server that will not run is now named in the session notice (a plain http:// url to another host, and servers dropped in MCP registry mode), and background or pooled sessions start credentialed servers with their env and headers instead of without them. Headers are no longer sent in cleartext to another host, and a loopback bridge never goes through an environment proxy.
Evidence:
- Targeted tests at this head, single process:
test_kas_mcp_not_run_notice.py,test_kas_env_launch.py,test_kas_withheld_credentials_notice.py,test_member_memory_mcp_routing.py,test_kas_header_bridge.py,test_kas_agents_mcp_env_relay.py-> 223 passed. - One mutation per new guard, each reddened a named test:
bridgeableaccepting any http (test_a_plain_http_server_with_headers_is_not_bridged), host normalisation (test_kas_accepts_url_matches_the_backends_rule[http://127.1:8080/mcp-True]), canonical bridge host (test_the_bridge_dials_the_canonical_loopback_host), proxy bypass (test_a_loopback_bridge_never_goes_through_an_environment_proxy), the unkeyed launch key (test_headers_reach_the_bridge_without_a_session_key), registry labels (TestRegistryMode::test_every_server_is_named_crews_own_conditionally), and no files written byto_client_custom_agentwithout a key (test_no_session_key_keeps_the_withholding_projection). - The two managed-server sets the registry labels rely on (
MANAGED_MCP_SERVER_NAMES,KIROCREW_BIN_MCP_SERVERS) were checked equal at runtime, so the labels match what is withheld. - No listener is added or changed; the change only narrows where credentials go.
- Source-only: Windows
inet_atonparity, and the snapshot cleanup path (by batch names, unchanged).
Non-blocking follow-ups:
- The registry-mode notice tells the user to run
kirocrew config set agent.mcp_registry_mode false. Many users have no terminal, and this setting has no Settings control yet. A follow-up that adds one (and points the notice at it) would make the advice usable. - A snapshot from a payload that never reaches a session (session/new fails) waits for the boot sweep. Unchanged by this PR, but more batches now write snapshots.
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on ed3721f. The naming of servers that will not run, and the env and header relay for a runtime with no session key yet, are good changes, and all 99 checks are green. Two things need to change first.
-
New regex in product code.
kas_env_launch.pyaddsimport reand, in_normalized_host,re.fullmatch(r"[0-9a-fx.]+", candidate). Please replace it with a plain check, for exampleall(c in "0123456789abcdefx." for c in candidate)and a non-empty test, so the module needs noimport re. The behavior stays the same. -
A new restriction on a setup that works today. The PR description says it is breaking: a header-bearing
http://server on a non-loopback host connects through Crew's bridge now, and after this change it does not run. That tightens what users can do today, and it is a security-flavored change that I would not take as the default. Please keep today's behavior by default and put the new refusal behind a setting that is off by default (for example anagentconfig key), with tests for both states, as the other opt-in changes here do. The parts that only name servers that will not run, and the loopback host normalization for the bridge, can stay as they are.
The rest looks fine to me: the registry-mode notice is conditional for Crew's own servers, the random unkeyed- launch key only names the snapshot file, and the plain-http loopback bridge ignoring environment proxies is a good catch.
I will look again when the head moves.
… out #30643 stopped bridging an MCP server's headers to a plain http:// url on another host. That setup connected through Crew's bridge before, so it is restored by default, and the refusal moves behind agent.kas_refuse_plain_http_mcp_headers (off). The bridge bypasses environment proxies only for a loopback host, so a remote http server keeps its proxy route. The loopback host reading moves to the standard-library bridge, without a regex, so both sides share it.
… out #30643 stopped bridging an MCP server's headers to a plain http:// url on another host. That setup connected through Crew's bridge before, so it is restored by default, and the refusal moves behind agent.kas_refuse_plain_http_mcp_headers (off). The bridge bypasses environment proxies only for a loopback host, so a remote http server keeps its proxy route. The loopback host reading moves to the standard-library bridge, without a regex, so both sides share it.
… out #30643 stopped bridging an MCP server's headers to a plain http:// url on another host. That setup connected through Crew's bridge before, so it is restored by default, and the refusal moves behind agent.kas_refuse_plain_http_mcp_headers (off). The bridge bypasses environment proxies only for a loopback host, so a remote http server keeps its proxy route. The loopback host reading moves to the standard-library bridge, without a regex, so both sides share it.
… out (#31064) #30643 stopped bridging an MCP server's headers to a plain http:// url on another host. That setup connected through Crew's bridge before, so it is restored by default, and the refusal moves behind agent.kas_refuse_plain_http_mcp_headers (off). The bridge bypasses environment proxies only for a loopback host, so a remote http server keeps its proxy route. The loopback host reading moves to the standard-library bridge, without a regex, so both sides share it.
…thout a session key (#30643) - Bridge a remote server only when KAS itself would accept its url (https, or http to a loopback host, normalised as KAS's URL parser does). A plain http url to another host is named in the session notice instead of being bridged with its headers in cleartext. - A plain-http (loopback) bridge ignores environment proxies, so its headers never reach an http_proxy in cleartext. - In MCP registry mode, the notice names each server Crew withholds, and Crew's own servers, which KAS drops when the Kiro profile is registry-governed. - A session batch with no session key yet (background or pooled runtime) names its launch snapshots with a random key, so stdio env and streamable-HTTP headers still reach the server. - Move two config reads out of kas_agents.py for its line cap. Fixes #30630 Co-authored-by: Joe Guo <12429733+iamwhatever@users.noreply.github.com> (cherry picked from commit 50ebe42)
… out (#31064) #30643 stopped bridging an MCP server's headers to a plain http:// url on another host. That setup connected through Crew's bridge before, so it is restored by default, and the refusal moves behind agent.kas_refuse_plain_http_mcp_headers (off). The bridge bypasses environment proxies only for a loopback host, so a remote http server keeps its proxy route. The loopback host reading moves to the standard-library bridge, without a regex, so both sides share it. (cherry picked from commit f0d6dc0)
Problem / Motivation
Goal: On the KAS backend, an MCP server that will not run is named in the session notice, and a server's
envandheadersreach it even when the session has no key yet.Four MCP setups that work on kiro-cli fail on KAS with no visible cause (KAS gap audit rows P0-22, P0-24, P1-7, P1-8):
http://to another host. KAS refuses any url that is nothttpsorhttpto a loopback host (insecure-url, kiro-agentmcp/url-validation.ts). Crew said nothing. If the entry hadheaders, Crew's local bridge acceptedhttp://anyway and sent the headers in cleartext.agent.mcp_registry_modeon, Crew withholds every server it did not author. When the Kiro profile is registry-governed, KAS also drops every non-registry server of every tier, Crew's own included (kiro-agentmcp/mcp-desired-set.ts,mcp/registry/resolve-registry-entries.ts). Only a log line said so.env, a streamable-HTTP server without itsheaders(401).Why it matters
Users moving from kiro-cli to KAS lose MCP servers with no message. Registry-governed accounts lose Crew's own tools silently. Background and pooled sessions start credentialed servers without their credentials.
Not a goal
What changed (motivation → approach → change)
Symptom: servers missing on KAS with no reason shown, and credentials missing on keyless batches. Cause: Crew's checks did not match KAS's url and registry rules, and the env/header relay was gated on a session key that only names a file. Change, all in Crew's KAS adapter:
kas_env_launch.kas_accepts_urlmirrors KAS'sisHttpsOrLocalhost, with hosts normalised as KAS's WHATWG URL parser does (127.1,[0:0:0:0:0:0:0:1],0x7f000001are loopback;localhost.,127.0.0.2are not).bridgeableuses it, and the projection records a refused url asinsecure-url.kas_env_launch.bridge_url: the snapshot holds the canonical loopback host (127.0.0.1,[::1],localhost), so a spelling like127.0.0.1.is never resolved through DNS.kas_http_bridge._opener: a plain-http (loopback) bridge ignores environment proxies, becauseno_proxymatches spellings literally.httpskeeps the proxy; it tunnels.registry, each of Crew's own asregistry-if-governed. Crew cannot read KAS's access mode, so that part of the notice is conditional.kas_withheld_noticeadds a section above the existing one: servers that will not run, with the fix (https://, orkirocrew config set agent.mcp_registry_mode false).build_kas_custom_agentspasses a randomunkeyed-…launch key when the session has none. The key only names the snapshot file; cleanup reads names off the batch as before.to_client_custom_agentwithout a key still writes no files._registry_governedand_relayed_env_referencesmove unchanged intoacp/kas_projection_reads.pyfor the 2,000-line cap;kas_agentsimports them back, so the patch target is unchanged.security.mdrow andagent-spec-fields.mdupdated.Backwards compatibility
Breaking: a header-bearing
http://server on a non-loopback host, which connected through Crew's bridge before, no longer runs on KAS. KAS itself refuses that url, and the old path sent the headers in cleartext. Writer sweep on origin/main @ edd8754:bridgeablehas one caller,relay_withheld_headers, changed here;relay_withheld_envandrelay_withheld_headershave one caller,_project_mcp_servers, changed here.Reader: src/kiro_crew/acp/kas_agents.py:_project_mcp_servers -- chat|cron|subagent -- the http entry is still declared, KAS reports it
insecure-url, and the notice names it (test_a_plain_http_server_with_headers_is_not_bridged)Tests
Proof: not provable -- other: the new test module imports constants the fix adds, so prove.py's revert errors at collection; checked by hand that the no-key launch test fails and the old bridge opener carries the env proxy on main
test/test_kas_mcp_not_run_notice.py(new): url rule table with WHATWG parity cases; http server not bridged and named; loopback still bridged; snapshot dials the canonical loopback host; registry notice; headers bridged with no session key; loopback bridge ignoreshttp_proxy.test/test_kas_env_launch.py: a session batch with no key starts the server with its env (real launcher process).test/test_kas_withheld_credentials_notice.py: two tests that pinned the no-key loss now use ansseserver, which still cannot be carried.Manual verification
new URL+ KAS's rule and throughkas_accepts_url: identical answers.scripts/local-gate.pyrelated set: 9154 passed, 1 failed (test_acp_harness_contract.py::test_a_missing_self_served_binary_names_its_install_command[copilot], also red on clean main on this machine because copilot is installed). black, isort, flake8, mypy, semgrep, line cap, harness parity, docs lint pass.Related Issues
Fixes #30630
Overlap check: #26786 (merged) added the env/headers notice this extends. Open #28444 and #22375 cover registry-mode identity and
skill_search, not this notice. No open PR covers these rows.Sibling sweep
Swept: git grep -nE "session_key=session_key|bridgeable(|startswith(("https://", "http://"))" -- src/kiro_crew/acp src/kiro_crew/kas_http_bridge.py
Sibling: src/kiro_crew/acp/kas_env_launch.py -- changed here
Sibling: src/kiro_crew/kas_http_bridge.py -- changed here
Sibling: src/kiro_crew/acp/harness/kas.py -- not affected -- passes session_key through to build_kas_custom_agents, which now supplies the launch key
Pattern harvest
Rule candidate: review-prompt
Pattern: a url accepted by a normalising check is later dialled in its original spelling
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.