From ce107d4710dfa89b9a7307f4ee9bf3af50889793 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sat, 10 Oct 2026 12:27:28 -0500 Subject: [PATCH] fix: validate persisted warm origin run identity Co-Authored-By: Paperclip --- .../services/native-runtime/native-session-executor.test.ts | 3 ++- server/src/services/native-runtime/native-session-executor.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index f0c8933da5..6aad086d79 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -13459,6 +13459,7 @@ describe("runnerd provider runtime wiring", () => { { condition: "workspace-coordinate", expected: "verified" }, { condition: "warm-origin", expected: "verified" }, { condition: "origin-other-session", expected: "scope_mismatch" }, + { condition: "origin-wrong-profile-run", expected: "scope_mismatch" }, { condition: "origin-other-owner", expected: "scope_mismatch" }, { condition: "origin-newer-generation", expected: "scope_mismatch" }, { condition: "origin-active", expected: "scope_mismatch" }, @@ -13487,7 +13488,7 @@ describe("runnerd provider runtime wiring", () => { const originDescriptor = { ...descriptor, leaseId: "origin-lease", providerLeaseId: condition === "origin-other-owner" ? "other-owner" : owner.ownerId, ownerGeneration: condition === "origin-newer-generation" ? 3 : 1 }; - const originRow = { status: condition === "origin-active" ? "running" : "succeeded", + const originRow = { id: condition === "origin-wrong-profile-run" ? "other-run" : originExecution.binding.runId, status: condition === "origin-active" ? "running" : "succeeded", runnerProfileJson: { nativeExecutionInput: originExecution, nativeComputerWorkspace: originDescriptor } }; const workspaceCoordinate = ["workspace-coordinate", "wrong-workspace-run"].includes(condition); const db = { select: () => ({ from: (table: unknown) => ({ where: (query: SQL) => { if (table === environmentLeases) leaseQuery = query; return ({ limit: async (limit: number) => diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index 55ee4680f1..77ba1f719d 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -4397,6 +4397,7 @@ export async function verifyPriorRunnerdStateForSessionScope(input: { // workspace coordinate. Resolve that recorded origin, never an arbitrary // run ID, before checking the physical lease and latest retirement. const origins = await input.db.select({ + id: heartbeatRuns.id, status: heartbeatRuns.status, runnerProfileJson: heartbeatRuns.runnerProfileJson, }).from(heartbeatRuns).where(and( @@ -4412,6 +4413,7 @@ export async function verifyPriorRunnerdStateForSessionScope(input: { const originExecution = parseNativeExecutionInput(originProfile.nativeExecutionInput); const originWorkspace = readNativeComputerWorkspaceReference(originProfile.nativeComputerWorkspace); if (!TERMINAL_HEARTBEAT_RUN_STATUSES.has(origin.status) || + originExecution.binding.runId !== origin.id || originExecution.binding.executionWorkspaceId !== input.identity.environmentLeaseId || nativeSessionScopeKey(originExecution) !== nativeSessionScopeKey(priorExecution) || !originWorkspace || originWorkspace.remoteCwd !== priorWorkspace.remoteCwd ||