fix(security): enforce sandbox inheritance for sessions_spawn

This commit is contained in:
Peter Steinberger
2026-03-02 01:10:39 +00:00
parent 6a1eedf10b
commit b9aa2d436b
6 changed files with 57 additions and 0 deletions

View File

@@ -154,4 +154,41 @@ describe("openclaw-tools: subagents (sessions_spawn allowlist)", () => {
acceptedAt: 5200,
});
});
it("forbids sandboxed cross-agent spawns that would unsandbox the child", async () => {
setSessionsSpawnConfigOverride({
session: {
mainKey: "main",
scope: "per-sender",
},
agents: {
defaults: {
sandbox: {
mode: "all",
},
},
list: [
{
id: "main",
subagents: {
allowAgents: ["research"],
},
},
{
id: "research",
sandbox: {
mode: "off",
},
},
],
},
});
const result = await executeSpawn("call11", "research");
const details = result.details as { status?: string; error?: string };
expect(details.status).toBe("forbidden");
expect(details.error).toContain("Sandboxed sessions cannot spawn unsandboxed subagents.");
expect(callGatewayMock).not.toHaveBeenCalled();
});
});