Skip to content

fix(kas): say when a remote MCP server's oauth block cannot reach the backend - #27712

Merged
bolichen97 merged 1 commit into
mainfrom
fix/kas-oauth-discarded
Nov 4, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/kas-oauth-discarded

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the KAS backend, a user whose agent declares a remote MCP server with a pre-registered OAuth client is told that sign-in will not work there, and the client secret stays off the wire.

KAS rebuilds each remote MCP entry from url/headers/env/timeout only, so a server's oauth block never reaches the backend. No sign-in card appears, the server's tools never load, and Crew logs nothing and shows nothing. Part of #27711.

Why it matters

Any KAS user with a provider that needs a pre-registered client (no Dynamic Client Registration) gets a server that silently does nothing, with no hint that the kiro-cli backend would work. The block can also hold a clientSecret, which was being sent to a backend that throws it away.

Not a goal

What changed (motivation → approach → change)

Symptom: a silent, unusable server. Cause: _project_mcp_servers forwards oauth, KAS drops it, and spec_keys_without_carrier has no entry for it, so the existing session-start notice never fires.

The change reuses the existing loss-reporting path rather than adding one:

  • src/kiro_crew/mcp_oauth_projection.py (new leaf outside the ACP layer, so kas_agents.py stays under the 2,000-line cap and the dashboard notice can read the key format); the log carries a fixed message and a key count only: the predicates, the key format, and the withhold-and-log step.
  • src/kiro_crew/acp/kas_agents.py: _project_mcp_servers withholds oauth from the projected entry and logs a fixed message with the block's key count only (no key name or value). spec_keys_without_carrier takes a new discards_mcp_oauth flag and, when set, adds mcpServers.<name>.oauth for each server the projection actually declares. Muted and registry-withheld entries are skipped through registry_withheld, a predicate the projection now shares, so the notice never names a server that does not run.
  • src/kiro_crew/dashboard/chat_turn/tool_approval.py: _spec_keys_notice adds one sentence for those keys: "Sign-in to MCP server will not work on this backend. The kiro-cli backend supports it." The row still passes through _redact_display_text.
  • src/kiro_crew/agent_sdk/spec_hooks.py, src/kiro_crew/dashboard/chat_turn/turn_spec_hooks.py: thread discards_mcp_oauth, set only for a KAS session. kiro-cli reads the block off disk and gets no notice.

Backwards compatibility

Compatible: kiro-cli is unchanged, and on KAS the only removed field is one the backend already discarded.

Reader: KAS mapClientMcpServers -- chat -- never read oauth, so withholding it changes nothing the backend sees (test_kas_agents_mcp_oauth.py::TestProjection::test_the_oauth_block_is_not_sent)

Tests

test/test_kas_agents_mcp_oauth.py: the block is not sent; the log names keys and carries neither the client id nor the secret; a non-object block is withheld without its value; KAS names the server, kiro-cli and the toolsSettings-only flag name nothing; muted, registry-mode and registry-marked servers are not named; dotted and multiple names read back whole; other notices are unchanged.

Proof: PROVEN test/test_kas_agents_mcp_oauth.py::TestProjection::test_the_oauth_block_is_not_sent, test/test_kas_agents_mcp_oauth.py::TestProjection::test_the_log_names_keys_and_never_values, test/test_kas_agents_mcp_oauth.py::TestProjection::test_a_non_object_block_is_withheld_and_named_without_its_value, test/test_kas_agents_mcp_oauth.py::TestNotice::test_the_notice_names_the_server_and_the_supported_backend, test/test_kas_agents_mcp_oauth.py::TestNotice::test_a_dotted_name_and_several_servers_read_back_whole (head ee2af70)

Local gate: test/test_kas_*.py, every *contract* suite and the spec-hook and tool-approval suites, 9,277 passed. Two reds are not this PR: test_kas_project_agents.py::test_a_shadowing_project_spec_changes_nothing_about_the_user_agent is red on clean origin/main 7f8700a (and still on the rebased base), and test_kas_skill_scope.py::test_an_inheriting_agent_keeps_the_default_trees_and_gets_no_rule passes alone. black, flake8, mypy and semgrep clean on the changed files.

Manual verification

N/A — unit coverage sufficient: the change is a projection field drop plus one notice string, both asserted directly.

Pattern harvest

Not generalizable: a single backend-specific field that KAS's mapper drops; the existing spec-keys notice path now names it, and the KAS schema change is tracked in #27711.

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners November 2, 2026 04:01
@jeeshofone
jeeshofone requested a review from CrysisDeu November 2, 2026 04:01
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 2, 2026
Comment thread src/kiro_crew/acp/kas_agents.py Fixed
@jeeshofone
jeeshofone force-pushed the fix/kas-oauth-discarded branch 2 times, most recently from 55330be to 0a4b6bf Compare November 2, 2026 05:29
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 987bfc0e89a8c433df37e78f1f0ef2d69ac60c46 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 removed the readiness: action required A blocking check or review needs attention label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the fix sends one less field to KAS and adds one more key to the existing session-start notice for lost spec keys. Nothing new is exposed.

Notes

[DESIGN-REVIEWED] 987bfc0

Description read

[DESCRIPTION-READ] 4cb535535be43621029b4dbffd04d3039ff254ce303547200f69fef2b3e3f0eb

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 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 987bfc0e89a8c433df37e78f1f0ef2d69ac60c46 — 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

Every item points to a cause: KAS drops the oauth block, and the existing notice had no key for it. The only note is a second copy of a set that already exists.

Notes

  • Item 4 — duplicate of src/kiro_crew/acp/kas_agents.py:150: the new module adds _MANAGED = frozenset(KIROCREW_BIN_MCP_SERVERS), which is the same set as MANAGED_MCP_SERVER_NAMES. Grepping for frozenset(KIROCREW_BIN_MCP_SERVERS) finds 2 definitions, and _project_mcp_servers still reads managed = name in MANAGED_MCP_SERVER_NAMES right beside registry_withheld. Subtraction: delete _MANAGED and have registry_withheld read the one existing constant, moving it into the leaf if import direction requires.

What this change ships

Inventory (5 items) — 4 justified

Intent: a KAS user whose remote MCP server needs a pre-registered OAuth client learns that sign-in won't work there, and the client secret stays off the wire. This is a FIX.

  1. On KAS, a server's oauth block (which may hold a clientSecret) is no longer sent to the backend — justified
  2. The session-start notice now names each running server that has an oauth block and says kiro-cli supports sign-in — justified
  3. An INFO log says which server's oauth block was withheld, giving only its key count — justified
  4. The registry-withhold check moved into a shared predicate so the notice skips servers that never run — duplicate of kas_agents.py:150 (_MANAGED set)
  5. A new discards_mcp_oauth parameter is threaded through spec_keys_without_carrier and crew_fired_spec_hooks and set only for KAS sessions — justified

[FIRST-PRINCIPLES-REVIEWED] 987bfc0

Description read

[DESCRIPTION-READ] 53fdc48f906363e2a9c711867fcf45ed5b8179b6e410d0547817449db268e35a

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 987bfc0

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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 987bfc0

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

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

Comment thread src/kiro_crew/acp/kas_mcp_oauth.py Fixed
@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 2, 2026
@jeeshofone
jeeshofone force-pushed the fix/kas-oauth-discarded branch from 0a4b6bf to ade0a9d Compare November 2, 2026 06:00
@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 2, 2026
@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 2, 2026
@jeeshofone
jeeshofone force-pushed the fix/kas-oauth-discarded branch from ade0a9d to ee2af70 Compare November 2, 2026 14:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for human review, reviewed at ee2af70789f63fdba27db8903a83efc7da937008.

The change itself looks sound: withhold_oauth keeps the oauth block (and any clientSecret) off the KAS wire (kas_agents.py#L807), the log carries only a server name and a key count (mcp_oauth_projection.py#L77-L102), the earlier CodeQL logging alerts are gone on the current merge ref, and all checks are green. It is held because it changes credential handling on the backend wire, which is reserved for a human reviewer.

Before approval, please also fix the follow-up tracking: the body says Closes #27711, but #27711 is also where the KAS schema change (item 2), the #9971 kiro-cli-only follow-up (item 3) and the Design Review note "remove the withhold step when KAS carries oauth" live. Merging would close their only tracker. Either switch to Part of #27711, or open separate issues for those items and link them. The "What changed" bullet that says the log names key names through _loggable_key_names is stale; the code logs a count only.

AI findings judged non-blocking:

  • Design note 1 (notice can drift from the projection): the only extra projection skip is stub_server_names, which are command-wrapped servers; a remote url + oauth entry is not wrapped (kas_agents.py#L795-L803).
  • First Principles item 4 (discards_mcp_oauth duplicates translates_tools_settings): two named flags are a style choice with no behaviour cost.

— crew-pr-reviewer (r141)

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Both done in the PR description: the issue link is now "Part of #27711" so the issue stays open for the KAS schema change and the follow-ups, and the What changed bullet now says the log carries a fixed message with a key count only. No code change or push.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for human review, reviewed at b94550a1528bd3b94542b39dfc92046ee2cf7e17.

The code looks sound. withhold_oauth keeps the oauth block, and any clientSecret, off the KAS wire and logs only a fixed message with a key count (

def withhold_oauth(
projected: dict[str, Any],
*,
agent_id: str,
name: str,
logger: logging.Logger,
) -> None:
"""Pop *projected*'s ``oauth`` block and log only how many keys it had.
Withheld rather than sent to be discarded, because the block can hold a
``clientSecret``; that is also why it is not a discarded-entry key.
"""
oauth = projected.pop("oauth", None)
if not oauth:
return
# A fixed message and an integer only: nothing derived from the block's
# keys or values reaches the log.
count = len(oauth) if isinstance(oauth, dict) else 0
logger.info(
"agent %r: MCP server %r declares an oauth block (%d keys), which this "
"backend discards, so its sign-in cannot work here; the kiro-cli "
"backend supports it.",
agent_id,
name,
count,
)
). The new split of the env-literal helpers into acp/kas_env_literals.py is a byte-identical move, and the NON_EGRESS_REDACTION_MODULES row moves with it; kas_agents.py no longer calls the redactor directly, so no coverage is lost (
"acp/kas_env_literals.py",
). All checks are green. It stays held because it changes what credential material reaches a backend and what is logged about it, which is reserved for a human reviewer.

AI findings judged non-blocking:

To clear: a maintainer reviews the credential-handling change and approves.

— crew-pr-reviewer (r145)

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 4, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97]

Review note at b94550a: the oauth-reporting change itself looks correct to me, and nothing in it is on main yet. The PR now conflicts with main because #26786 already landed the same kas_env_literals.py extraction and the matching security_posture.py allowlist swap. On rebase, keeping main's copy of that file and dropping the duplicated extraction and re-export block should resolve all three conflicts without losing any of the oauth fix.

Small things to consider while rebasing: pin oauth's absence in _KAS_WIRE_SCHEMA_KEYS the way type is pinned, so an upstream schema change goes red here; "1 keys" in the log line; and the test name test_the_log_names_keys_and_never_values asserts that key names are never logged.

AI-assisted, approved by bolichen97

@jeeshofone
jeeshofone force-pushed the fix/kas-oauth-discarded branch from b94550a to a678f4e Compare November 4, 2026 12:04
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto main as a678f4e. Kept main's kas_env_literals.py (from #26786) and its security_posture.py entry, and dropped this PR's duplicate extraction and the _PLAIN_WORD / _RELAYABLE_BOOLEANS / _credential_shaped_env_key re-export block. The PR now changes only the oauth reporting: mcp_oauth_projection.py, its call sites in kas_agents.py, spec_hooks.py, tool_approval.py, turn_spec_hooks.py, and test/test_kas_agents_mcp_oauth.py. kas_agents.py is 1,979 lines.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a678f4e
  • What rule changed: none. After the rebase this PR no longer touches src/kiro_crew/security_posture.py. The NON_EGRESS_REDACTION_MODULES swap from acp/kas_agents.py to acp/kas_env_literals.py landed on main in fix(kas): say which MCP servers start without their env on KAS #26786, and this head keeps main's line unchanged.
  • Before / after: identical to main for every sensitive file.
  • Risk: none added. The oauth block and any clientSecret stay off the KAS wire, and the log line carries a fixed message plus an integer key count (pinned by test_the_log_names_keys_and_never_values).

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 4, 2026
… backend

KAS rebuilds each remote MCP entry from url, headers, env and timeout only,
so a pre-registered OAuth client never arrives and sign-in cannot start,
with nothing logged and nothing shown. Withhold the block from the wire (it
can hold a client secret), log its key names only, and name the server in
the existing session-start notice for spec keys this backend never
receives, saying sign-in will not work here and kiro-cli supports it.

Part of #27711
@jeeshofone
jeeshofone force-pushed the fix/kas-oauth-discarded branch from a678f4e to 987bfc0 Compare November 4, 2026 15:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 4, 2026

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

[operator: bolichen97] Approving at 987bfc0.

No blocking issue found. On KAS the oauth block is now kept off the wire (it is a field KAS drops anyway), the log carries only the server name and a count, and the user is told sign-in will not work there. The kiro-cli path is unchanged. The earlier conflict I noted is gone: this head no longer touches kas_env_literals.py or security_posture.py. Nothing equivalent is on main.

Non-blocking suggestions:

  • The log reads "(1 keys)"; pluralize or say "key count N".
  • test_the_log_names_keys_and_never_values asserts key names are not logged, and the module docstring in test/test_kas_agents_mcp_oauth.py still says it logs key names. Both could be renamed or reworded.
  • Pinning oauth's absence in the KAS wire schema keys would make the withhold step go red once KAS starts carrying oauth.
  • servers_with_discarded_oauth does not skip stub server names the way the projection does. Harmless today, but the notice could drift.

This still needs the Sensitive Change sign-off from another maintainer.

AI-assisted, approved by bolichen97

@bolichen97
bolichen97 merged commit 7a5bc2d into main Nov 4, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/kas-oauth-discarded branch November 4, 2026 20:50

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

Maintainer decision (security sign-off): not adopted as written. The maintainer's rule for security changes is that we do not raise security strictness, so the maintainer will not add the new restriction here: stripping a remote MCP server's oauth block from the KAS projection before it is sent.

Reviewed at 987bfc0. Please drop the tightening part and keep the rest:

  • Drop: the withhold_oauth call in _project_mcp_servers and the withhold_oauth helper in mcp_oauth_projection.py, plus the tests that pin the block being removed (test_the_oauth_block_is_not_sent, test_a_non_object_block_is_withheld_and_named_without_its_value, and the log tests that only exist for the pop).
  • Keep: the session-start notice that names each server whose sign-in will not work on KAS (spec_keys_without_carrier with discards_mcp_oauth, oauth_lost_keys, oauth_servers_in, _spec_keys_notice), and the registry_withheld refactor. These tell the user something true without changing what is sent.

If you would rather not keep the notice on its own, closing the PR is fine too. Thank you for the careful work on this.

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.

4 participants