Skip to content

fix(connections): let Crew's own DCR client_id through its consent gate - #36189

Merged
iamwhatever merged 1 commit into
mainfrom
fix/crew-oauth-registered-client-id
Nov 13, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/crew-oauth-registered-client-id

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An owner-added MCP server whose authorization server gives Crew a long mixed-case client_id by Dynamic Client Registration (PostHog) can sign in through Crew-owned OAuth.

With the crew_oauth preview on, Connect on such a server ends failed with mint_url_rejected. The consent-link gate logs rule=credential_scan_bare_secret_raw parameter=client_id length=40.

Why it matters

Every owner-added server whose AS issues a 40-character mixed-case DCR id cannot be connected at all through Crew-owned OAuth; there is no setting that clears it, because the gate only relaxes client_id at endpoints listed in oauth_endpoints.json, and a discovered endpoint is not one.

Not a goal

  • No change to the credential gate itself (security/exfil.py, security/exfil_oauth.py) or to which client_id shapes it accepts at any endpoint.
  • No change to the ACP/harness consent banner path (dashboard/chat_turn/mcp_session.py, the chat_utils_display.py re-gate, mcp_oauth_discovery.py) or the kiro-cli/KAS mint paths.
  • An owner-supplied oauth.clientId is not exempted. A possible follow-up could exempt it the same exact-value way.

What changed (motivation → approach → change)

Crew builds its own consent link, and the client_id in it is the one the vendor's DCR answer gave Crew. That id is public, but its shape matches the bare-secret scan, so Crew refused its own link.

Crew now hands the gate its link without that one client_id pair. It drops the pair only when all of these hold; otherwise the gate reads the link as before:

Condition Else
the sign-in uses Crew's own DCR registration owner-supplied id: scanned
the link has exactly one client_id two or more: scanned
its decoded value equals Crew's registered id other value: scanned

Every other parameter stays in the scan. crew_oauth_dcr.Plan gains a registered flag, set on the DCR reuse/register path only, so Crew can tell its own registration from an owner's clientId.

_start_mint_row in connections/crew_oauth.py is the only place that gates the Crew-owned consent link; the mint-row view served to the card returns the stored URL without re-gating it, so emit and redraw agree.

Backwards compatibility

Compatible: a link the gate admitted before is still admitted, since dropping a pair only removes text from what is scanned, and every other caller of the gate is unchanged.

Removes nothing: no path, key, record or public function is taken away; the gate only stops reading one pair Crew itself put in its own link.

Tests

test/test_crew_oauth_custom_servers.py:

  • test_a_custom_server_with_a_long_dcr_client_id_reaches_consent: a DCR id of 40 mixed-case characters reaches waiting with that id in the consent link.
  • test_crews_registered_client_id_passes_only_on_its_own_sign_in: Crew's link passes; the same URL through the banner gate is still refused.
  • test_everything_but_crews_own_client_id_is_still_scanned: a different value, a second client_id, a secret-shaped other parameter, and an owner-supplied id are each still refused.

Proof: PROVEN test/test_crew_oauth_custom_servers.py::test_a_custom_server_with_a_long_dcr_client_id_reaches_consent (head d24636b)

Determinism: the module ran green repeatedly under -p no:randomly and under xdist -n 4 with the other Crew OAuth suites (697 passed); no clock, network or ordering dependence (vendor answers are in-memory, the discovered-endpoint table is replaced per test).

Manual verification

N/A — unit coverage sufficient: the end-to-end test drives the real start_mint_row and the real gate against an in-memory vendor.

Related Issues

Closes #36171

Sibling sweep

Swept: git grep -n "oauth_url_contains_credential" -- src/
Sibling: src/kiro_crew/connections/mint.py -- not affected -- harness consent link from kiro-cli, not Crew-built
Sibling: src/kiro_crew/connections/mint_kas.py -- not affected -- harness consent link from KAS, not Crew-built
Sibling: src/kiro_crew/connections/warm.py -- not affected -- harness premint links, not Crew-built
Sibling: src/kiro_crew/dashboard/chat_turn/mcp_session.py -- not affected -- ACP banner path, unchanged by design
Sibling: src/kiro_crew/dashboard/chat_utils_display.py -- not affected -- ACP banner re-gate, unchanged by design

Pattern harvest

Not generalizable: the exemption depends on Crew having built the link from its own registration, which only the Crew-owned sign-in knows.

Checklist

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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 12, 2026 23:25
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 70394ca7bd9bcd15568a3691f03bd6672a31110d 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 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the exemption only applies to Crew's own consent link, and only when the link carries a single client_id equal to the id Crew registered by DCR. The gate and every other caller are unchanged.

[DESIGN-REVIEWED] 70394ca

Description read

[DESCRIPTION-READ] d806df69dcd523e855f2cb16268d7f1d587d47c2a1b05f8f61028f82b6171ff6

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 70394ca7bd9bcd15568a3691f03bd6672a31110d — 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. The exemption is tied to one exact value at the one caller that knows it built the link, and the defect is tracked in #36171.

Notes

  • Item 3 — symptom-level: the cause is a gate that scans a link Crew built itself as if it came from outside. The fix strips that one value at the caller, and the description defers the second case of the same cause: "An owner-supplied oauth.clientId is not exempted." That leaves 1 unfixed sibling (the owner-supplied id path, crew_oauth_dcr.py:604 Plan(client, scope)). This is declared and deferred, so it is not a demand.

What this change ships

Inventory (3 items) — 2 justified

Intent: an owner-added MCP server that issues a long mixed-case DCR client_id (PostHog) can be connected through Crew-owned OAuth. FIX.

  1. Connect on such a server now reaches consent instead of failing with mint_url_rejected. — justified
  2. Crew's DCR plans now record whether Crew registered the client itself (Plan.registered, 1 consumer: _vetted_link; grepped \.registered\b). — justified
  3. An owner-supplied clientId of the same shape is still refused at a discovered endpoint. — symptom-level: the same cause is deferred for the owner-id path

[FIRST-PRINCIPLES-REVIEWED] 70394ca

Description read

[DESCRIPTION-READ] a80d9bf9bafa752015c0da40a87c5a5e06bdbf8ab77aa2df366026e8dbea75ae

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 70394ca

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

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

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 70394ca

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

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The change is narrow and correct. _vetted_link removes one client_id pair from what the credential gate scans, and only when three things hold: plan.registered is true, the link has exactly one client_id, and its decoded value equals Crew's own registered id. Otherwise the gate reads the link unchanged.

registered=True is set only on the three _reuse_or_register returns. The owner-supplied Plan in prepare_custom keeps the default False. When _dcr is None (the card path without DCR), _vetted_link returns the URL as is.

The exempt value comes from the authorization server's own DCR answer. It goes back to that server's own authorize endpoint, which comes from the same discovery document, so no user secret can leak through it.

The emitted URL is built from the same _dcr plan (crew_oauth.py:688). The mint-row view serves the stored URL without re-gating it. warm.py, mint.py, mint_kas.py and the ACP banner callers of the gate are untouched.

The tests cover the end-to-end waiting state and four negative cases: a different value, a second client_id, a secret-shaped other parameter, and an owner-supplied id. Each would fail without the change.

The f

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 70394ca7bd · 128 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@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 13, 2026
@iamwhatever
iamwhatever force-pushed the fix/crew-oauth-registered-client-id branch from d24636b to 9c704c1 Compare November 13, 2026 01:13
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/client_permissions.py and src/kiro_crew/session_allocation_parts/get_or_create.py (import overlap) since this head went green (0828c8a -> 52cc80f); new head 9c704c1. Related Crew OAuth and OAuth URL gate tests pass locally (650 passed). CI re-running.

@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 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Backend Tests shard 8 (Linux + Windows) and Coverage Gate are red on test/test_reply_format_once.py::TestEveryMessageWhereTheBlockCannotBeTakenOut::test_the_table_names_every_selectable_harness. It reproduces on a clean origin/main (a02e90c), so it is main's red, tracked in #36279 with fix PR #36290. This PR waits for that fix and will rebase onto it.

@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 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased onto main b7a4e1e, which now carries the fix for the inherited shard-8 red (#36290, closes #36279); new head 036260f. The previously failing test_the_table_names_every_selectable_harness and the related Crew OAuth / OAuth URL gate tests pass locally (651 passed). CI re-running.

@iamwhatever
iamwhatever force-pushed the fix/crew-oauth-registered-client-id branch from 9c704c1 to 036260f Compare November 13, 2026 04:19
@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 13, 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 13, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 13, 2026
@iamwhatever
iamwhatever force-pushed the fix/crew-oauth-registered-client-id branch from 036260f to a9139b1 Compare November 13, 2026 07:38
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/session_allocation_parts/get_or_create.py (import overlap) since this head went green (b7a4e1e -> 72b62cf); new head a9139b1. Related Crew OAuth and OAuth URL gate tests pass locally (650 passed). CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 labels Nov 13, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased onto main 57ebed3, which carries the fix for the inherited mypy red in src/kiro_crew/cli_commands_memory.py (#36457), and to clear a conflict in test/test_crew_oauth_custom_servers.py (both sides appended tests; kept both, main's lines untouched). New head 70394ca. mypy/flake8 clean on the touched files; related Crew OAuth and OAuth URL gate tests pass locally (651 passed). CI re-running.

@iamwhatever
iamwhatever force-pushed the fix/crew-oauth-registered-client-id branch from a9139b1 to 70394ca Compare November 13, 2026 08:01
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 13, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) November 13, 2026 09:36

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head 70394ca. We read the whole diff (3 files, one commit). We checked that Plan.registered is set only on the three _reuse_or_register returns, and that the owner-supplied Plan in prepare_custom keeps False. We confirmed that every other caller of oauth_url_contains_credential is unchanged. A mutation run showed that reverting the call site hunk, or dropping the staged registered=True, fails test_a_custom_server_with_a_long_dcr_client_id_reaches_consent. Done well: the exemption needs positive provenance, exactly one client_id pair, and an exact decoded match. The tests pin both sides, including a check that the same URL read whole is still refused.

Security: this change narrows what the credential gate reads on Crew's own consent link, and only for Crew's own link. The exempt value is the client_id that the authorization server returned in its own DCR answer, and the link sends it back to that same server's authorize endpoint. So no local secret leaves through that pair. In every other case the exemption fails closed: no plan, an owner-supplied id, an empty id, zero or two client_id pairs, or a value that differs from the registered id. Every other parameter is still scanned, and the Kiro CLI banner path still reads the link whole.

Optional:

  • docs/system-specs/modules/connections.md (the paragraph on what the start_mint_row gate reads) could add one sentence about Crew's own DCR client_id. That keeps the spec in step with the code.
  • _vetted_link re-parses a link Crew just built. Holding the registered client_id at the same fixed value already used for state and the PKCE challenge (via dataclasses.replace on the plan) would do the same job without a query parser.
  • An end-to-end case with oauth.clientId set to a secret-shaped id that asserts mint_url_rejected would pin the owner-supplied refusal through the real prepare_custom path. Today it is pinned only on a synthetic Plan.

@iamwhatever
iamwhatever merged commit 72e9612 into main Nov 13, 2026
134 of 145 checks passed
@iamwhatever
iamwhatever deleted the fix/crew-oauth-registered-client-id branch November 13, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crew-owned OAuth refuses its own DCR-registered 40-char client_id

2 participants