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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16218-a-deployed-forge-s-machine-is-hardened-a → main 0 commits fork 1 thread · 1 unresolved
2 files
changed +30
−2
src/crew/sandbox_policy.ts +1 −1
| @@ -94,5 +94,5 @@ export function reprober(o: { | ||
| 94 | 94 | |
| 95 | 95 | /** Why a run waits, naming the cause the probe reported and what to do. */ |
| 96 | 96 | 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.`; | |
| 98 | 98 | } |
test/crew-sandbox-required.test.ts +29 −1
| @@ -5,9 +5,11 @@ import { join } from "node:path"; | ||
| 5 | 5 | import { createApp, type App } from "../src/app.ts"; |
| 6 | 6 | import { createRun, getRun } from "../src/core/runs.ts"; |
| 7 | 7 | import { createUser } from "../src/core/users.ts"; |
| 8 | import { createToken } from "../src/core/tokens.ts"; | |
| 9 | import { serve } from "../src/http/server.ts"; | |
| 8 | 10 | import { pump } from "../src/crew/dispatch.ts"; |
| 9 | 11 | 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"; | |
| 11 | 13 | import { configureConversation, say, type ConversationOptions } from "../src/crew/conversation.ts"; |
| 12 | 14 | import { oneShot } from "../src/crew/one_shot.ts"; |
| 13 | 15 | 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", () => { | ||
| 26 | 28 | const words = sandboxHoldSentence("bwrap is not installed"); |
| 27 | 29 | expect(words).toContain("missing binary: bwrap"); |
| 28 | 30 | 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"); | |
| 29 | 34 | expect(words).not.toContain("\n"); |
| 30 | 35 | }); |
| 31 | 36 | 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", () | ||
| 257 | 262 | expect(again()).toBe(true); |
| 258 | 263 | }); |
| 259 | 264 | }); |
| 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 | }); |
new above
offline
Duplicate import from ../src/actions/talk.ts: TALK_WORDS is imported from the same module on line 12. Merge into one import.