Configuration-Dependent Unauthenticated Root RCE through the Setup Wizard

Summary

Milesight UG65/UG67 firmware 60.0.0.50 allows unauthenticated access to yruo_guide.set, even after setup is complete. An attacker can store shell syntax in an alarm email-group member and enable the power-on email event.

When SMTP/email is already enabled, the next reboot raises event 4019 and emaild inserts the stored member into a root shell command:

system("echo -e \"Subject: %s\n\n%s\" | msmtp %s -C /etc/msmtprc 2>%s", ...);

$() and backticks survive the group parser, resulting in command execution as root.

Classification

Field Value
Product Milesight UG65/UG67
Firmware 60.0.0.50
Authentication None
Impact Stored root command execution
CWE CWE-306, CWE-78
Prerequisite SMTP/email is already enabled
Trigger Reboot or equivalent power-on event
Tags unauthenticated, configuration_dependent, stored_payload, root_rce, tested

The wizard request does not enable SMTP. On a freshly initialized test overlay, /etc/msmtprc contained #enable no, and the stored payload did not execute until SMTP was enabled through the legitimate authenticated settings.

Attack chain

  1. POST /cgi calls yruo_guide.set without a session or ACL check.
  2. contack_info stores the attacker-controlled email-group member and enables email notification for events 4019 and 4020.
  3. The payload persists in /etc/quagga/email_groups.conf and is rebuilt into /etc/emaild_groups at boot.
  4. powerdetect raises event 4019 when it starts.
  5. emaild, running as root, expands the stored $() inside its msmtp shell command.

Proof of concept

python3 poc_ms11_wizard_rce.py 127.0.0.1:18443 \
  -c 'id > /www/duckie'

Prerequisites and trigger:

SMTP/email already enabled
payload planted without authentication
gateway rebooted, or event 4019 raised

Verified result:

# cat /www/duckie
uid=0(root) gid=0(root)

The same request on a fresh overlay with #enable no planted the payload but did not execute it. This negative control confirms the SMTP prerequisite.

Remediation

  1. Require an authenticated, authorized session for yruo_guide.set after initial setup.
  2. Validate email-group members as email addresses.
  3. Replace the emaild shell command with an argument-vector call to msmtp.
  4. Do not raise the power-on event unconditionally whenever powerdetect starts.

The MQTT notification finding reaches the same downstream emaild sink, but its primary eventcore injection executes immediately and does not require SMTP. See MQTT notifications.