From f0ec82005446d51434816e5d64b74e3d0c0ea602 Mon Sep 17 00:00:00 2001 From: "Kai (Tam Nhu) Tran" <61256810+kaitranntt@users.noreply.github.com> Date: Sat, 23 May 2026 16:54:13 -0400 Subject: [PATCH] fix(cliproxy): disable spoofable default bg keepalive probe (#1340) --- src/cliproxy/executor/session-bridge.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cliproxy/executor/session-bridge.ts b/src/cliproxy/executor/session-bridge.ts index c160de2a..4b181903 100644 --- a/src/cliproxy/executor/session-bridge.ts +++ b/src/cliproxy/executor/session-bridge.ts @@ -275,12 +275,13 @@ export function setupCleanupHandlers( } }; - const backgroundProbe = - keepAliveOptions.hasBackgroundWorkerUsingBaseUrl ?? hasClaudeBackgroundWorkerUsingBaseUrl; + // Security hardening: only allow keepalive when caller provides an explicit, + // trusted detector. Falling back to global process-list probing is spoofable. + const backgroundProbe = keepAliveOptions.hasBackgroundWorkerUsingBaseUrl; const startKeepAliveWatcher = (baseUrl: string) => { const timer = setInterval(() => { - if (backgroundProbe(baseUrl)) return; + if (backgroundProbe?.(baseUrl)) return; log('No Claude bg worker is using the session proxy; cleaning up'); stopSessionResources(); process.exit(0); @@ -299,6 +300,7 @@ export function setupCleanupHandlers( const backgroundKeepAliveBaseUrl = keepAliveOptions.backgroundKeepAliveBaseUrl; if ( + backgroundProbe && shouldKeepSessionProxiesAlive({ code, signal,