From ce6e47e35d7a0ebbb6887d7a45215c4dd91b3d4d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:15:48 +0000 Subject: [PATCH] Validate non-empty runtime websocket auth token Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 10 ++++++++++ apps/t3/src/runtimeApiServer.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 61b3049253..60a7a3a589 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -106,6 +106,16 @@ afterEach(async () => { }); describe("runtimeApiServer", () => { + it("rejects empty auth token configuration", async () => { + await expect( + startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + authToken: " ", + }), + ).rejects.toThrow("Invalid runtime auth token"); + }); + it("responds to todos.list over websocket RPC", async () => { const server = await startRuntimeApiServer({ port: 0, diff --git a/apps/t3/src/runtimeApiServer.ts b/apps/t3/src/runtimeApiServer.ts index 66a6b0f7c7..5511e18c46 100644 --- a/apps/t3/src/runtimeApiServer.ts +++ b/apps/t3/src/runtimeApiServer.ts @@ -278,7 +278,10 @@ export async function startRuntimeApiServer( options: RuntimeApiServerOptions, ): Promise { const launchCwd = path.resolve(options.launchCwd); - const authToken = options.authToken; + const authToken = options.authToken?.trim(); + if (options.authToken !== undefined && !authToken) { + throw new Error("Invalid runtime auth token: expected non-empty string."); + } const bootstrapSessionTimeoutMs = options.bootstrapSessionTimeoutMs ?? BOOTSTRAP_SESSION_TIMEOUT_MS; const providerManager = new ProviderManager();