[Bug]: Session/channel read+write tools lack per-agent ownership scoping (sessions_list/history/send, discord_search)
Affected component
tools
Severity
S0 - data loss / security risk
Current behavior
Several built-in tools take a target identifier (session_id, channel_id) from model-supplied arguments and act on it with no per-agent ownership check. Any agent can therefore reach another agent's session/channel data. This violates ADR-011 (docs/book/src/architecture/decisions/ADR-011-multi-agent-runtime-boundaries.md:24,56), which declares agents must not share workspace, memory, or channel reachability by accident, and ADR-011:46,86, which require every cross-agent capability to define its own authorization boundary.
The ownership primitive already exists (SessionOwnershipScope::authorize, crates/zeroclaw-tools/src/sessions.rs:90-126) and is wired into sessions_reset/sessions_delete — but the read/write session tools and discord_search never call it. Verified by source inspection at commit c1b04dbc0c (master, v0.8.3):
| Tool | Location | Gap |
|---|---|---|
sessions_list |
crates/zeroclaw-tools/src/sessions.rs:132 |
Lists all sessions of all agents/channels; no security gate, no scope |
sessions_history |
sessions.rs:216 |
Reads any session by id; only a coarse ToolOperation::Read gate, no ownership |
sessions_send |
sessions.rs:313 |
Writes a user turn into any session; only a coarse Act gate, no SessionOwnershipScope |
discord_search |
crates/zeroclaw-tools/src/discord_search.rs:57 |
Reads all indexed Discord history; channel_id/author_id are optional filters; no enforce_tool_operation at all |
Registration confirms the session tools are all built via unscoped ::new even though agent_alias is already in scope at the call site (crates/zeroclaw-runtime/src/tools/mod.rs:1121-1127, inside all_tools_with_runtime(agent_alias, …)).
Scope note: the 5 core memory tools (memory_recall/store/forget/purge/export) are not affected — they are correctly scoped via AgentScopedMemory with the alias bound from a trusted constructor; cross-agent sharing there is opt-in via read_memory_from. send_via (peer-group membership check) and sessions_current (trusted TOOL_LOOP_SESSION_KEY task-local) are the correct reference models to copy.
The shared knowledge-graph has the same class of gap but a different fix shape (schema + migration) and is filed separately.
Expected behavior
Each tool must derive the caller's identity from a trusted context (constructor-bound agent_alias / task-local), never from arguments, and authorize the target before acting:
sessions_list— filter results to sessions the caller owns (reuse the three-tierSessionOwnershipScopepredicate).sessions_history/sessions_send— runSessionOwnershipScope::authorizebeforeload/append; deny on foreign sessions. Register viafor_agent(...)intools/mod.rs.discord_search— add a tool-operation gate and constrain results to channels the calling agent is configured for.
Legacy data handling — fail-closed with the existing channel fallback. Reuse SessionOwnershipScope::authorize as-is: agent_alias match → owned-channel_id match → deny. Channel sessions never receive agent_alias (the orchestrator stamps only channel_id/room_id/sender_id, orchestrator/mod.rs:4460-4465), so the channel-ownership fallback prevents hiding an agent's own channels; only truly unattributed legacy sessions are denied. This matches the already-shipped reset/delete behavior.
Steps to reproduce
# Two agents in one deployment: [agents.rowan] and [agents.sable].
# Agent "sable" has an active channel session telegram__victim with private history.
# Acting AS agent "rowan", issue these tool calls:
# 1) Enumerate every session across ALL agents/channels (no ownership filter):
sessions_list {}
# -> telegram__victim (owned by sable) appears in the list.
# 2) Read another agent's full private history:
sessions_history {"session_id": "telegram__victim"}
# -> returns sable's conversation verbatim.
# 3) Inject a turn into another agent's session:
sessions_send {"session_id": "telegram__victim", "message": "..."}
# -> appended as a user message in sable's session.
# 4) Read all indexed Discord history irrespective of channel membership:
discord_search {"query": "..."} # channel_id omitted
# Verified by source inspection at commit c1b04dbc0c (master, v0.8.3):
# sessions.rs:132 / :216 / :313 (list / history / send — no ownership scope)
# discord_search.rs:57 (no gate; channel_id optional)
# runtime/src/tools/mod.rs:1121-1127 (session tools registered via unscoped ::new)Impact
Affected: any multi-agent deployment (>=2 configured agents, or agents + gateway/channel sessions).
Vector: a prompt-injected or low-trust agent can exfiltrate another agent's private
conversation history and inject messages into foreign sessions.
Frequency: always -- deterministic, no race.
Consequence: cross-agent confidentiality + integrity breach; violates the ADR-011 isolation
guarantee. Same confused-deputy class as #7947 and #8279; relevant to tracker #8290.
Not affected: the 5 core memory tools (AgentScopedMemory-scoped).Logs / stack traces
Static authorization gap -- no runtime log. Primary evidence (v0.8.3, c1b04dbc0c):
sessions.rs:164 async fn execute(&self, args) { // SessionsListTool
sessions.rs:171 let metadata = self.backend.list_sessions_with_metadata(); // ALL sessions, unscoped
sessions.rs:242 async fn execute(&self, args) { // SessionsHistoryTool
sessions.rs:243 self.security.enforce_tool_operation(Read, "sessions_history") // coarse gate only
sessions.rs:278 let messages = self.backend.load(session_id); // arbitrary session_id, no ownership checkZeroClaw version
v0.8.3 (commit c1b04dbc0c)
Rust version
rustc 1.97.0
Operating system
All platforms (source-verified on Windows 11; code path is OS-independent)
Regression?
Unknown
Pre-flight checks
- I reproduced this on the latest master branch or latest release. (verified by source inspection of the v0.8.3 / c1b04dbc0c tree)
- I redacted secrets, tokens, and personal data from all submitted content. (neutral placeholder aliases only)
Source: zeroclaw-labs/zeroclaw