From af7aa0c2dda834237a3aa79661cd62d096c32876 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:48 -0400 Subject: [PATCH] fix(cliproxy): sanitize local port before config regeneration (#1342) --- src/web-server/routes/proxy-routes.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/web-server/routes/proxy-routes.ts b/src/web-server/routes/proxy-routes.ts index a98867ed..8032149a 100644 --- a/src/web-server/routes/proxy-routes.ts +++ b/src/web-server/routes/proxy-routes.ts @@ -155,8 +155,9 @@ router.put('/backend', (req: Request, res: Response) => { // Pre-flight read: check running state before acquiring write lock const currentConfig = loadOrCreateUnifiedConfig(); const currentBackend = currentConfig.cliproxy?.backend ?? DEFAULT_BACKEND; - const localPort = - currentConfig.cliproxy_server?.local?.port ?? DEFAULT_CLIPROXY_SERVER_CONFIG.local.port; + const localPort = validatePort( + currentConfig.cliproxy_server?.local?.port ?? DEFAULT_CLIPROXY_SERVER_CONFIG.local.port + ); if (currentBackend !== backend && isProxyRunning() && !force) { res.status(409).json({ error: 'Proxy is running. Stop proxy first or use force=true to change backend.',