Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(bot-box): mount only the browser folders under /opt, and no /var/lib (#4011)

CI fixture7af1a66f349f
diff --git a/docs/bot-box.md b/docs/bot-box.md
index b01de9b1f3..cf5cb81ca4 100644
--- a/docs/bot-box.md
+++ b/docs/bot-box.md
@@ -9,7 +9,7 @@ its database, its settings, other bots' folders and other turns' processes are n
| Inside the box | What it is |
|---|---|
-| `/usr`, `/etc`, `/opt`, the server's own code folder, read-only | The image: engine CLIs, node, python, git, the bots' browser |
+| `/usr`, `/etc`, the bots' browser folders under `/opt`, the server's own code folder, read-only | The image: engine CLIs, node, python, git, the bots' browser. `/opt` and `/var/lib` are not bound whole: on a self-hosted host they hold other services' files a bot must not read; the browser's own folders (`/opt/openmausbot-browser`, `/opt/google/chrome`) and a server installed under `/opt` are what is shown |
| `HOME`, read-write | What bots and engines keep there: settings, tools, caches, git config. Of the engines' sign-in files (`~/.claude/.credentials.json`, `~/.codex/auth.json`, `~/.grok/auth.json`, the rest of `ENGINE_FOLDERS` in `server/engine-homes/layout.ts`) only the one of the engine account the process runs is there, bound over itself so a refresh writes in place; every other engine's and account's is an empty read-only file; every folder between HOME and those files is bound over itself, so a bot cannot rename one away; and a process that names no engine (a shell step, an MCP server) has none (`server/bot-box/sign-in-masks.ts`). The edge's certificate folder (`~/.omb-edge`) is an empty private folder. On a Team Cloud this is the turn's audience's engine home instead, with the team's engine sign-in files bound into it, and the server's HOME is not there at all ([team-cloud.md](team-cloud.md#engine-homes)) |
| the data folder (`~/.openmausbot`), **an empty private folder** | `messages.db`, `config.json`, logins, the server's sockets, every other bot's folders are not there |
| put back inside it: the turn's working folder and the bot's own folder (`workspaces/<bot>`), read-write | What the turn works on, and the bot's memory and skills. On a Team Cloud a turn that is not the team's has the bot's own folder read-only, and its own memory layer read-write ([team-cloud.md](team-cloud.md#the-audience-rule)) |
diff --git a/server/bot-box/plan.test.ts b/server/bot-box/plan.test.ts
index 2f070bd924..4d351fb9a8 100644
--- a/server/bot-box/plan.test.ts
+++ b/server/bot-box/plan.test.ts
@@ -5,7 +5,7 @@ import { engineInstallRoots } from "../engine-roots.ts";
import { githubFolders } from "../github/sign-in.ts";
import { chatgptAccountHome } from "../drivers/codex-account-home.ts";
import { boxEnvironment } from "./env.ts";
-import { BOX_MUTATIONS, CPU_LIST_FILES, argvPaths, bwrapArgs, planBox, taskWorkspaceIds, under, visibleInBox, type BoxAudience, type BoxMutation, type BoxRequest, type BoxSetup } from "./plan.ts";
+import { BOX_MUTATIONS, BROWSER_ROOTS, CPU_LIST_FILES, argvPaths, bwrapArgs, planBox, taskWorkspaceIds, under, visibleInBox, type BoxAudience, type BoxMutation, type BoxRequest, type BoxSetup } from "./plan.ts";
const home = "/data";
const dataDir = "/data/.openmausbot";
@@ -65,6 +65,21 @@ linuxBox("the box plan", () => {
expect(visibleInBox(plan, "/root/.ssh/id_ed25519")).toBe("none");
});
+ it("shows the browsers' own folders under /opt, never /opt or /var/lib whole (issue #4011)", () => {
+ const plan = turn();
+ const text = bwrapArgs(plan).join(" ");
+ expect(text).not.toContain("--ro-bind /opt /opt");
+ expect(text).not.toContain("/var/lib");
+ expect(visibleInBox(plan, "/opt/other-service/.env"), "another service's files").toBe("none");
+ expect(visibleInBox(plan, "/var/lib/docker/volumes/one/_data")).toBe("none");
+ for (const root of BROWSER_ROOTS) expect(visibleInBox(plan, join(root, "chrome")), root).toBe("ro");
+ });
+
+ it("a code root under /opt is mounted itself, so a deb install's server code stays in the box", () => {
+ const plan = planBox({ ...setup(), codeRoots: ["/opt/OpenMausBot/resources"] }, { command: "/usr/bin/x", args: [], env: {} });
+ expect(visibleInBox(plan, "/opt/OpenMausBot/resources/dist-server/index.js")).toBe("ro");
+ });
+
it("a process the bot's conversations share sees all of that bot's conversation folders and uploads, and no other bot's", () => {
const plan = planBox(setup(), { command: "opencode", args: ["acp"], cwd, env: { HOME: home }, botThreads: true });
expect(plan.botId).toBe("bot-a");
diff --git a/server/bot-box/plan.ts b/server/bot-box/plan.ts
index 11904c4716..9a71eb4752 100644
--- a/server/bot-box/plan.ts
+++ b/server/bot-box/plan.ts
@@ -2,7 +2,8 @@
//
// What the box sees:
// - the image's code read-only: /usr (with /bin, /lib, /lib64 and /sbin as the links a merged-/usr Debian has), /etc,
-// /opt (the bots' browser) and the server's own code folder, so the engine CLIs and the proxies they start run;
+// the bots' browser folders under /opt and the server's own code folder, so the engine CLIs and the proxies they
+// start run; /opt and /var/lib themselves are not shown: on a self-hosted host they hold other services' files;
// - its HOME read-write (the engine's own login and settings live there), with the server's data folder replaced by an
// empty private folder, so messages.db, config.json, logins, other bots' folders and the server's sockets are not there;
// on a Team Cloud that HOME is the audience's engine home instead (server/engine-homes), with only the team's engine
@@ -207,6 +208,12 @@ export const PATH_ENV_NAMES = ["CLAUDE_CONFIG_DIR", "CODEX_HOME", "XDG_CONFIG_HO
* runtime) read `possible` at start and stop themselves (SIGABRT, exit 134) when it is missing. */
export const CPU_LIST_FILES = ["/sys/devices/system/cpu/possible", "/sys/devices/system/cpu/online"] as const;
+/** The bots' browser folders under /opt, the only part of it the box shows: the image's and deb's browser, and an
+ * installed Google Chrome. /opt and /var/lib are not bound whole (issue #4011): on a self-hosted host they hold other
+ * services' files a bot must not read. What an install needs beyond the browser is the server's own code, which
+ * `codeRoots` already carries. */
+export const BROWSER_ROOTS = ["/opt/openmausbot-browser", "/opt/google/chrome"] as const;
+
/** Folders the box always has its own copy of, so no setting may put the host's back. */
const PRIVATE_INSIDE = ["/tmp", "/var/tmp", "/run", "/dev", "/proc"];
@@ -232,13 +239,12 @@ export function planBox(setup: BoxSetup, request: BoxRequest, signIns?: SignInMa
{ kind: "symlink", link: "/lib64", target: "usr/lib64" },
{ kind: "symlink", link: "/sbin", target: "usr/sbin" },
{ kind: "ro", source: "/etc", target: "/etc" },
- { kind: "ro", source: "/opt", target: "/opt", optional: true },
- { kind: "ro", source: "/var/lib", target: "/var/lib", optional: true },
+ ...BROWSER_ROOTS.map((root): Mount => ({ kind: "ro", source: root, target: root, optional: true })),
...CPU_LIST_FILES.map((file): Mount => ({ kind: "ro", source: file, target: file, optional: true })),
];
for (const root of setup.codeRoots) {
const code = resolve(root);
- if (["/usr", "/etc", "/opt", "/var/lib"].some((base) => under(code, base))) continue;
+ if (["/usr", "/etc", ...BROWSER_ROOTS].some((base) => under(code, base))) continue;
mounts.push({ kind: "ro", source: code, target: code });
}
mounts.push({ kind: "proc", target: "/proc" }, { kind: "dev", target: "/dev" });
@@ -354,7 +360,7 @@ export function planBox(setup: BoxSetup, request: BoxRequest, signIns?: SignInMa
if (!named.has(full) && (under(full, dataDir) || under(dataDir, full)) && !covered(full) && !inBotFolder(full)) continue;
// Code and the system are already there; a file under HOME or /tmp the command line names is put back read-only.
if ((!asked.has(full) && covered(full)) || readOnly.has(full)) continue;
- if (["/usr", "/etc", "/opt", "/var/lib", ...setup.codeRoots, ...setup.engineRoots].some((base) => under(full, resolve(base)))) continue;
+ if (["/usr", "/etc", ...BROWSER_ROOTS, ...setup.codeRoots, ...setup.engineRoots].some((base) => under(full, resolve(base)))) continue;
readOnly.add(full);
mounts.push({ kind: "ro", source: full, target: full, optional: true });
}