diff --git a/server/src/__tests__/helpers/owned-linux/linux-command-relay.mjs b/server/src/__tests__/helpers/owned-linux/linux-command-relay.mjs index eb49e7d5c45..3f28312fa2c 100644 --- a/server/src/__tests__/helpers/owned-linux/linux-command-relay.mjs +++ b/server/src/__tests__/helpers/owned-linux/linux-command-relay.mjs @@ -28,7 +28,10 @@ try { || request.args.some(value => typeof value !== "string" || value.length > 131072)) throw fail("invalid_command_request"); witnessStage="resolve_cwd"; const cwd = await realpath(request.cwd ?? root); - if (cwd !== root && !cwd.startsWith(root + "/")) throw fail("foreign_command_cwd"); + // Public execute permits the literal container root as a stable command cwd. + // A different request path that resolves to root does not gain this exception. + const literalContainerRoot = request.cwd === "/" && cwd === "/"; + if (!literalContainerRoot && cwd !== root && !cwd.startsWith(root + "/")) throw fail("foreign_command_cwd"); witnessStage="validate_budget"; const deadline = request.timeoutMs; if (!Number.isSafeInteger(deadline) || deadline < 1 || deadline > 90000) throw fail("command_budget_invalid"); diff --git a/server/src/__tests__/native-workspace-sync.test.ts b/server/src/__tests__/native-workspace-sync.test.ts index cc50f547782..694cc74ae0c 100644 --- a/server/src/__tests__/native-workspace-sync.test.ts +++ b/server/src/__tests__/native-workspace-sync.test.ts @@ -353,10 +353,11 @@ describe("native workspace sync durable metadata", () => { const execute = vi.fn(async (request: { command: string; args?: string[]; cwd?: string; timeoutMs?: number; bypassSession?: boolean; }) => { - // Match the normal confined provider: omitted cwd uses its owned root; - // an explicit foreign cwd is refused before executing the real shell. + // The normal container provider accepts literal root as a stable cwd; + // other foreign paths and aliases to root remain refused. const cwd = await realpath(request.cwd ?? remoteRoot); - if (cwd !== remoteRoot && !cwd.startsWith(remoteRoot + path.sep)) throw new Error("foreign_command_cwd"); + const literalContainerRoot = request.cwd === "/" && cwd === "/"; + if (!literalContainerRoot && cwd !== remoteRoot && !cwd.startsWith(remoteRoot + path.sep)) throw new Error("foreign_command_cwd"); expect(request.timeoutMs).toBe(15_000); expect(request.bypassSession).toBe(true); try { @@ -391,7 +392,7 @@ describe("native workspace sync durable metadata", () => { ).resolves.toBe(true); expect(execute).toHaveBeenCalledTimes(2); - expect(execute.mock.calls.map(([request]) => request.cwd)).toEqual([undefined, undefined]); + expect(execute.mock.calls.map(([request]) => request.cwd)).toEqual(["/", "/"]); const remoteStamp = JSON.parse(await readFile(path.join(remoteCwd, ".paperclip-runtime", "paperclip-runner", "workspace-sync-v1.json"), "utf8")); expect(remoteStamp).toMatchObject({ hostSha256: finalHostSha256, finalizedRunId: descriptor.binding.runId }); expect(persistedLeaseMetadata).toMatchObject({ diff --git a/server/src/services/native-runtime/native-workspace-sync.ts b/server/src/services/native-runtime/native-workspace-sync.ts index 88d246d2057..82f703e98ca 100644 --- a/server/src/services/native-runtime/native-workspace-sync.ts +++ b/server/src/services/native-runtime/native-workspace-sync.ts @@ -707,6 +707,7 @@ async function writeRemoteStamp(input: { "-c", `umask 077; mkdir -p ${shellQuote(runtimeDir)} && printf %s ${shellQuote(encoded)} | base64 -d > ${shellQuote(tempPath)} && mv ${shellQuote(tempPath)} ${shellQuote(stampPath)}`, ], + cwd: "/", timeoutMs: 15_000, bypassSession: true, }); @@ -753,6 +754,7 @@ async function remoteStampMatches(input: { "-c", [...gitChecks, `test -f ${shellQuote(stampPath)}`, `cat ${shellQuote(stampPath)}`].join(" && "), ], + cwd: "/", timeoutMs: 15_000, bypassSession: true, });