Repository navigation
fix(memory-wiki): sandboxed sub-agents could read other agents' bridged memory through shared vault wiki reads - #111463
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 7:28 PM ET / 23:28 UTC. ClawSweeper reviewWhat this changesThe PR prevents sandboxed sub-agents from reading foreign or ownership-unknown bridge-compiled Memory Wiki pages through Merge readinessKeep this PR open for landing. Current Priority: P0 Review scores
Verification
How this fits togetherMemory Wiki compiles per-agent memory artifacts into a vault that direct wiki tools and Memory Core fallback tools can search and retrieve. The query layer receives caller identity and sandbox state, filters readable pages, then returns results to the requesting agent. flowchart LR
A[Memory bridge artifacts] --> B[Shared Memory Wiki vault]
C[Agent identity and sandbox state] --> D[Query visibility gate]
B --> D
D --> E[wiki_get and wiki_search]
D --> F[Memory Core corpus fallback]
E --> G[Agent tool result]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +40, Tests +421. Total +461 across 5 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land a single query-layer ownership check for bridge-compiled pages after rebasing onto current Do we have a high-confidence way to reproduce the issue? Yes, from source and supplied real-vault proof: current main's wiki-corpus reads do not apply caller ownership, and the same synthetic bridge-page scenario is exercised through direct and registered fallback tools. This review did not independently execute the reproduction because the read-only runner could not launch local inspection commands. Is this the best way to solve the issue? Yes. A shared query-layer visibility predicate is the narrowest maintainable solution because it covers both direct wiki reads and Memory Core corpus fallback without duplicating caller-specific access policy. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against 342826b90440. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
ebb1ef1 to
f38a07d
Compare
f38a07d to
b610e01
Compare
b610e01 to
3d3a9ba
Compare
3d3a9ba to
9b947db
Compare
9b947db to
ec3c67b
Compare
ec3c67b to
770640f
Compare
770640f to
d1be22c
Compare
d1be22c to
8740e81
Compare
|
@obviyus Hey, Since the PR is passing checks can this be merged?? |
Sandboxed sub-agents could read another agent's bridge-compiled memory through the shared global vault via wiki_get, wiki_search, and the memory_get/memory_search corpus fallback. The wiki-corpus read path now filters pages through one visibility gate that fails closed for bridge-compiled pages a sandboxed caller does not own, including bridge pages that carry no ownership metadata.
8740e81 to
4f31584
Compare
|
Maintainer review + rebase. Head is now Confirmed the hole on current
|
Closes #103087
What Problem This Solves
Fixes an issue where a sandboxed sub-agent belonging to one agent identity could read another agent's bridge-compiled memory content through
wiki_get,wiki_search, and thememory_get/memory_searchcorpus fallback. Withbridge.enabled: true, every agent's memory-root, daily-note, dream-report, and event-log artifacts are compiled into the one shared global vault, and the wiki-corpus read path returned any matching vault page with no check of the caller'sagentId,agentSessionKey, orsandboxedflag, even though the sessions-corpus branch in the same file already blocks the equivalent cross-agent read.#103349 added the opt-in
vault.scope: "agent"isolation and filtered bridge sync by ownership, but as noted on the issue the default global vault query path remained caller-unfiltered, so the reported disclosure is still live on currentmain.Why This Change Was Made
The fix reuses the ownership model #103349 established instead of adding new configuration: bridge pages already carry
bridgeAgentIdsfrontmatter written by bridge sync (extensions/memory-wiki/src/bridge.ts:231), soWikiPageSummarynow surfaces that field and the wiki-corpus branch ofgetMemoryWikiPageandsearchWikiCorpusfilters pages through one visibility gate.The gate is deliberately limited to sandboxed callers and fails closed on bridge-compiled pages. A page counts as bridge-compiled when its
sourceTypeismemory-bridgeormemory-bridge-events, or when it carries anybridgeAgentIdsentry. A sandboxed caller with a resolved agent identity reads its own bridge pages and every ordinary wiki page, but not another agent's bridge pages and not a bridge page whose ownership metadata is absent or empty. A sandboxed caller with no resolvable agent reads no bridge page at all. Ordinary non-sandboxed callers retain the documentedvault.scope: "global"behavior, including cross-agent bridge reads. Ownership comparison is case-insensitive, matching the existing agent-id comparisons in this file.The gate lives in
query.tsrather than in any caller, so it covers every wiki-corpus read surface at once.createWikiCorpusSupplementalready forwardsagentId,agentSessionKey, andsandboxedintosearchMemoryWikiandgetMemoryWikiPage, and Memory Core already forwardsctx.sandboxedfrom the plugin tool context throughresolveMemoryToolOptions(extensions/memory-core/index.ts:160) intosearchMemoryCorpusSupplementsandgetMemoryCorpusSupplementResult, so the registeredmemory_search/memory_getcorpus fallback picks up the same visibility rule with no change outsideextensions/memory-wiki. The regression now drives that registered route through the real memory-core plugin registration rather than calling the supplement directly.Note: open PR #105098 also touches
searchWikiCorpus(deadline threading in the supplement fallback). The concerns are independent, but whichever lands second will need a trivial rebase of thesearchWikiCorpussignature.User Impact
Sandboxed sub-agents using the default shared vault with the memory bridge can no longer read another agent's bridged memory content, and can no longer read bridge pages that carry no ownership metadata. Normal non-sandboxed agent calls keep the documented global-vault sharing contract, including cross-agent bridge reads and unowned bridge reads. Single-agent setups see no behavior change: the agent owns its bridge pages, because every bridged workspace resolves at least one agent id (
resolveMemoryDreamingWorkspaces), and ordinary wiki pages remain readable.No stored data shape changes.
bridgeAgentIdsis the only ownership key bridge sync has ever written, from the bridge feature's first commitfbbe2a1675(2026-04-05) onward, so there is no earlier on-disk frontmatter shape to migrate and no doctor migration is required. Vaults whose bridge pages predate an ownership-reporting memory provider are covered by the fail-closed rule above rather than by a rewrite.Evidence
Driver: the real
wiki_getandwiki_searchagent tools fromextensions/memory-wiki/src/tool.ts, built bycreateWikiGetTool/createWikiSearchToolexactly asindex.tsregisters them, plus the realmemory_getandmemory_searchtools obtained from the actualmemory-coreplugin registration (memoryCorePlugin.register(...), then the registered tool factory invoked with a plugin tool context carryingagentId,sessionKey, andsandboxed), with the wiki supplement installed through the realregisterMemoryCorpusSupplementregistry that Memory Core reads. All four surfaces run against one real on-disk vault created by the productionresolveMemoryWikiConfigplusinitializeMemoryWikiVault. Nothing is stubbed on the read path; the only difference between the two runs isquery.tsplusmarkdown.ts.Vault contents are synthetic fixture pages written in the exact shape
bridge.tsproduces: one bridge page owned by agentsecondary(frontmatterbridgeAgentIds: ["secondary"]) and one bridge page with no ownership metadata, standing in for a vault whose bridge pages were compiled from a memory provider that does not report agent ids. No private vault content or real vault path appears below; the sentinel strings andsources/...paths are fixture data from a temporary vault.Validation on head
d1be22cbbf:node scripts/run-vitest.mjs run extensions/memory-wiki/src/query.test.ts extensions/memory-wiki/src/corpus-supplement.visibility.test.ts extensions/memory-wiki/src/claim-health.test.ts extensions/memory-wiki/src/agent-vault-isolation.test.ts extensions/memory-wiki/src/corpus-supplement.test.ts: 5 files, 64 tests passed.node scripts/run-vitest.mjs run extensions/memory-core/src/tools.test.ts: 1 file, 44 tests passed.node scripts/run-tsgo.mjs -p tsconfig.extensions.json: clean.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json: clean.node scripts/run-oxlint.mjsover the changed files: clean.oxfmt --checkover the changed files: clean.git diff --check: clean.Real behavior proof
Behavior addressed: a sandboxed sub-agent of one agent could read another agent's bridge-compiled memory, and any sandboxed sub-agent could read bridge pages carrying no ownership metadata, through the shared global vault read surfaces.
Real environment tested: the registered
wiki_get,wiki_search,memory_get, andmemory_searchagent tools driven against one real on-disk global vault, run on pristinemainand on this branch with identical inputs and identical vault contents.Exact steps or command run after this patch: three callers issue the same four calls against the same vault for each of two bridged pages: a sandboxed sub-agent of
main, a sandboxed sub-agent ofsecondary(the owner of the first page), and a normal non-sandboxedmainsession.Evidence after fix:
Observed result after fix: on all four read surfaces, including the registered Memory Core fallback, the sandboxed foreign caller went from full disclosure to denial, and the sandboxed caller of an unowned bridged page went from full disclosure to denial, while the owner's sandboxed reads and every non-sandboxed read stayed byte-identical across the two runs.
What was not tested: a full gateway run with a live
bridge.enabledsync cycle writing the pages throughsyncMemoryWikiBridgeSources(the vault pages were written directly in the exact shape bridge sync produces), andvault.scope: "agent"deployments, which bypass the shared vault entirely and are unaffected.Review responses
extensions/memory-core/index.ts:160copiesctx.sandboxedinto the tool options,extensions/memory-core/src/tools.tsforwards it intosearchMemoryCorpusSupplementsandgetSupplementMemoryReadResult, andextensions/memory-core/src/tools.shared.tshands it to every registered supplement. The gap was proof, not code, so the regression and the run above now drive the registeredmemory_getandmemory_searchtools built by the realmemory-coreplugin registration withsandboxed: trueon the tool context, instead of calling the supplement directly.agentIdsbridge frontmatter: no such key exists.bridge.tshas writtenbridgeAgentIdssince the bridge feature landed infbbe2a1675;agentIdsappears only as a TypeScript parameter name insidebridge.tsand as a field on the in-memoryMemoryPluginPublicArtifact, never in page frontmatter. The real residual risk the review points at is a bridge page whose ownership list is empty, which happens when a memory capability plugin omitsagentIdson its public artifacts, a casefilterMemoryWikiBridgeArtifactsexplicitly tolerates in global scope. That case is now fixed rather than migrated: bridge-compiled pages fail closed for sandboxed callers when ownership cannot be proven, covered by the second bridged page in the run above and by a new regression.mainsession still readssecondary's bridge page through both the direct wiki tools and the registered fallback.