Public: anyone can read this; the crew can change it.

A deployed forge's machine is hardened at boot: not root, firewalled, no pass… #16324

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16218-a-deployed-forge-s-machine-is-hardened-a → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/16218-a-deployed-forge-s-machine-is-hardened-a was merged into main as 0486fe4.

Review

Sign in to review this change.
2 files changed +30 −2
src/crew/sandbox_policy.ts +1 −1
@@ -94,5 +94,5 @@ export function reprober(o: {
9494
9595 /** Why a run waits, naming the cause the probe reported and what to do. */
9696 export function sandboxHoldSentence(reason: string): string {
97 return `this forge requires the agent sandbox and it is unavailable here (${sandboxCause(reason).words}); make the host able to run bubblewrap and socat, or set ${SANDBOX_ENV}=off to run the crew unrestricted on purpose.`;
97 return `this forge requires the agent sandbox and it is unavailable here (${sandboxCause(reason).words}); make the host able to run bubblewrap and socat (a forge deployed from another forge cannot set ${SANDBOX_ENV}: its owner loads the sandbox's AppArmor profile from the machine's console, which needs no restart, or asks the forge that deployed it to Update it); on a forge you run yourself, ${SANDBOX_ENV}=off runs the crew unrestricted on purpose.`;
9898 }
test/crew-sandbox-required.test.ts +29 −1
@@ -5,9 +5,11 @@ import { join } from "node:path";
55 import { createApp, type App } from "../src/app.ts";
66 import { createRun, getRun } from "../src/core/runs.ts";
77 import { createUser } from "../src/core/users.ts";
8 import { createToken } from "../src/core/tokens.ts";
9 import { serve } from "../src/http/server.ts";
810 import { pump } from "../src/crew/dispatch.ts";
outdated

Duplicate import from ../src/actions/talk.ts: TALK_WORDS is imported from the same module on line 12. Merge into one import.

911 import type { CrewOptions } from "../src/crew/runner.ts";
10 import { TALK_WORDS } from "../src/actions/talk.ts";
12 import { TALK_WORDS, talk } from "../src/actions/talk.ts";
1113 import { configureConversation, say, type ConversationOptions } from "../src/crew/conversation.ts";
1214 import { oneShot } from "../src/crew/one_shot.ts";
1315 import { DEFAULT_MODE, SANDBOX_REPROBE_MS, SANDBOX_UNPROVEN, noteSandbox, reprober, sandboxHoldSentence, sandboxMode, sandboxRefusal, type SandboxProbe } from "../src/crew/sandbox_policy.ts";
@@ -26,6 +28,9 @@ describe("FORGE_CREW_SANDBOX", () => {
2628 const words = sandboxHoldSentence("bwrap is not installed");
2729 expect(words).toContain("missing binary: bwrap");
2830 expect(words).toContain("FORGE_CREW_SANDBOX=off");
31 // A deployed forge cannot set it, and the sentence says what its owner can do instead.
32 expect(words).toContain("a forge deployed from another forge cannot set FORGE_CREW_SANDBOX");
33 expect(words).toContain("AppArmor profile");
2934 expect(words).not.toContain("\n");
3035 });
3136 test("the footer says refused, beside what runs uncontained", () => {
@@ -257,3 +262,26 @@ describe("the probe is taken again, at most once a minute and one at a time", ()
257262 expect(again()).toBe(true);
258263 });
259264 });
265
266 describe("Talk's doors answer a refused turn in the forge's own words", () => {
267 test("the API says 503 with the sentence, and nothing is started or kept", async () => {
268 const dir = await mkdtemp(join(tmpdir(), "forge-sandbox-door-"));
269 const door = createApp({ dataDir: dir, port: 0, host: "forge.test" });
270 const servers = await serve(door);
271 try {
272 const made = await createUser(door.db, { origin: "seed", trusted: true, username: "doorman", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
273 if (!made.ok) throw new Error(String(made.error));
274 const token = createToken(door.db, made.value.id, "personal", "rw").token;
275 configureConversation(door, { binary: "/nonexistent-agent", localUrl: servers.url, budgetUsd: 1, timeoutMs: 60_000, signal: new AbortController().signal });
276 noteSandbox(door, true, { ok: false, reason: "bwrap is not installed" }, () => {});
277 const res = await fetch(`${servers.url}/api/v1/conversation/messages`, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}` }, body: JSON.stringify({ text: "hello" }) });
278 expect(res.status).toBe(503);
279 expect(await res.text()).toContain("requires the agent sandbox");
280 expect(talk(door, made.value, "hello")).toEqual({ ok: false, error: "sandbox" });
281 expect((door.db.query("SELECT count(*) AS n FROM conversation_run").get() as { n: number }).n).toBe(0);
282 } finally {
283 await servers.stop();
284 await rm(dir, { recursive: true, force: true });
285 }
286 });
287 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs