Skip to content

fix(a2a): a bearer tasks/get and tasks/cancel answer only for the caller's own task (#3751) - #3836

Merged
vybe merged 2 commits into
devfrom
fix/3751-a2a-bearer-task-scope
Oct 20, 2026
Merged

vybe merged 2 commits into
devfrom
fix/3751-a2a-bearer-task-scope

Conversation

@dolho

@dolho dolho commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A bearer A2A tasks/get / tasks/cancel now 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_inbound could 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:

    • the row has triggered_by == "a2a";
    • its source_user_id is the caller's id (never empty);
    • its source_mcp_key_id is 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_by and 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 its messageId namespace.

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

Test Plan

  • cd tests && pytest unit/test_3751_a2a_bearer_task_scope.py: 28 pass.
    • The starter (key, signed-in person, agent key, shared user) can read and cancel its own task, running or queued.
    • A sibling agent key, the owner's key, the owner signed in, a shared user, an admin and the system key all get Task not found on both methods. Nothing is terminated, cancelled or audited.
    • The refusal is byte-identical to an unknown id.
    • A non-A2A row, a row with no user, and a re-issued key are all refused.
    • The row the real _mint_a2a_execution writes is pollable by its caller only.
    • AAuth still uses execution_owned_by.
  • Mutations: removing the gate turns 21 tests red; removing the triggered_by check turns 5 red.
  • The existing A2A suites pass: 157, 3749, ent623, 3185, ent838 (170 tests).
  • test_ent679_a2a_payment_gate.py and test_736_a2a_outbound_edges.py show 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

dolho and others added 2 commits October 20, 2026 15:22
…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]>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge-train: validated at 69163b7 — ownership gate fails closed, uniform not-found, tests drive the real dispatcher (105 pass).

@vybe
vybe merged commit 3719f67 into dev Oct 20, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants