Repository navigation
fix(security): accept a compact-JWS client_id on an approved OAuth endpoint - #12796
zachary-povey wants to merge 1 commit into
Conversation
…dpoint An MCP server whose dynamic client registration issues a client_id shaped like a compact JWS could not be authorized at all. The fixed-credential signature matches any eyJ-prefixed three-segment base64url run, and it was evaluated against the raw URL before endpoint approval was known, so the banner failed closed with no configuration remedy: the operator endpoint extension never took effect because the code path did not reach the endpoint check. RFC 7591 constrains the format of a registered identifier not at all, so this affects any provider that issues a structured one. Evaluate the signature against the same target the markerless scan uses, and blank a client_id there only when it keeps the compact-JWS shape at an exact approved endpoint. The shape test requires base64url and exactly two separators and re-checks every decoded form, so a standard-base64 run or a double-encoded payload cannot ride it. The exfil warning's own signatures stay unconditional apart from that one identifier -- they remain the backstop that catches a marker hidden inside an entropy-bearing parameter such as state. Add ClickUp's authorization endpoint, taken from its RFC 8414 metadata, and pin the carve-out's boundaries: each rejection case in the new test class differs from the accepted URL in exactly one way.
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS security.md still promises fixed-credential scanning stays unconditional at approved endpoints; this PR falsifies that guarantee without updating the owning spec. WatchThe spec's oauth-extension passage ( [DESIGN-REVIEWED] 0112747 |
GPT 5.6 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/security/exfil.py:1237 -- JWS-shaped client IDs bypass credential scanning Adjudication (Opus 4.8) — is blocking on each finding proportionate?The adjudicable block is empty (0 findings). One fenced finding, F1. F1 — harm rung: UNBOUNDED (fixed-credential exposure, the class the OAuth exfil scanner exists to catch). Conditions I confirmed from code opened this run: (a) at an approved endpoint the credential precheck now scans Rarity/recovery for a FLAG: the condition combination is not extreme — a three-segment [ADJUDICATION] 0112747 total=0 uphold=0 downgrade=0 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Confirm ClickUp's RFC 8414 metadata names What this change shipsInventory (5 items) — 5 justifiedIntent: let sign-in complete for an MCP provider whose dynamically registered
[FIRST-PRINCIPLES-REVIEWED] 0112747 |
Opus 4.8 Review (fork) — 🔴 changes requested (blocking)Reviewed BLOCKING — the JWS [BLOCK-MERGE] 0112747 BLOCKING — src/kiro_crew/security/exfil.py:1120 ( Input [OPUS-REVIEWED] 0112747 |
Security Scope Review (fork) — 🟡 CONCERNSWhich legitimate operations does the reviewer's own judgement; no confirmed regression Scope-Verdict: CONCERNS TIGHTENING: No shell-side mechanism got stricter — every hunk in ADJUDICATED: 9 candidates submitted, 0 confirmed newly-refused handed to this review. The candidates cover the maintainers' daily operations in the touched area (running PLATFORM COVERAGE: Candidates were written in three spellings. UNADJUDICATED: The entire change lives in a URL gate the classifier cannot see: [SCOPE-REVIEWED] 0112747Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR was flagged for automated triage with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: the blocking finding is real and reproducible, and its fix sits inside your stated intent rather than against it. GPT 5.6 ( The rest is mechanical. One thing I will not decide for you: after the narrowing above, a genuine JWT in If you'd prefer I don't touch this PR, add the |
|
PR triage (automated, evidence-based): closing as DUPLICATE of #16816 #16816 (open PR, not an issue) re-lands this PR's commit on a clean What I checked, at head
#16816 closes these cases but has its own open security blocks; see its maintainer handoff. Please continue there. If #16816 is abandoned, this PR can be reopened, but it would need the narrowing above and a rebase first. |
Problem / Motivation
An MCP server whose dynamic client registration issues a
client_idshaped like a compact JWS cannot be authorized at all, and no configuration can fix it.What the user observes is the fail-closed banner — "authentication failed: URL contained credential or exfiltration pattern" — with no URL in either the log line or the banner meta, so the cause is not diagnosable from inside the product.
ClickUp's MCP server is the concrete case. Its DCR mints
mcp-client-eyJ…, whose payload declares"tokenType":"jwt_client_id". Two URLs identical but for the shape of that one parameter:client_idfixed_credential_raw(paramclient_id)Why it matters
The provider is unusable — sign-in cannot be completed by any route — and the operator escape hatch does not help. A correct, byte-exact
oauth_endpoints.jsonentry produces zerooauth_endpoint_extension_usedevents insecurity_events.jsonl, not because the file is rejected but because the code path never consults it. Diagnosing that took reading the gate's source and extracting the authorize URL from a different client; a user cannot get there from the product.RFC 7591 places no constraint on the format of a dynamically registered
client_id, so this is not ClickUp-specific: it hits any provider that issues a structured identifier.kiro-cliis unaffected because it has no equivalent gate, which makes the failure look like a Kiro Crew regression to a user who has the same server working elsewhere.What changed (motivation → approach → change)
Symptom — a compact-JWS
client_idis rejected at an endpoint that is otherwise approved.Root cause —
_contains_fixed_credentialmatches anyeyJ-prefixed three-segment base64url run, which is the JWT/JWE signature. Indiagnose_oauth_url_credentialit was evaluated against the raw URL before endpoint approval was computed, so it short-circuited withfixed_credential_rawand_approved_oauth_authorization_endpointwas never reached. The identifier authenticates nothing on its own and is being sent to the very issuer that minted it, so the match is a false positive — but one the rule could not see, because it ran before the information that would exempt it.Change — evaluate the signature against the same target the markerless scan uses, and blank a
client_idthere only when it keeps the compact-JWS shape at an exact approved endpoint._oauth_client_id_is_jws_shapedrequires base64url (so a standard-base64+//run cannot ride it) and exactly two separators (so a singly dotted identifier does not match), and re-validates every decoded form — the same decode-until-stable discipline_oauth_entropy_value_is_protocol_shapedalready applies, so a double-encoded payload cannot smuggle a credential-shaped run into the blanked value.The carve-out is applied at all three sites that judge the URL: the pre-check, the markerless scan target, and the payload handed to
_exfil_url_warning. Missing any one of them only moves the rejection to a different rule, which is what the first two drafts of this change did.mcp.clickup.com+/oauth/authorizeis added to_OAUTH_AUTHORIZATION_ENDPOINTS, taken from ClickUp's RFC 8414 metadata athttps://mcp.clickup.com/.well-known/oauth-authorization-server, reached by RFC 9728 discovery fromhttps://mcp.clickup.com/mcp.What this deliberately does not widen.
_exfil_url_warning's credential signatures stay unconditional for everything except that one identifier — they remain the backstop that catches a marker hidden inside an entropy-bearing parameter. An earlier draft reused the general scan target there and silently removed that backstop; the narrowing is deliberate and is pinned by a test.The tradeoff, stated plainly: a genuine JWT placed in
client_idat an approved endpoint is now exempt from credential scanning. The destination is a code-owned or operator-vouched consent endpoint, and this is the same tradeoff already accepted forstateandnonce. Reviewers should weigh that explicitly rather than take it as free.Backwards compatibility
Compatible: the change only accepts input that main rejects. No field becomes required, no validator is tightened, no type is narrowed, and no key is renamed or removed — every URL main accepts today is still accepted, with identical diagnostic rule names for every input that is not an approved-endpoint URL carrying a JWS
client_id.Tests
test/oauth_url_corpus.pygains a ClickUp entry — the regression guard for a provider whose identifier carries the JWT signature shape. It fails on unpatched main (both corpus tests,test_corpus_url_not_flagged_as_credentialandtest_corpus_url_renders_banner) and passes with the fix.TestJwsClientIdCarveOutintest/test_mcp_oauth_banner.pylocks in the boundaries: 13 cases, 2 accepting and 11 rejecting, each rejection differing from the accepted URL in exactly one way.httpscheme, case-variant parameter name.statebeside a valid JWSclient_idis still caught, and so is one in an unknown parameter.All JWS segments in the tests are synthetic; the payload decodes to
{"tokenType":"jwt_client_id","iss":"example-mcp-server"}and the signature is filler.Manual verification
Reproduced the original defect and the fix against a real ClickUp authorize URL shape with
KIROCREW_HOMEpointed at an empty directory, confirming the accept comes from the builtin allowlist and not from a localoauth_endpoints.json. Verified the rejection moved through each gate in turn while the carve-out was incomplete (fixed_credential_raw→exfil_fixed_credential→credential_scan_fixed_raw→ accepted), which is what established that all three sites need it.End-to-end banner rendering is covered automatically by
test_corpus_url_renders_banner, which asserts the live banner carries a clickableoauth_urlrather than a rejection.Not exercised against ClickUp's live consent flow: that needs a ClickUp account and a real DCR round-trip.
Related Issues
None — no issue was filed for this; the defect was diagnosed and fixed directly. Happy to open one first if maintainers prefer that order.
Pattern harvest
Rule candidate: review-prompt
Pattern: an unconditional signature check evaluated before the approval context that would scope it — and, once a carve-out exists, applied at only some of the sites that judge the same input. Both halves showed up here: the fixed-credential check ran ahead of
approved_endpoint, and the first two drafts fixed one site at a time while the rejection simply reappeared under the next rule name. A reviewer prompt worth adding: when a gate gains a conditional exemption, ask which other call sites evaluate the same input, and whether the ordering lets the exemption be seen at all.Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Verification run locally:
pytest12,459 passed / 16 skipped (81 related backend files viascripts/local-gate.py);vitest36,848 passed (full frontend suite) and 8,718 passed (related subset);tsc -b,isort,flake8clean;mypy1.14.1 (matching thepyproject.tomlpin)Success: no issues found in 1685 source files;scripts/local-gate.py --base origin/mainexit 0.The full 126,672-test backend suite was not run locally:
xdist_budget.pyestimates ~16 GiB per worker and this host had 8–11 GiB of 36 GiB free, so it clamped to a single worker and the run was heading for hours. The diff-scoped gate states the full suite is deferred to CI by design.Rebased onto
cbdfa743e; none of the intervening commits touch the changed files.Contribution License Agreement
The template carries a placeholder here pending OSPO wording, so there is nothing to affirm yet. Happy to sign whatever is required once it is published.