Repository navigation
feat(mcpbroker): trust AS-1 for ID-JAGs only at AS-2 - #3002
Conversation
AS-2 trusted AS-1 for both assertion types, so it redeemed plain RFC 7523 assertions from AS-1 without client authentication. It now accepts ID-JAGs only. Key fetches from a private or loopback address are an explicit trust setting instead of always on. Tests cover the step (8) refusals and reason codes, concurrent single use, a replay-store outage, and the vMCP's rejection of bad gateway tokens, and pin two shortcuts: self-exchange of a gateway token, and the vMCP accepting typ JWT or none. Part of #2533. Co-authored-by: Mecatl <[email protected]>
…AS-1's audience Point the vMCP typ shortcut at stacklok/toolhive#7345. Replace the stale note that AS-1 accepts its token endpoint as a client assertion's audience with a test that it refuses it. Part of #2533. Co-authored-by: Mecatl <[email protected]>
AS-2 issued gateway tokens with ToolHive's default typ JWT, not the at+jwt that step (8) requires. Mecatl now opts in when AS-2 is set up, so nothing changes with the identity broker off. The replay-store outage test now also shows that a gateway token issued before the outage still works at the vMCP. The vMCP's missing typ check is recorded in the design's ToolHive work list (stacklok/toolhive#7345). Part of #2533. Co-authored-by: Mecatl <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
LGTM. Checked against #2533 and the step (8) design, and ran it locally.
Design fit. This matches the parts of #2533 that v0.69.0 allows: ID-JAG-only trust (acceptedAssertionTypes: [id_jag]), the private-address key fetch moved out of the hardcoded value into the trust, at+jwt gateway tokens, and the "Done when" refusal list. The deferred items line up with what waits on toolhive#7247. The new ToolHive work-list row for the vMCP typ check (toolhive#7345) fills a real gap in the ledger.
Existing users. Nothing changes with the identity broker off, because as2 needs BrokerClient. With it on, WithAccessTokenType also retypes the broker's per-session OAuth login tokens, not just gateway tokens. I checked the consumers. Only the in-process vMCP reads them, and its validator refuses only an ID-JAG typ. The identity broker only reads typ on ID-JAGs. ToolHive's token exchange accepts at+jwt subject tokens, and the pinned self-exchange test shows it. Production AS-2 still trusts no issuer, so AllowPrivateAddresses defaulting to false has no production effect today.
Ran locally:
go test -racepasses on./internal/adapter/mcpbroker/...and./internal/identitybroker/....go testpasses on./internal/app(full package) and./cmd/mecak8s.- Mutation check: dropping
AcceptedAssertionTypesfails exactly the four plain-JWT cases inTestAS2RefusesRedemptionsOutsideItsConfiguration.
One sequencing note, non-blocking. The self-exchange shortcut lets the broker client turn a gateway token into a fresh one with a new jti, up to the original's expiry. That's harmless now. Once #2727 and toolhive#7062 make a gateway token single-use per call, it could get around the single-use rule unless the marker refusal (toolhive#7247 / #6404) lands first. Worth stating that ordering on #2727, or checking that the exchanged token can't carry the call's authorization_details.
jhrozek
left a comment
There was a problem hiding this comment.
Approving. The ID-JAG-only trust, the at+jwt type, and making the private-address key fetch opt-in all do what the description says; I checked them against ToolHive v0.69.0, and production can't turn the private-address fetch on.
Four things to fix, inline: the #7345 shortcut needs a Mecatl-side step to go away, one test checks lifetime rather than age, there's no bad-signature redemption case, and the refusal tests check the reason code but not the cause.
Address review of #3002: - AS-2 limits an ID-JAG's lifetime, not its age, so test a lifetime over the maximum instead of an old iat. - Add an ID-JAG with AS-1's issuer and key ID signed by another key. - Check ToolHive's hint for each refusal, since many share the invalid_assertion reason, and require a gateway token on the one concurrent success and none on each refusal. - The vMCP typ shortcut ends only when Mecatl pins stacklok/toolhive#7345 and turns its check on for AS-2. Part of #2533. Co-authored-by: Mecatl <[email protected]>
|
@rdimitrov on the sequencing note: the ordering is already safe on the ToolHive side. v0.69.0 refuses an RFC 8693 exchange whose subject token carries I've added a note on #2727 to extend |
Part of #2533. This covers what the pinned ToolHive release (v0.69.0) allows before stacklok/toolhive#7247 turns on subject resolution. The rest of #2533 waits on that release.
Changes
acceptedAssertionTypes: [id_jag](Gate ID-JAG by issuer assertion types toolhive#6678). Until now, AS-2 redeemed plain RFC 7523 assertions from AS-1 with no client authentication. It now refuses them, with or without client authentication.at+jwt(RFC 9068), as step (8) requires. ToolHive's default istyp: JWT; Mecatl now opts in withrunner.WithAccessTokenType, only when AS-2 is set up.as2trust.Trust.AllowPrivateAddressesreplaces the hardcodedAllowPrivateIPs: true. Every test that uses a loopback AS-1 now sets it explicitly, and a new test checks that the same trust is refused when AS-2 is built without it.implementation.md("Credential verification"):invalid_assertion,subject_unknown), and each refusal's hint is checked, since many shareinvalid_assertion;exp - iat), not its age;server_error, and a gateway token issued before the outage still works at the vMCP;401 invalid_tokenfor a gateway token with another issuer, another audience, a bad signature, an ID-JAGtyp, or an expired one.typJWTor notyp, not onlyat+jwt. Removed once Mecatl pins a ToolHive release with vMCP: optionally refuse JWT access tokens whose typ is not at+jwt (RFC 9068) toolhive#7345 and turns its check on for AS-2; the design's ToolHive work list has a row for it.Not in this PR (waits on stacklok/toolhive#7247 or later)
resolve.actor_deniedandresource_deniedrefusals: AS-2 produces them only in subject moderesolve.NonFatalSecondaryLegs(Make secondary chain legs optionally non-fatal toolhive#7311, unreleased).API compatibility
No wire change. Production AS-2 still trusts no ID-JAG issuer. The
at+jwttype changes only tokens that AS-2 issues and mecak8s's own vMCP consumes in process; no client sees them.Testing
go testpasses for./internal/adapter/mcpbroker/...,./internal/identitybroker/...,./internal/app, and./cmd/mecak8s. The AS-2 tests also pass with-race.AcceptedAssertionTypes, the four plain-JWT cases fail;AllowPrivateIPsforced to true, the private-address test fails;at+jwtoption, the gateway-tokentypassertion fails.golangci-lintreports no issues on the touched packages, andtask docs:checkpasses.task docsstops at the gRPC reference step becausebufisn't installed locally; this PR changes no contracts.