Repository navigation
fix(connections): let Crew's own DCR client_id through its consent gate - #36189
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the exemption only applies to Crew's own consent link, and only when the link carries a single [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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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
What this change shipsInventory (3 items) — 2 justifiedIntent: an owner-added MCP server that issues a long mixed-case DCR
[FIRST-PRINCIPLES-REVIEWED] 70394ca Description read[DESCRIPTION-READ] a80d9bf9bafa752015c0da40a87c5a5e06bdbf8ab77aa2df366026e8dbea75ae 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: |
Code change approver recommendation: ApproveWhy: 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.
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 The tests cover the end-to-end 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 |
d24636b to
9c704c1
Compare
|
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. |
9c704c1 to
036260f
Compare
036260f to
a9139b1
Compare
|
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. |
a9139b1 to
70394ca
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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 thestart_mint_rowgate reads) could add one sentence about Crew's own DCRclient_id. That keeps the spec in step with the code._vetted_linkre-parses a link Crew just built. Holding the registeredclient_idat the same fixed value already used forstateand the PKCE challenge (viadataclasses.replaceon the plan) would do the same job without a query parser.- An end-to-end case with
oauth.clientIdset to a secret-shaped id that assertsmint_url_rejectedwould pin the owner-supplied refusal through the realprepare_custompath. Today it is pinned only on a syntheticPlan.
Problem / Motivation
Goal: An owner-added MCP server whose authorization server gives Crew a long mixed-case
client_idby Dynamic Client Registration (PostHog) can sign in through Crew-owned OAuth.With the
crew_oauthpreview on, Connect on such a server endsfailedwithmint_url_rejected. The consent-link gate logsrule=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_idat endpoints listed inoauth_endpoints.json, and a discovered endpoint is not one.Not a goal
security/exfil.py,security/exfil_oauth.py) or to whichclient_idshapes it accepts at any endpoint.dashboard/chat_turn/mcp_session.py, thechat_utils_display.pyre-gate,mcp_oauth_discovery.py) or the kiro-cli/KAS mint paths.oauth.clientIdis 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_idin 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_idpair. It drops the pair only when all of these hold; otherwise the gate reads the link as before:client_idEvery other parameter stays in the scan.
crew_oauth_dcr.Plangains aregisteredflag, set on the DCR reuse/register path only, so Crew can tell its own registration from an owner'sclientId._start_mint_rowinconnections/crew_oauth.pyis 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 reacheswaitingwith 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 secondclient_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:randomlyand under xdist-n 4with 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_rowand 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