Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docker/coolify-terminal/terminal-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down