Repository navigation
Description
Environment
- OpenClaw version: v2026.3.13 (61d171a)
- OS: Ubuntu 24.04.3
- Docker: installed, sandbox enabled via
agents.defaults.sandbox - Setup: 5+ OpenClaw instances on the same host, isolated via
HOMEenv var
Description
When multiple OpenClaw instances run on the same host with Docker sandbox enabled, they all generate the same container name (e.g. openclaw-sbx-agent-main-f331f052). This causes all instances to share a single Docker container, meaning exec tool operations in one instance read/write files from another instance's workspace.
Root Cause
The container name hash appears to be derived solely from the agent key (main) rather than including the instance identity (e.g. HOME path or gateway port). Since all instances use the default agent key main, they produce an identical hash.
Steps to Reproduce
- Create 2+ OpenClaw instances on the same host using different
HOMEdirs:HOME=/path/to/instance-a openclaw gateway run # port 18810 HOME=/path/to/instance-b openclaw gateway run # port 18820
- Both have sandbox enabled:
{ "agents": { "defaults": { "sandbox": { "mode": "all", "workspaceAccess": "rw" } } } } - Start both instances
- Run
docker ps— only one container exists:openclaw-sbx-agent-main-f331f052 - The container mounts whichever instance created it first
execfrom instance-b reads instance-a's files
Impact
- Critical data contamination: cross-instance file reads/writes via exec
sandbox/containers.jsonin each instance references the same container name- Deleting the container doesn't help — the next exec recreates it with the same name
Expected Behavior
Each instance should produce a uniquely-named container, incorporating instance-level identity (HOME path, gateway port, or config hash) into the container name.
Workaround
Disable sandbox on all co-hosted instances by removing agents.defaults.sandbox from config. This loses sandbox security isolation.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
Ryce commentedon Mar 21, 2026
Hollychou924 commentedon Mar 21, 2026
fix(sandbox): include workspace dir in container name to prevent cros…
yang1002378395-cmyk commentedon Mar 21, 2026
技术分析
这是一个严重的生产环境隔离问题。根本原因是容器名生成逻辑缺少实例标识符。
问题代码位置
core/sandbox/docker.ts中的容器名生成逻辑:只使用
agentKey(默认 "main"),导致所有实例生成相同名称。解决方案选项
Option A: 加入实例标识符(推荐)
Option B: 在容器创建时检查所有权
临时解决方案
对于紧急生产环境,可以:
--network)商业支持
如果需要快速修复 + 长期维护,我可以提供付费支持服务:
联系方式:查看我的 GitHub profile bio
定价:$199(包含修复 + 测试 + 部署指导)
我是 OpenClaw 技术专家,专注于企业级部署与优化。
Hollychou924 commentedon Mar 21, 2026
clawsweeper commentedon Apr 28, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 5, 2026, 5:52 AM ET / 09:52 UTC.
Summary
Keep open. Current main and v2026.6.11 still derive sandbox runtime identity from scope keys without workspace or instance identity, while the direct fix remains an open unmerged candidate.
Reproducibility: yes. Current main is source-reproducible: non-shared sandbox scope keys and Docker/browser container names are derived without workspace identity, matching the co-hosted instance collision report; I did not run live Docker in this read-only review.
Root-cause cluster
Relationship:
canonicalCanonical: #51363
Summary: This issue is the narrow canonical sandbox container collision report; an open PR is the candidate fix, an older direct PR is closed unmerged, and broader multi-instance lifecycle work is adjacent.
Members:
fixed_by_candidate: fix(sandbox): scope agent sandboxes by workspace #96866 - The open PR directly addresses non-shared sandbox reuse by adding workspace-scoped runtime identity and includes real Docker backend proof.superseded: fix(sandbox): include workspace dir in container name to prevent cross-instance collisions #51380 - The earlier direct fix PR is closed unmerged after branch drift and is no longer a viable landing path.partial_overlap: [Feature]: First-class multi-instance management for Docker installs #39659 - That open issue tracks broader first-class multi-instance Docker lifecycle management, while this issue is a concrete sandbox naming isolation bug.partial_overlap: [Feature]: Managed ephemeral sandbox lifecycle for session-owned work #98516 - That open maintainer-labeled issue covers managed ephemeral sandbox lifecycle, which is adjacent to but broader than this container identity collision.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
Do not queue a separate fix PR because the issue is security/product-sensitive and already has #96866 as the active candidate fix path.
Maintainer decision needed
Security
Needs attention: This issue is security-sensitive because current sandbox naming can reuse a Docker isolation boundary across co-hosted instances.
Review details
Best possible solution:
Land the workspace-scoped non-shared sandbox identity fix, or an equivalent security-reviewed fix, with Docker/browser/SSH/recreate coverage and explicit upgrade cleanup behavior for existing runtimes.
Do we have a high-confidence way to reproduce the issue?
Yes. Current main is source-reproducible: non-shared sandbox scope keys and Docker/browser container names are derived without workspace identity, matching the co-hosted instance collision report; I did not run live Docker in this read-only review.
Is this the best way to solve the issue?
Yes on direction, but maintainer/security review is still needed. Workspace-scoping the sandbox lifetime key is better than a Docker-only name patch because Docker, browser, SSH, registry, skills workspace, and recreate paths all consume that scope contract.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 78685aec4686.
Label changes
Label justifications:
P1: The source-proven bug can make co-hosted OpenClaw instances share an exec sandbox container and operate on the wrong workspace.impact:data-loss: Wrong-container reuse can route writes from one instance into another instance's mounted workspace.impact:security: The issue weakens the Docker sandbox isolation boundary between separately configured instances on the same host.impact:session-state: Wrong-container reuse can expose or mutate another instance's workspace, agent context, and session files.Evidence reviewed
Security concerns:
src/agents/sandbox/docker.ts:595Current Docker and browser sandbox names are derived from scope keys without instance identity, so separately configured instances can address the same running container and mounted workspace.
Confidence: 0.9
Acceptance criteria:
What I checked:
resolveSandboxScopeKeyreturnsshared, the raw session key, oragent:<agentId>; it does not include HOME, workspace root, gateway port, or another per-instance discriminator. (src/agents/sandbox/shared.ts:32, 78685aec4686)ensureSandboxWorkspaceLayoutderivesscopeKeyfrom only the raw session key before creating the workspace/backend runtime, so the backend receives the same agent-scope identity across co-hosted instances. (src/agents/sandbox/context.ts:91, 78685aec4686)ensureSandboxContainerbuilds the Docker container name fromslugifySessionKey(scopeKey)before workspace identity participates only in the config hash, so equal agent scope keys can target the same container. (src/agents/sandbox/docker.ts:595, 78685aec4686)ensureSandboxBrowserbuilds the browser container name fromparams.scopeKey, so the parallel browser runtime path shares the same scope-only identity problem. (src/agents/sandbox/browser.ts:234, 78685aec4686)resolveSshRuntimePathsbuilds the SSH runtime id fromscopeKey, confirming the invariant is shared across sandbox backends rather than Docker-only. (src/agents/sandbox/ssh-backend.ts:426, 78685aec4686)src/agents/sandbox/docker.ts:600, e085fa1a3ffd)Likely related people:
src/agents/sandbox/docker.ts,src/agents/sandbox/browser.ts,src/agents/sandbox/context.ts)src/agents/sandbox/docker.ts,src/agents/sandbox/backend.ts,src/agents/sandbox/ssh.ts)5dff031467f1a9c15a77b37461b1a14829f3eaf4to Bartok9, though that commit appears to be broad/grafted checkout history rather than the original sandbox behavior introduction. (role: recent current-line contributor; confidence: low; commits: 5dff031467f1; files:src/agents/sandbox/shared.ts,src/agents/sandbox/docker.ts,src/agents/sandbox/browser.ts)src/agents/sandbox/shared.ts,src/agents/sandbox/docker.ts,src/agents/sandbox/browser.ts)src/agents/sandbox/docker.ts,src/agents/sandbox/browser.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.10 remaining items
fix(sandbox): scope runtimes by workspace
fix(sandbox): scope runtimes by workspace
fix(sandbox): scope runtimes by workspace (#115766)
fix(sandbox): scope runtimes by workspace (openclaw#115766)