From fb0eff7fd6c88614c2f74681a88354aafaede9e9 Mon Sep 17 00:00:00 2001 From: PlexicusAI Date: Tue, 1 Dec 2026 18:14:32 +0000 Subject: [PATCH] Fix for OS Command/Argument Injection in SSH PTY Spawn (CWE-78) --- docker/coolify-terminal/terminal-server.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/coolify-terminal/terminal-server.js b/docker/coolify-terminal/terminal-server.js index 068c449a909..e67fa262b42 100755 --- a/docker/coolify-terminal/terminal-server.js +++ b/docker/coolify-terminal/terminal-server.js @@ -448,7 +448,14 @@ async function handleCommand(ws, command, userId, terminalSessionId, reportEnd) commandTimeout, terminalSessionTimeout, }); - const ptyProcess = pty.spawn('ssh', sanitizedSshArgs.concat([hereDocContent]), options); + // The remote shell runs as `bash -se`/`sh -se`, which reads its script from stdin. Feed the + // here-doc body on stdin instead of as an extra ssh argument, so user-controlled command data + // never reaches the spawned process argument string (OS command/argument injection, CWE-78). + const ptyProcess = pty.spawn('ssh', sanitizedSshArgs, options); + + if (hereDocContent) { + ptyProcess.write(hereDocContent.endsWith('\n') ? hereDocContent : `${hereDocContent}\n`); + } userSession.ptyProcess = ptyProcess; userSession.isActive = true;