From cd5ebe083cfd61e49ab7ea5fef186457f049dce9 Mon Sep 17 00:00:00 2001 From: Augustin Date: Wed, 22 Apr 2026 18:56:33 +0200 Subject: [PATCH] fix(terminal): ignore invalid shell config from race condition Reject shell paths with length <= 1 to prevent errors when user input is accidentally sent as init message. Assisted-by: MiniMax-M2.7 via Crush --- internal/api/terminal.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/api/terminal.go b/internal/api/terminal.go index 2d56ea6..90a5a12 100644 --- a/internal/api/terminal.go +++ b/internal/api/terminal.go @@ -105,6 +105,12 @@ func (s *Server) handleTerminalWS(w http.ResponseWriter, r *http.Request) { } } + // Ignore invalid shell paths (e.g., single characters from race condition) + if len(shell) <= 1 { + conn.WriteJSON(wsMessage{Type: "error", Data: "invalid shell config"}) + return + } + if _, err := os.Stat(shell); err != nil { conn.WriteJSON(wsMessage{Type: "error", Data: fmt.Sprintf("shell not found: %s", shell)}) return