ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(security): prevent command injection via hostname in Postfix install (GHSA-mc93-rc3x-fpgq)
Juan Denis20e79ff3636a
diff --git a/backend/app/services/postfix_service.py b/backend/app/services/postfix_service.pyindex ebbc9ce4..a90c9fe9 100644--- a/backend/app/services/postfix_service.py+++ b/backend/app/services/postfix_service.py@@ -131,12 +131,18 @@ mailbox_size_limit = 0def install(cls, hostname: str = None) -> Dict:"""Install Postfix."""try:- # Pre-seed debconf to avoid interactive prompts+ if hostname and not re.match(r'^[a-zA-Z0-9.-]+$', hostname):+ return {'success': False, 'error': 'Invalid hostname format'}++ # Pre-seed debconf to avoid interactive prompts. The values are+ # piped via stdin so no user input is ever interpolated into a+ # shell command string (GHSA-mc93-rc3x-fpgq).if PackageManager.detect() == 'apt':- run_privileged(['bash', '-c',- 'echo "postfix postfix/mailname string ' + (hostname or 'localhost') + '" | debconf-set-selections'])- run_privileged(['bash', '-c',- 'echo "postfix postfix/main_mailer_type select Internet Site" | debconf-set-selections'])+ debconf_lines = (+ f'postfix postfix/mailname string {hostname or "localhost"}\n'+ 'postfix postfix/main_mailer_type select Internet Site\n'+ )+ run_privileged(['debconf-set-selections'], input=debconf_lines)result = PackageManager.install(['postfix'], timeout=300)if result.returncode != 0: