Merge pull request #3529 from Dokploy/fix/prevent-send-malicious-bash

fix(wss): add container ID validation to enhance security in WebSocke…
This commit is contained in:
Mauricio Siu
2026-01-27 09:21:06 -06:00
committed by GitHub

View File

@@ -3,7 +3,7 @@ import { findServerById, IS_CLOUD, validateRequest } from "@dokploy/server";
import { spawn } from "node-pty";
import { Client } from "ssh2";
import { WebSocketServer } from "ws";
import { getShell } from "./utils";
import { getShell, isValidContainerId } from "./utils";
export const setupDockerContainerLogsWebSocketServer = (
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>,
@@ -42,6 +42,12 @@ export const setupDockerContainerLogsWebSocketServer = (
return;
}
// Security: Validate containerId to prevent command injection
if (!isValidContainerId(containerId)) {
ws.close(4000, "Invalid container ID format");
return;
}
if (!user || !session) {
ws.close();
return;