Repository navigation
fix: stop sharing one employee's identity/memory across other employees' private Boon Agent chats - #330
Conversation
Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Adds senderId?: string to resolveBootstrapFilesForRun's params and forwards it to getOrLoadBootstrapFiles (sessionKey branch) and loadWorkspaceBootstrapFiles (no-sessionKey branch), completing the per-sender MEMORY.md/USER.md partitioning chain for ENG-21047. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ded run attempt Threads the real turn's senderId into both resolveBootstrapFilesForRun call sites in runEmbeddedAttempt (preload and resolver-fallback paths), completing the ENG-21047 per-sender bootstrap isolation wiring on top of Tasks 1-3 (workspace.ts, bootstrap-cache.ts, bootstrap-files.ts). Co-Authored-By: Claude Sonnet 5 <[email protected]>
compactEmbeddedAgentSessionDirectOnce rebuilt the successor system prompt through resolveBootstrapContextForRun without a senderId, so a long session that compacted went back to the shared workspace-root USER.md/MEMORY.md and reopened the cross-user leak for the rest of the session. resolveBootstrapContextForRun's params type never gained senderId (only its sibling resolveBootstrapFilesForRun did), so no caller could thread it. Add the field and pass params.senderId at the compaction call site. Co-Authored-By: Claude Opus 5 <[email protected]>
Codex, Copilot, and the /context and /export prompt inspection commands all loaded workspace bootstrap files with the sender already in hand but without passing it, so those surfaces still read the shared workspace-root USER.md and MEMORY.md after the per-sender partition landed. Codex and Copilot take it off their attempt params the same way attempt.ts does; the command bundle normalizes ctx.SenderId the way the agent run path already does, so the reported prompt matches the prompt the run builds. Co-Authored-By: Claude Opus 5 <[email protected]>
openRootFile resolves symlinks and only rejects targets outside the workspace, so identities/A/USER.md -> identities/B/USER.md (or a symlinked identity dir) resolved inside the root and was accepted, reading across the partition. Hardlinks were already rejected; symlinks were not. Extend readWorkspaceFileWithGuards with a symlink-alias refusal used only for the identity-partitioned USER.md/MEMORY.md reads, mirroring resolveCanonicalRootMemoryFile. Aliased files read as missing. Root bootstrap files keep following symlinks, which workspaces legitimately use. Co-Authored-By: Claude Opus 5 <[email protected]>
USER.md and MEMORY.md now resolve under identities/<senderId>/ when a turn carries a sender identity, and stay at the workspace root otherwise. Every other bootstrap file is unaffected. Also note identities/ in the git backup step so per-sender profiles are not left unbacked. Co-Authored-By: Claude Opus 5 <[email protected]>
…tion ENG-21047 re-review found a 4th missed bootstrap entry point: src/agents/cli-runner/prepare.ts called resolveBootstrapContextForRun without senderId, even though RunCliAgentParams.senderId is populated at both real dispatch sites. This is the primary prompt-assembly path for every CLI-backed harness, so the per-sender MEMORY.md/USER.md partition never engaged there and the shared root files were injected into every sender's turn. Pass senderId: params.senderId ?? undefined, matching the pattern already used at the other 3 fixed sites. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 20 files
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
View guided diff | Turn on auto-fix | Re-trigger cubic
…or walk, Codex memory routing) - sanitizeIdentityPathSegment now encodes any non-empty-but-unsafe senderId into its own distinct identity path instead of falling back to the shared workspace root (cubic P1). Only a truly empty senderId (no identity at all) still falls back to root. - hasSymlinkAlias now walks every ancestor between the identity file and the workspace boundary, not just the file and its immediate parent, so a symlinked `identities/` directory can't alias another sender (cubic P1). - Codex's root-memory detection now also recognizes a sender's identity-scoped MEMORY.md, so it routes through memory tools like the root file does instead of being inlined into the prompt (cubic P2). - Doc clarifications: identities/<senderId>/ doesn't seed from root, isolation only applies to non-empty sender identities, literal <senderId> in Mintlify accordion title (cubic P2/P3). - Test coverage: shared-file test now checks all 6 shared files not just AGENTS.md; new test loads an existing identity-scoped MEMORY.md's own content; removed a stray ticket reference from a test comment; fixed a leaked temp workspace in a Codex test (cubic P2/P3). Co-Authored-By: Claude Sonnet 5 <[email protected]>
… test CI's check-test-types caught what tsgo couldn't run locally in this worktree: memoryReferenceFiles is optional on CodexWorkspaceBootstrapContext. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
…test tautology) - sanitizeIdentityPathSegment no longer calls encodeURIComponent, which threw URIError on an unpaired UTF-16 surrogate (a real crash regression from the prior fix). Encodes per UTF-16 code unit instead, which never throws and keeps the same backward-compatible pass-through for alphanumeric/hyphen ids. - Trimmed the function's doc comment to the actual invariant. - Docs now say the identities/ directory name is an encoded form of the senderId, not the raw value, and that whitespace-only falls back to root. - The unsafe-senderId test now asserts the identity directory's structural shape independently of the sanitizer it's testing, so it can't pass on a sanitizer that regresses in the same way as the code under test. Added a dedicated unpaired-surrogate regression test. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Code Review: Approved
Summary
Resolves cross-user memory and identity leakage (ENG-21047) in multi-user Boon Agent deployments where USER.md and MEMORY.md were previously shared globally at the workspace root across all employees.
With this PR:
USER.mdandMEMORY.mdare partitioned underidentities/<senderId>/whenever a turn carries a non-emptysenderId.- Other shared workspace files (
AGENTS.md, agent identity,TOOLS.md,HEARTBEAT.md,BOOTSTRAP.md) remain shared at the workspace root. - Single-user deployments and turns without a sender identity fall back byte-for-byte to the workspace root.
Verification & Invariant Checks
- Path Traversal & Surrogate Safety:
sanitizeIdentityPathSegmentencodes every non-[A-Za-z0-9_-]character into a fixed 4-digit hex percent-encoding (%00xx/%xxxx).- Does not throw on unpaired UTF-16 surrogates (tested with
\uD800). - Prevents directory traversal (
..,/,\\).
- Symlink Escape Guard:
hasSymlinkAliaswalks ancestors from the target file up toworkspaceDirto reject symlinked files and symlinked identity directories from aliasing another user's identity directory.
- Session Rollover & Snapshot Cache:
bootstrapFilesEqualcompares resolved file paths in addition to content and names, ensuring cached snapshots are never shared across differentsenderIdvalues on the same session key.
- Compaction & Successor Prompt Rebuild:
- Threaded
senderIdintocompactEmbeddedAgentSessionDirect/compact.ts, preventing compacted sessions from reverting to the root identity.
- Threaded
- Codex & Copilot Extension Parity:
- Checked upstream Codex (
../codex/codex-rs/memories/read/src/usage.rs:57,codex-rs/external-agent-migration/src/memory_import.rs:20-31). - Codex app-server attempt context (
isCodexWorkspaceRootMemoryPath) correctly identifiesidentities/<senderId>/MEMORY.mdand extracts it intomemoryReferenceFilesso memory tools route it on demand rather than inlining into the model context. - Copilot bootstrap context correctly loads from the identity partition.
- Checked upstream Codex (
- Commands & CLI Runners:
- Threaded into
prepareCliRunContextandresolveCommandsSystemPromptBundlefor accurate/contextand/exportintrospection.
- Threaded into
Test Execution & CI Proof
- All unit and integration test suites pass locally:
src/agents/workspace.test.ts(65/65 passed)src/agents/bootstrap-cache.test.ts,src/agents/bootstrap-files.test.ts,src/agents/cli-runner/prepare.test.ts(104/104 passed)src/agents/embedded-agent-runner/compact.hooks.test.ts,src/agents/embedded-agent-runner/run/attempt.bootstrap-context.test.ts,src/auto-reply/reply/commands-system-prompt.test.ts(85/85 passed)extensions/codex/src/app-server/attempt-context.test.ts,extensions/copilot/src/workspace-bootstrap.test.ts(23/23 passed)
- GitHub Actions CI status check rollup: all check runs completed green (SUCCESS).
LGTM!
Addresses cubic review feedback on PR #332: the boon.6 release note described the identity directory with the raw sender ID and didn't mention the empty/whitespace fallback or the encoding's case-collision behavior on case-insensitive filesystems (macOS default, Windows). Co-Authored-By: Claude Sonnet 5 <[email protected]>
* chore(release): bump version 2026.6.35-boon.5 -> 2026.6.35-boon.6 Cuts the fork release for the PRs merged to boon after the v2026.6.35-boon.5 tag: - #330 (ENG-21047): MEMORY.md/USER.md now resolve per sender identity under identities/<senderId>/ instead of always at the shared workspace root, so a multi-user Boon Agent box can no longer leak one employee's identity, preferences, or conversation history into a different employee's private chat. Single-user deployments are byte-for-byte unchanged. - #331 (ENG-22470): Dependabot coverage, cooldown, and guarded auto-merge CI hardening. No shipped runtime change. Bump the root package.json and npm-shrinkwrap.json, all 136 bundled plugin manifests (scripts/sync-plugin-versions.ts), and the version string in every extension npm-shrinkwrap.json via a literal find-and-replace (no dependency content changed by this bump; a full scripts/generate-npm-shrinkwrap.mjs --all regeneration was skipped per the known registry-re-resolution risk on a pure version bump). Add the 2026.6.35-boon.6 CHANGELOG.md section. No source or dependency change beyond the merged PRs above. Co-Authored-By: Claude Sonnet 5 <[email protected]> * docs(changelog): precisely describe the #330 identity-segment encoding Addresses cubic review feedback on PR #332: the boon.6 release note described the identity directory with the raw sender ID and didn't mention the empty/whitespace fallback or the encoding's case-collision behavior on case-insensitive filesystems (macOS default, Windows). Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
What Problem This Solves
Fixes an issue where, for any multi-user Boon Agent deployment (one organization's Boon Agent box serving many employees' separate private 1:1 conversations), one employee's identity and conversation content could surface in a different employee's private chat. The agent's workspace memory files (
MEMORY.md,USER.md) were shared across the whole box instead of being scoped to the person actually talking to it, so after a long conversation and a general follow-up question, the agent could answer using a different employee's name, role, or conversation history. This was the root cause of ENG-21047 (Marathon: a private DM surfaced another user's content).Why This Change Was Made
MEMORY.md/USER.mdnow resolve underidentities/<senderId>/when a verified per-turn sender identity (MsgContext.SenderId, already populated by every channel plugin) is present, instead of always resolving at the shared workspace root. No new wire/protocol field was needed — this reuses an identity signal OpenClaw already carries on every turn. All other workspace files (AGENTS.md,SOUL.md,IDENTITY.md,TOOLS.md,HEARTBEAT.md,BOOTSTRAP.md) are unaffected and remain shared, as intended. A symlink guard was added so an identity-scoped file can't alias another identity's file. A deployment that never populates a sender identity (single-user CLI/Claude-Code-style usage) sees byte-for-byte unchanged behavior.Out of scope for this PR (tracked as follow-ups, not regressions): migrating already-contaminated root
MEMORY.md/USER.mdcontent on existing live boxes; a write-side partition for the separateextensions/memory-coretool surface; the Discord voice realtime path, which has no single-speaker identity to key off of today.User Impact
A Boon Agent (or any other multi-user OpenClaw deployment) can no longer leak one employee's identity, preferences, or conversation history into a different employee's private conversation via the shared memory files. Single-user deployments are unaffected.
Evidence
src/agents/workspace.test.ts,src/agents/bootstrap-cache.test.ts,src/agents/bootstrap-files.test.ts,src/agents/embedded-agent-runner/compact.hooks.test.ts,src/agents/cli-runner/prepare.test.ts,extensions/codex/src/app-server/attempt-context.test.ts,extensions/copilot/src/workspace-bootstrap.test.ts,src/auto-reply/reply/commands-system-prompt.test.ts— all green locally.USER.mdand the real sender.tsgo/pnpm build/lint — this worktree's local toolchain is incomplete (node_modules/.binmissing). The compaction fix changes a type re-exported through the Plugin SDK, so a Testbox/Crabboxpnpm check:changedtypecheck pass is needed before merge; requesting that as part of this PR's CI.Related PRs (same fix, different repos): boon-skills
ridho/eng-21047-cross-user-memory-isolation, boonridho/eng-21047-cross-user-memory-isolation.🤖 Generated with Claude Code
Summary by cubic
Fixes a cross-user leak where one employee's identity, preferences, and conversation history surfaced in a different employee's private Boon Agent chat.
MEMORY.mdandUSER.mdnow resolve underidentities/<senderId>/when the turn carries a sender identity instead of at the shared workspace root; no new wire or protocol field was added. All other bootstrap files (AGENTS.md,SOUL.md,IDENTITY.md,TOOLS.md,HEARTBEAT.md,BOOTSTRAP.md) stay shared. Turns with no sender identity (single-user CLI/Claude-Code) see byte-for-byte unchanged behavior. Non-empty senderIds are encoded so even unsafe values, including unpaired surrogates, map to their own identity path without throwing; the encoding preserves letter case, so senderIds differing only in case collide on case-insensitive filesystems (for example, macOS's default volume format). Identity-scoped reads refuse symlink aliases pointing at another identity's files, including symlinkedidentities/directories, and Codex routes identity-scopedMEMORY.mdthrough memory tools instead of inlining it.Notes
MEMORY.md/USER.mdon existing live boxes is out of scope, as are the write-side partition forextensions/memory-coreand the Discord voice realtime path.memoryReferenceFiles) and the linted type assertion are fixed.Written for commit 28998c1. Summary will update on new commits.