[Bug]: Delegated memory tools lose principal scope
Affected component
memory
Severity
S0 - data loss / security risk
Current behavior
A principal-owned RPC session routes its direct memory tools to the owner's private plane, but an agentic delegate constructs replacement memory tools without that principal scope. This lets the child read or modify the target agent's shared memory and puts delegated writes there instead of in the owner's private memory.
This is a source-traced finding from the retrospective review of #11082, also present at the revision below. I have not executed the reproduction scenario.
The relevant path is:
route_memory_to_principalroutes the parent memory and direct memory tools. It does not update the delegate's target-memory factory.- A non-admin with
tools:execute,allowed_tools = ["*"], andallowed_agents = ["*"]retains delegation. Those selectors do not grant the admin-only shared memory plane. memory_for_target_agentcallscreate_memory_for_agentwithout a principal wrapper. Bounded delegation builds memory tools from that handle and substitutes them into the child registry.
Expected behavior
A delegated memory operation from an owner-bound session must retain the owner's principal scope while selecting the target agent's memory dimension. If that scope cannot propagate, refuse the affected operation rather than use shared storage. Named administrators also default to private memory; shared access must remain explicit.
Steps to reproduce
# Source-derived regression scenario, not an executed shell script.
# 1. Use SQLite and configure a non-admin principal with Sessions Create/Execute,
# Tools Execute, and wildcard agent/tool selectors.
# 2. Configure a caller and reachable bounded agentic target whose risk profiles
# permit delegation and memory_recall/memory_store. No shell access is needed.
# Satisfy the target's normal delegation and noninteractive approval rules.
# 3. Seed a synthetic shared-plane sentinel in the target agent's memory.
# 4. Create an owned RPC Chat session and invoke bounded delegation to that target.
# 5. Have the child call memory_recall for the shared sentinel and memory_store
# with a different synthetic key. A deterministic test provider can issue these calls.
# 6. Inspect both storage planes: the child uses the shared handle; its write
# does not enter the owner's private plane.Impact
Multi-user deployments that enable delegation for a non-admin with wildcard selectors can expose shared operator memory or place that user's notes into shared storage. The configuration can restrict the agents to delegation and memory tools, so this does not depend on independent shell or database-file access. Existing delegation policies, target reachability, and tool approvals still apply. This finding does not show access to another principal's protected private rows.
Carry the owner scope into target memory construction and subsequent nested calls, or disable principal-unaware delegation for owner-bound sessions until it can preserve isolation. Rebinding only the parent's tool list is insufficient because the target factory replaces the memory tools again. A focused regression should exercise actual child recall/store against private and shared sentinels.
Related #8289. This is a post-merge repair for #11082, distinct from #10644's background-result ownership and #11151's RPC agent-handle selection.
Logs / stack traces
No response. Source review only; no runtime logs were generated.
ZeroClaw version
24e7324dc69f525797fc46d80aa0b439d0b418ae; the same delegation path is present in #11082's landed commit ebf97ab060229ab4a766279ae8d69937cf30c489.
Rust version
Not applicable to this source-only report; no compiler run.
Operating system
The inspected routing is platform-independent. No operating-system runtime reproduction was performed.
Regression?
Unknown. #11082 introduced the private-memory contract; the existing delegation path was not brought under it.
Pre-flight checks
- I reproduced this on the latest master branch or latest release.
- I redacted secrets, tokens, and personal data from all submitted content.
The first checkbox is intentionally unchecked: the failure path was traced at the stated master revision, not executed.
Source: zeroclaw-labs/zeroclaw