fix(settings): validate host canary integrity across sandbox backends

This commit is contained in:
Xubin Ren committed 2026-11-08 14:29:46 +08:00
1 parent a666948509
commit fb159257cb
3 files changed
+14 -2

No files matched your search

+3 -1
View File
@@ -74,7 +74,9 @@ async def check_sandbox(config: ExecToolConfig, workspace: Path) -> SandboxCheck
script = (
"printf checked > inside && "
f"! test -r {shlex.quote(str(canary))} && "
f"! (printf changed > {shlex.quote(str(canary))})"
# bwrap may allow writing a new file in its private tmpfs at the
# same path. What must stay unchanged is the host-side canary.
f"(printf changed > {shlex.quote(str(canary))} || true)"
)
argv = shlex.split(wrap_command(
config.sandbox, script, str(project), str(project),
@@ -90,7 +90,7 @@ export function SandboxSettings({ settings, state, client, isRestarting, childre
<div className="flex items-start gap-2 text-ui leading-6 text-muted-foreground">
{checking ? <Loader2 className="mt-1 h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none" aria-hidden />
: status === "passed" ? <ShieldCheck className="mt-1 h-4 w-4 shrink-0" aria-hidden /> : <CircleAlert className="mt-1 h-4 w-4 shrink-0" aria-hidden />}
<p>{reason ? t(`settings.sandbox.reasons.${reason}`, { defaultValue: tx("reasons.unknown") }) : tx(`help.${dirty ? "unsaved" : status}`)}</p>
<p>{!saved.supported_backend && enabled ? tx("help.unsupported") : reason ? t(`settings.sandbox.reasons.${reason}`, { defaultValue: tx("reasons.unknown") }) : tx(`help.${dirty ? "unsaved" : status}`)}</p>
</div>
{launcher ? <p className="mt-2 break-all font-mono text-caption text-muted-foreground">{launcher}</p> : null}
<p className="mt-2 text-caption leading-5 text-muted-foreground">{tx("scope")}</p>
+10
View File
@@ -94,6 +94,16 @@ describe("Saved sandbox settings", () => {
expect(screen.queryByRole("button", { name: "Check sandbox" })).not.toBeInTheDocument();
});
it("does not tell an unsupported host with isolation off to choose a sandbox", () => {
const settings = payload();
settings.runtime_config!["tools.exec.sandbox"] = "";
settings.advanced.exec_sandbox_status = { ...settings.advanced.exec_sandbox_status!, state: "off", reason: "", supported_backend: null };
renderSettingsView({ initialSection: "advanced", initialSettings: settings, webuiCapabilities: capability });
expect(screen.getByText("This isolation method is not supported on the gateway’s operating system.")).toBeVisible();
expect(screen.queryByText(/Choose an isolation method/)).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Check sandbox" })).not.toBeInTheDocument();
});
it("ignores a completed probe from the previously selected host", async () => {
let finish!: (response: unknown) => void;
const first = { requestMutation: vi.fn(() => new Promise((resolve) => { finish = resolve; })) } as unknown as NanobotClient;