Repository navigation
Description
Summary
POST /api/agents/{name}/emit-event is AuthorizedAgent-gated, so any principal with READ
access to {name} — including a sibling agent's key, which resolves to the owner — can emit an
event whose source_agent is {name}. The real initiator is recorded nowhere: agent_events
has no emitter column. A subscriber can be made to act on an event attributed to an agent that
did not send it.
Journey Impact: J06 (credential/MCP lifecycle) — attribution on the event path.
Converted from the debt inbox by /groom on 2026-09-21. Entry verbatim below.
debt:2026-09-14-emit-event-for-agent-lets-any-accessor-emit-as-the-agent
What: POST /api/agents/{name}/emit-event (routers/event_subscriptions.py::emit_event_for_agent) is AuthorizedAgent-gated — any principal with READ access to {name} emits an event whose source_agent IS {name}. That includes a sibling agent's key, which resolves to the owner and therefore can access every owner agent. After ent#614 the EVT-001 loopback vouches that source_agent to the subscriber (agent_originated=True), so the subscriber's execution is attributed to {name} while the real initiator — a human accessor or a sibling agent — is recorded nowhere (agent_events has no emitter column).
Why deferred: it is that endpoint's own contract ("admin triggering events" per its docstring), pre-existing, and orthogonal to the raw-header fix; changing it means either an owner-tier gate (a behaviour change for accessors) or an emitter column on agent_events (a dual-track migration). Narrowed during ent#614's review: the loopback no longer CERTIFIES the accessor-chosen name (agent_originated=current_user.agent_name == name), so such an event can no longer mint an actor_type='agent' audit row, a triggered_by='agent' execution or an AGENT_COLLABORATION edge on {name} — it wakes the subscriber as an ordinary MCP-triggered execution. What remains is only the agent_events.source_agent row value and the WebSocket event broadcast, which still say {name}.
Context: minimal fix = owner-or-self gate (OwnedAgent, or current_user.agent_name == name for an agent key) so only the agent itself or its owner can emit as it; fuller fix = agent_events.emitted_by_user_id / emitted_by_agent columns (SQLite entry + Alembic revision) carried into the loopback claim. /api/events (emit_event) is already principal-derived and needs nothing.
Interest: an accessor or a sibling agent can make a subscriber act on a forged "event from {name}" with the audit trail naming {name}; the attribution the ent#614 helper guarantees on the dispatch routes has this one upstream hole.
Effort (AI): S (gate) / M (emitter column, both migration tracks)
Source: abilityai/trinity-enterprise#614, /autoplan gate (deferred item 2; engineering finding 2)
Activity