Skip to content

fix(kas): relay plain-http mcp headers again unless the operator opts out - #31064

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/kas-http-bridge-opt-in
Nov 6, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/kas-http-bridge-opt-in

Conversation

@buluoray

@buluoray buluoray commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the KAS backend, an MCP server reached over plain http:// on another host with headers connects through Crew's bridge as it did before #30643, and refusing it is an opt-in setting.

#30643 made Crew stop bridging an MCP server's headers to a plain http:// url on another host. That setup worked before: KAS refuses such a url itself, but it sees Crew's bridge as a local stdio server, so the server connected. After #30643 it no longer runs. Review 5795405137 on #30643 asks to keep today's behaviour by default and put the refusal behind a setting that is off, and to drop a new regex from kas_env_launch.py.

Why it matters

Users with such a server lost it on upgrade, with only a notice to explain why. A tightening like this should be the operator's choice, not a new default.

Not a goal

What changed (motivation → approach → change)

Review 5795405137 on #30643, item by item:

  1. No regex. _normalized_host now uses a plain character check (all(c in "0123456789abcdefx." for c in candidate) on a non-empty host) and import re is gone. Same behaviour; the existing parity table (test_kas_accepts_url_matches_the_backends_rule) still passes. The function moved, unchanged apart from that line, from acp/kas_env_launch.py into kas_http_bridge.py, the standard-library leaf, and kas_env_launch imports it from there. The bridge needs the same loopback reading for its proxy rule (below), and the bridge cannot import the ACP stack.
  2. Today's behaviour by default, refusal as an opt-in. kas_env_launch.bridgeable bridges a plain http:// url to another host again unless agent.kas_refuse_plain_http_mcp_headers is true (new, default false). With the key on, the server is not bridged and the session notice names it as not running, as in fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key #30643. A url whose port does not parse is never bridged, so one bad entry cannot stop the batch. bridgeable strips the url first, as kas_accepts_url does, and bridge_url returns the stripped url on every branch, so the snapshot the launcher reads never keeps the spaces. The key is read at the point of use, kas_env_launch.refuses_plain_http_headers (KiroCrewConfig.load() when a session's projection runs). Only a JSON true turns it on; a config that cannot be loaded reads as off, which is today's behaviour.
  3. Proxy rule follows. The bridge's opener skips environment proxies only for a loopback http host, the case fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key #30643 meant to fix. A plain http url to another host keeps the environment proxy, as before fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key #30643, since that may be its only route there.

Kept from #30643: the not-run notice for servers KAS refuses, registry mode, the loopback host canonicalization for the bridge, and the random unkeyed- launch key.

Docs: the security.md row, agent-spec-fields.md and configuration.md describe the default and the new key. config-baseline.json regenerated. The help text lives in sections_agent_fields.py (to keep sections_agent.py within its line budget), so the config.sections facade and its inventory bind the new constant.

builder-security checked: no listener is added or changed. The bridge is an outbound stdio-to-HTTP relay. The default restores the pre-#30643 behaviour for one url class, and the stricter behaviour is one config key away.

Backwards compatibility

Compatible: this restores what worked before #30643 (a header-bearing http:// server on another host connects through the bridge), and it adds one optional key that defaults to off. Nothing that works on main today stops working.

Removes nothing: the only behaviour taken away is #30643's default refusal, which is now the opt-in key, and the new key adds a choice without hiding or renaming anything.

Tests

Proof: PROVEN test/test_kas_mcp_not_run_notice.py::test_a_loopback_bridge_never_goes_through_an_environment_proxy[http://127.1:9/mcp], test/test_kas_mcp_not_run_notice.py::test_a_loopback_bridge_never_goes_through_an_environment_proxy[http://0x7f000001/mcp], test/test_kas_mcp_not_run_notice.py::test_a_loopback_bridge_never_goes_through_an_environment_proxy[http://127.0.0.1./mcp] (head 4990865)

test/test_kas_mcp_not_run_notice.py:

  • test_by_default_a_plain_http_server_with_headers_is_bridged_as_before: key off, the server goes through the bridge and no not-run entry is recorded.
  • test_a_url_with_surrounding_space_is_bridged_like_the_other_readers: a url with surrounding spaces (loopback and another host) is bridged, because bridgeable strips it as kas_accepts_url and bridge_url do.
  • test_the_bridge_dials_the_canonical_loopback_host[...]: also covers " https://mcp.example/v1 " and " http://mcp.example/v1", whose snapshot url is stripped.
  • test_with_the_refusal_on_it_is_not_bridged: key on, not bridged, named insecure-url.
  • test_the_refusal_is_read_from_the_agent_config[...]: only a JSON true in config.json turns it on (true, false, "true", absent).
  • test_a_loopback_bridge_never_goes_through_an_environment_proxy: also asserts a plain http url to another host keeps the environment proxy.
  • The loopback, notice and bad-port tests run with the key on or off as each needs.

One mutation per guard, each reddened a named test: bridging despite the key (test_with_the_refusal_on_it_is_not_bridged), refusing by default (test_by_default_..._bridged_as_before), the key always on (test_the_refusal_is_read_from_the_agent_config[False-False]), the loader dropping the key ([True-True]), the proxy bypass for every http host and for literal hosts only (test_a_loopback_bridge_never_goes_through_an_environment_proxy[http://127.1:9/mcp]), the bad-port guard (test_a_bad_port_on_one_server_does_not_stop_the_session), and the strip (test_a_url_with_surrounding_space_is_bridged_like_the_other_readers[ http://127.0.0.1:8080/mcp]).

Run locally, single process: test_kas_mcp_not_run_notice.py, test_kas_header_bridge.py, test_kas_env_launch.py, test_kas_withheld_credentials_notice.py, test_config_baseline.py, test_config_module_boundaries.py, test_config_refactor_contract.py -> 181 passed; test_sections_facade.py, test_facade_mirror_guards.py -> pass; test_config_load_pipeline_field_defaults.py, test_config_api.py, test_config_enum_coerced_keys.py, test_config_core_owned_sections.py -> 242 passed. black, isort, flake8, mypy (touched modules), comment-history, brand, harness parity, file line cap and docs lint pass.

Manual verification

N/A — unit coverage sufficient: the change is which entries the projection bridges and which opener the bridge builds, and the tests assert both directly.

Related Issues

Follow-up to #30643, addressing review 5795405137 (#30643 (review)).

Sibling sweep

Swept: git grep -nE "kas_accepts_url|bridgeable(|ProxyHandler" -- src/kiro_crew
Sibling: src/kiro_crew/acp/kas_agents.py -- not affected -- its insecure-url record applies only to an entry left with a url and no command, so a bridged entry is never named
Sibling: src/kiro_crew/kas_http_bridge.py -- changed here

Pattern harvest

Not generalizable: a default that a fix tightened, put back behind an opt-in at a reviewer's request.

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.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 6, 2026 04:04
@buluoray
buluoray requested a review from bolichen97 November 6, 2026 04:04
@buluoray
buluoray enabled auto-merge (squash) November 6, 2026 04:04
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 4990865ec458cbc1dd4476fe1f77d9571cce7de9 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 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the PR puts back the behaviour users had before #30643 and makes the refusal an opt-in key. It takes nothing away from any reader, because kas_env_launch re-imports the helpers that moved.

Notes

  • refuses_plain_http_headers calls KiroCrewConfig.load() once for every non-KAS-accepted entry in bridgeable. Reading the key once per projection batch and passing it in would give each session one consistent answer.

[DESIGN-REVIEWED] 4990865

Description read

[DESCRIPTION-READ] 9e99266a10be71e8b1611b1d0cf2383749c33bfba172a00b4d83d5ee062eb069

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 added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 4990865ec458cbc1dd4476fe1f77d9571cce7de9 — 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

Nothing blocks. This puts back what worked before #30643, and the linked review 5795405137 asks for it. The new key defaults to off and has one consumer, bridgeable.

What this change ships

Inventory (6 items) — 6 justified

Intent: let an operator's plain-http:// MCP server with headers on another host connect through KAS again, with refusing it as an opt-in. This is a FIX.

  1. By default, a plain-http MCP server on another host with headers connects through the bridge again, as it did before fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key #30643 — justified
  2. A new config key, agent.kas_refuse_plain_http_mcp_headers, default false, brings back the refusal from fix(kas): name MCP servers KAS will not run, and relay env/headers without a session key #30643 — justified
  3. The bridge skips environment proxies only for a loopback http host, so a remote plain-http server uses the proxy again — justified
  4. The loopback-host check no longer uses a regex, with the same behaviour — rides along
  5. _normalized_host and _LOOPBACK_HOSTS moved into the standard-library bridge module so the bridge and the projection share them — justified
  6. Urls with surrounding spaces are stripped consistently in bridgeable and bridge_url — undeclared

[FIRST-PRINCIPLES-REVIEWED] 4990865

Description read

[DESCRIPTION-READ] d0148c8a780a67f3d7c4745c738a00a4a099a5b5c5451d0cbf0516b7ace2c660

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 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 4990865

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

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4990865

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

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

Requesting changes on 0706946. This head does what the review on #30643 asked: the regex is gone (_normalized_host uses a plain character check and import re is removed), today's behavior is the default, and the refusal is an off-by-default key with tests for both states. One real defect is left.

bridgeable in kas_env_launch.py now tests url.lower().startswith(("https://", "http://")) on the raw string. kas_accepts_url and bridge_url both strip the url first, and the old bridgeable went only through kas_accepts_url. So an entry like " http://127.0.0.1:8080/mcp" with headers was bridged before and is not bridged on this head: its headers stay withheld and the server fails to authenticate. This matches the GPT lane finding at kas_env_launch.py:301, and I confirmed it in the diff. It fails closed, so nothing leaks, but it is a regression for a setup that works today.

Fix: strip the url once at the top of bridgeable (for example url = url.strip()) before the scheme check, so all three readers agree. A test with a leading space and headers on a loopback url and on another host would pin it.

Everything else looks right to me: the key reads only a JSON true, an unreadable config reads as off, the bad-port guard keeps one entry from stopping the batch, and the bridge keeps the environment proxy for plain http to another host as before.

I will look again when the head moves.

@buluoray
buluoray force-pushed the crew/slack/kas-http-bridge-opt-in branch from 0706946 to 0a2c448 Compare November 6, 2026 04:27
@buluoray

buluoray commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Disposition for 0706946 -> fixed in 0a2c448.

GPT 6.1 F1 / review 5795707660 (kas_env_launch.py:301, scheme check on the raw url): fixed. bridgeable now strips the url once before the scheme check, the way kas_accepts_url and bridge_url read it, so " http://127.0.0.1:8080/mcp" with headers is bridged again.

  • New test test_a_url_with_surrounding_space_is_bridged_like_the_other_readers, parametrized on a loopback url and on another host, both with headers.
  • Mutation: removing the strip turns test_a_url_with_surrounding_space_is_bridged_like_the_other_readers[ http://127.0.0.1:8080/mcp] red.
  • test_kas_mcp_not_run_notice.py, test_kas_header_bridge.py, test_kas_env_launch.py, single process: 96 passed. The Proof line in the description is refreshed for this head.

@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 Nov 6, 2026
@buluoray
buluoray force-pushed the crew/slack/kas-http-bridge-opt-in branch from 0a2c448 to f4a5e2b Compare November 6, 2026 04:59
@buluoray

buluoray commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Disposition for 0a2c448 -> fixed in f4a5e2b.

GPT 6.1 F1 (kas_env_launch.py:301, the snapshot keeps the untrimmed url): fixed. Same class as the previous round: an untrimmed url used after a trimmed one was tested. Sites checked: bridgeable (stripped last round), bridge_url (fixed here), and kas_agents' insecure-url check (already reads through kas_accepts_url, which strips). bridge_url now strips first and returns the stripped url on every branch, so the snapshot never holds the spaces the launcher refuses. That also covers a header-bearing " https://..." entry.

  • test_the_bridge_dials_the_canonical_loopback_host gains " https://mcp.example/v1 " and " http://mcp.example/v1".
  • Mutation: returning the raw url turns test_the_bridge_dials_the_canonical_loopback_host[ https://mcp.example/v1 -https://mcp.example/v1] red.
  • test_kas_mcp_not_run_notice.py, test_kas_header_bridge.py, test_kas_env_launch.py, test_kas_env_shim.py, single process: 114 passed. Proof line refreshed.

@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 Nov 6, 2026
… 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.
@buluoray
buluoray force-pushed the crew/slack/kas-http-bridge-opt-in branch from f4a5e2b to 4990865 Compare November 6, 2026 05:36
@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 6, 2026
@buluoray
buluoray requested a review from bolichen97 November 6, 2026 06:27
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding 4990865 for human review. I found no concrete defect.

Why it is held:

The code matches its description. The key reads only a JSON true, an unreadable config reads as off, a bad port is never bridged, and bridge_url returns the stripped url on every branch. All checks on this head are green. One non-blocking Design note remains: the config is loaded once per entry rather than once per batch.

This clears when a maintainer accepts the cleartext-by-default policy and the change request is re-reviewed or dismissed.

— crew-pr-reviewer (r147)

@bolichen97 bolichen97 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 4990865. The point from my earlier review is fixed.

What I checked on this head:

  • All checks are green, including PR Readiness, CodeQL, Coverage Gate and Windows shard 8. The cancelled entries in the list are older duplicate runs, and each has a newer run that passed.
  • bridgeable now strips the url once before the scheme check, so it reads the url the same way as kas_accepts_url and bridge_url. bridge_url returns the stripped url, because the launcher needs one that starts with the scheme. A new test covers a leading space and headers on a loopback url and on another host.
  • The change from the last head I reviewed is small: this head also exports the help text constant for the new setting through the config module boundary. There is no other code change.
  • No regex in the added product code. The earlier re.fullmatch is gone and import re is removed.
  • The default keeps today's behavior. agent.kas_refuse_plain_http_mcp_headers is off unless it is a JSON true, so this adds no restriction.

I did not set auto-merge, because it is already set on this PR.

@buluoray
buluoray merged commit f0d6dc0 into main Nov 6, 2026
99 of 108 checks passed
@buluoray
buluoray deleted the crew/slack/kas-http-bridge-opt-in branch November 6, 2026 07:12
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
buluoray added a commit that referenced this pull request Nov 6, 2026
… 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)
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.

3 participants