Summary
Network UPS Tools (NUT) can pass a server-supplied UPS alarm value into shell commands when upsmon handles notifications. If an alarm is processed with an EXEC notification configured, crafted shell metacharacters may allow command execution with the privileges of the upsmon account, which is commonly root.
Affected context
The issue occurs in upsmon notification handling in clients/upsmon.c, where the ups.alarm value supplied by the server is incorporated into shell commands. It affects the described NUT versions 2.8.3 through 2.8.5 when a monitored device reports an ALARM state and the operator has configured NOTIFYCMD with EXEC in NOTIFYFLAG ALARM. The alarm value may originate from a malicious or compromised upsd, a compromised UPS device, or a plaintext connection exposed to an on-path attacker.
Exploit preconditions
- Attack surface: The upsmon notification path for monitored UPS devices.
- Required access: Ability to influence the alarm value supplied to upsmon, such as through a malicious or compromised upsd, a compromised UPS device, or an on-path position on a plaintext connection.
- Trigger point: A monitored device reports an ALARM state while
NOTIFYFLAG ALARMenablesEXECfor the configuredNOTIFYCMD. - Why exploitation is possible: The server-supplied alarm text is inserted into shell commands without adequate protection against shell metacharacters. Successful command execution runs with the upsmon account's privileges.
Why this happens
The notification code treats a server-supplied alarm string as safe to embed in a shell command. Shell metacharacters in that string can alter the command's meaning when the shell interprets it, which maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command. This is a command-construction and input-trust boundary failure.
Potential impact
- An attacker may execute arbitrary operating-system commands as the upsmon account.
- If upsmon runs with root privileges, an attacker could gain root-level control of the host.
- An attacker could disrupt UPS monitoring or alter system configuration.
- A compromised host could be used to access other systems or sensitive data.
General mitigation guidance
Defensive patterns focus on avoiding shell interpretation of externally influenced data and limiting the consequences of compromise.
- Prefer direct process execution with fixed arguments over constructing shell command strings.
- If shell invocation cannot be avoided, use robust argument-escaping mechanisms appropriate to the platform and validate input against a narrow expected format.
- Treat alarm text from servers, devices, and network connections as untrusted, including when transport encryption is enabled.
- Restrict notification command configuration and run monitoring processes with only the privileges they need.
- Use authenticated, encrypted connections where appropriate, while recognizing that transport protection does not address compromised upstream devices.
How teams detect issues like this
- Use static analysis to identify shell execution APIs that receive strings containing externally sourced values.
- Review notification handling for command construction, especially paths that incorporate server- or device-supplied alarm text.
- Check configuration and deployment policies for EXEC notification settings and unnecessary privileges assigned to monitoring processes.
- Monitor process creation and command execution by upsmon for unexpected activity.
- Automated code review tools can help flag shell invocation patterns and untrusted data flows.

