Repository navigation
feat(identitybroker): fix the AuthorizeCall shape and run the checks before a grant - #2785
Conversation
…before a grant AuthorizeCallRequest carries the run, method, server, tool, arguments hash, and rejected attempt; Authorization adds the expiry and attempt ID. The broker checks the session, a rejection report, the grant (no_grant), the credential, and the gateway's servers in design order, recording each refusal; a call passing every check is still denied until steps (7) and (8). Co-authored-by: Mecatl <noreply@mecatl.dev>
e903f3e to
a9d9519
Compare
jhrozek
left a comment
There was a problem hiding this comment.
Reviewed the second commit (e903f3e09e) only; the first one is #2784, already merged.
The request and response fields and the check order match credentials-and-lifecycle.md as amended in #2779. Every path ends in a refusal, and a failed record can't turn a refusal into an allow. The shortcuts are marked in the code and match the PR description. I also read the same code on #2786: it consumes the retry allowance under the lock, checks the session again before each external step, and saves the records before it returns a token. So the parts this PR leaves unwired are handled there.
Please rebase onto main before merging. The branch still has the design text from before #2779. For example, audit.md:45 on this branch says "The broker does not inspect V", while the GatewayToken reference in DecisionRecord follows the amended text on main. Anyone who checks the code against this branch's copy of the docs will see contradictions that aren't real.
Three inline comments. Only the first one would change something that's hard to change later.
| At time.Time | ||
| SessionID string | ||
| Workload Workload | ||
| // Owner is the broker session's verified owner, or the owner mecak8s |
There was a problem hiding this comment.
Owner holds the verified owner when the session has one, and otherwise the owner mecak8s reported. Nothing in the record says which one it is.
This matters for refusals recorded before the grant check: a closed session, an unknown rejected attempt, and no_grant itself. For example, a session opened without the user's access token reports alice. A call in it gets no_grant, and the record says Owner: alice, exactly like a record from a session where the broker verified alice.
audit.md:39 (on main) requires each subject to be marked verified or reported:<component>. Once #2541 turns these records into audit events, it can't recover the difference. Could you add OwnerVerified bool, set from s.verifiedOwner != nil in decisionRecord? It's one field now. After #2541 it would be a change to the record format.
There was a problem hiding this comment.
Added DecisionRecord.OwnerVerified (set from s.verifiedOwner != nil) in #2794, tested on a verified and a tokenless session.
| } | ||
| } | ||
|
|
||
| func TestAuthorizeCallUnroutedServerIsDenied(t *testing.T) { |
There was a problem hiding this comment.
No test pins the order of the credential check and the server check. The invalid-credential tests all use a server the gateway serves, and this test uses a valid credential. If the two checks in authorize.go were swapped, every test would still pass, and a caller with an expired SVID would get denied ("no gateway routes") instead of svid_expired.
Suggested test: an expired credential and an unrouted server together. Expect CodeUnauthenticated with ReasonSVIDExpired, and a decision record with no agent.
There was a problem hiding this comment.
Added in #2794: an expired credential for an unrouted server is refused as svid_expired with a record naming no agent; swapping checks 3 and 6 fails it.
| // Tool is the exact tool name the call sends as params.name, such as | ||
| // "github.pull_request_read". Set for tools/call only. | ||
| Tool string | ||
| // ArgumentsSHA256 is the SHA-256 of the call's arguments, 64 lowercase |
There was a problem hiding this comment.
Nit: could this comment point to the definition in credentials-and-lifecycle.md (step 8, "The argument hash")? The design says it's the SHA-256 of the arguments in RFC 8785 (JCS) form, with {} when there are no arguments. Whoever writes the MCP client side will start from this field, and "the SHA-256 of the call's arguments" could be read as a hash of the raw bytes. That would stop matching the gateway, because the client decodes the arguments and encodes them again before sending.
There was a problem hiding this comment.
Done in #2794: the comment now points at step (8), "The argument hash" (RFC 8785 serialization of params.arguments as sent, or {}).
Address review comments on #2785: - DecisionRecord.OwnerVerified says whether Owner is the owner the broker verified at session open or only the one mecak8s reported, as audit subjects must say (audit.md). - Pin that check 3 comes before check 6: an expired credential for an unrouted server is refused as svid_expired. - ArgumentsSHA256 points at the design's definition of the argument hash. Co-authored-by: Mecatl <noreply@mecatl.dev>
|
Thanks @jhrozek. All three inline comments are fixed in a separate follow-up PR, #2794, which sits on top of the stack (#2783), so this PR merges as you approved it:
The rebase you asked for is done: the stack was rebased onto main after #2784 merged, so this branch carries the design text as amended by #2779. Your two comments on #2784 (fencing the AS-2 trust seam, and the duplicated trusting-AS-2 setup) are addressed in the same follow-up, #2794. |
Address review comments on #2785: - DecisionRecord.OwnerVerified says whether Owner is the owner the broker verified at session open or only the one mecak8s reported, as audit subjects must say (audit.md). - Pin that check 3 comes before check 6: an expired credential for an unrouted server is refused as svid_expired. - ArgumentsSHA256 points at the design's definition of the argument hash. Co-authored-by: Mecatl <noreply@mecatl.dev>
Address review comments on #2785: - DecisionRecord.OwnerVerified says whether Owner is the owner the broker verified at session open or only the one mecak8s reported, as audit subjects must say (audit.md). - Pin that check 3 comes before check 6: an expired credential for an unrouted server is refused as svid_expired. - ArgumentsSHA256 points at the design's definition of the argument hash. Co-authored-by: Mecatl <noreply@mecatl.dev>
Address review comments on #2785: - DecisionRecord.OwnerVerified says whether Owner is the owner the broker verified at session open or only the one mecak8s reported, as audit subjects must say (audit.md). - Pin that check 3 comes before check 6: an expired credential for an unrouted server is refused as svid_expired. - ArgumentsSHA256 points at the design's definition of the argument hash. Co-authored-by: Mecatl <noreply@mecatl.dev>
Part 2 of 4 for #2535. Stack: #2784 → this PR → #2786 → #2783.
The
AuthorizeCallcontract and the checks before a grant (design step (6), as amended by #2779).tools/callortools/list), server, tool as the gateway routes it, argument hash (tool calls only), operation, run, run owner, delegation, rejected attempt.Targetis renamedServer. Response: gateway token, expiry, attempt ID.no_grant, agent credential, route (check 6). Calls that pass every check are still refused here; feat(identitybroker): authorize gateway calls with a per-call ID-JAG and gateway token #2786 adds steps (7) and (8).MemoryRecorder), the rejected-attempt ledger,no_grantandconsent_requiredreasons,Gateway{Servers}, conformance cases.Shortcuts (marked in code): checks 4, 5 (#2557) and 7 (authority work) accept their inputs; check 6 matches the server, not the tool's route (#2538); one gateway (#2538); records and retry state in memory (#2541, #2563); an unaccepted refusal record is not reported elsewhere (#2541).
API compatibility
No wire change:
AuthorizeCallis an in-process Go contract until #2560. All Go callers are in this repository and updated.