Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix: harden SSH config endpoint per Codex security review
rcourtman71abcb2a37bc
diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.goindex 1fc3453772..54511ad989 100644--- a/internal/api/config_handlers.go+++ b/internal/api/config_handlers.go@@ -3930,17 +3930,39 @@ elif [ "$TEMP_MONITORING_AVAILABLE" = true ]; thenecho ""echo "Configuring automatic SSH ProxyJump for containerized Pulse..."+ # Get list of all cluster nodes (or just this node if standalone)+ ALL_NODES="${PROXY_JUMP_HOST}"+ if command -v pvecm >/dev/null 2>&1; then+ CLUSTER_OUTPUT=$(pvecm nodes 2>/dev/null || true)+ if [ -n "$CLUSTER_OUTPUT" ]; then+ CLUSTER_NODES=$(echo "$CLUSTER_OUTPUT" | awk 'NR>1 && $1 ~ /^[0-9]+$/ {print $3}')+ if [ -n "$CLUSTER_NODES" ]; then+ ALL_NODES="$CLUSTER_NODES"+ fi+ fi+ fi+# Create SSH config that uses this Proxmox host as jump point+ # Only scope ProxyJump to the specific Proxmox nodes, not all hostsSSH_CONFIG="Host ${PROXY_JUMP_HOST}HostName ${PROXY_JUMP_IP}User rootIdentityFile ~/.ssh/id_ed25519--Host *+ StrictHostKeyChecking accept-new+"++ # Add ProxyJump config for each cluster node+ for NODE in $ALL_NODES; do+ if [ "$NODE" != "$PROXY_JUMP_HOST" ]; then+ SSH_CONFIG="${SSH_CONFIG}+Host ${NODE}ProxyJump ${PROXY_JUMP_HOST}User rootIdentityFile ~/.ssh/id_ed25519- StrictHostKeyChecking accept-new"+ StrictHostKeyChecking accept-new+"+ fi+ done# Write SSH config to Pulse container# This will be written to /home/pulse/.ssh/config inside the containerdiff --git a/internal/api/system_settings.go b/internal/api/system_settings.goindex 592dbd9809..a053ab6b06 100644--- a/internal/api/system_settings.go+++ b/internal/api/system_settings.go@@ -8,6 +8,7 @@ import ("net/http""os""path/filepath"+ "strings""time""github.com/rcourtman/pulse-go-rewrite/internal/config"@@ -458,6 +459,9 @@ func (h *SystemSettingsHandler) HandleSSHConfig(w http.ResponseWriter, r *http.Rreturn}+ // Limit request body to 32KB to prevent memory exhaustion+ r.Body = http.MaxBytesReader(w, r.Body, 32*1024)+// Read SSH config content from request bodysshConfig, err := io.ReadAll(r.Body)if err != nil {@@ -466,6 +470,29 @@ func (h *SystemSettingsHandler) HandleSSHConfig(w http.ResponseWriter, r *http.Rreturn}+ // Basic validation: ensure it looks like SSH config+ configStr := string(sshConfig)+ if len(configStr) == 0 {+ log.Error().Msg("Empty SSH config received")+ http.Error(w, "Empty SSH config", http.StatusBadRequest)+ return+ }++ // Security: Reject dangerous SSH directives+ dangerousDirectives := []string{+ "ProxyCommand",+ "LocalCommand",+ "RemoteCommand",+ "PermitLocalCommand",+ }+ for _, directive := range dangerousDirectives {+ if strings.Contains(configStr, directive) {+ log.Warn().Str("directive", directive).Msg("Rejected SSH config with dangerous directive")+ http.Error(w, "SSH config contains forbidden directive", http.StatusBadRequest)+ return+ }+ }+// Get the Pulse user's home directoryhomeDir := os.Getenv("HOME")if homeDir == "" {@@ -488,7 +515,8 @@ func (h *SystemSettingsHandler) HandleSSHConfig(w http.ResponseWriter, r *http.Rreturn}- log.Info().Str("path", configPath).Msg("SSH config written successfully")- w.WriteHeader(http.StatusOK)- json.NewEncoder(w).Encode(map[string]bool{"success": true})+ log.Info().Str("path", configPath).Int("size", len(sshConfig)).Msg("SSH config written successfully")+ if err := json.NewEncoder(w).Encode(map[string]bool{"success": true}); err != nil {+ log.Error().Err(err).Msg("Failed to encode success response")+ }}