Repository navigation
fix(a2a): a bearer tasks/get and tasks/cancel answer only for the caller's own task (#3751) - #3836
Merged
Merged
Conversation
…ler's own task (#3751) The bearer branch checked only that the execution belonged to the agent, so any principal that passed _authorize_inbound (owner, shared user, admin, any agent key of the owner) read or cancelled every execution id on it. AAuth callers were already bound by execution_owned_by, payers by the payer binding. _bearer_started_by: the row was started through A2A (triggered_by='a2a') by this user id AND this key id (None on both sides for a JWT). The key, not the user, is the identity: every agent key of one owner resolves to the owner's user id and role. No owner/admin override for the same reason. Anyone else gets the unknown-id answer byte for byte, and a refused cancel signals nothing. This scopes the A2A task handle; the REST execution routes are trinity-enterprise#875. Mutations: removing the gate turns 21 of 28 new tests red; removing the triggered_by check turns 5 red. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sk-scope # Conflicts: # tests/registry.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A bearer A2A
tasks/get/tasks/cancelnow answers only for a task that the same credential started through A2A. Before, it checked only that the execution belonged to the agent, so any principal that passed_authorize_inboundcould read or cancel every execution id on that agent: the owner, a shared user, an admin, or any agent key of the owner.The rule,
routers/a2a.py::_bearer_started_by:triggered_by == "a2a";source_user_idis the caller's id (never empty);source_mcp_key_idis the caller's key id (empty on both sides for a signed-in person).The key is the identity, because every agent key of one owner resolves to the owner's user id and role. It is the bearer equivalent of AAuth's
execution_owned_byand the payer binding.No owner/admin override (decided while planning), because an agent key carries its owner's role. Anyone else gets the unknown-id
Task not found, byte for byte, and a refused cancel signals nothing. A re-issued key loses its in-flight tasks, the same as itsmessageIdnamespace.Scope: this scopes the A2A task handle only. The REST execution routes (
GET /api/agents/{name}/executions/{id},…/terminate) sit behind the same agent-access gate. They are handled by trinity-enterprise#875 (#3777).Changes
src/backend/routers/a2a.py:_bearer_started_by, applied in the bearer branch oftasks/getandtasks/cancel.tests/unit/test_3751_a2a_bearer_task_scope.py(new, 28 tests).test_157_a2a_inbound_server.pyandtest_3749_a2a_working_task.py: fixture rows carry the starter's fields. The bug: inbound A2A message/send never returns a working task for a long agent turn, so the caller's 30 s timeout loses the answer #3749 mint stub now records what the real mint records.docs/user-docs/integrations/a2a-protocol.md: who may poll a task.docs/memory/requirements/mcp.mdFR-3.docs/memory/feature-flows/a2a-inbound-server.md: the per-door binding table.Test Plan
cd tests && pytest unit/test_3751_a2a_bearer_task_scope.py: 28 pass.Task not foundon both methods. Nothing is terminated, cancelled or audited._mint_a2a_executionwrites is pollable by its caller only.execution_owned_by.triggered_bycheck turns 5 red.test_ent679_a2a_payment_gate.pyandtest_736_a2a_outbound_edges.pyshow the same 22 local failures with and without this change, so they predate this PR and are environment-related.Fixes #3751
🤖 Generated with Claude Code