Summary
MajorDoMo contains an unauthenticated OS command injection vulnerability where user-controlled input is interpolated directly into a shell command string and later executed with exec() without sanitization.
By abusing a web-accessible queue worker and a timing window in its polling loop, an attacker can inject shell metacharacters that are executed on the server within seconds, resulting in full remote code execution.
Affected context
The vulnerability occurs in MajorDoMo deployments where:
- The
rc/index.phpendpoint is exposed and accepts user-supplied parameters - The
$paramvalue is interpolated into a shell command within double quotes - Commands are queued via
safe_exec()and stored in a database table - The
cycle_execs.phpscript is web-accessible without authentication - The worker script uses
exec()to run queued commands without escaping or validation
In this context, any HTTP client that can reach these endpoints can influence shell commands executed by the server.
Exploit preconditions
- Attack surface: Public or internal HTTP access to both
rc/index.phpandcycle_execs.php. - Required access level: No authentication required; attacker only needs network reachability.
- Trigger point:
- Attacker first calls
cycle_execs.php, which:
- Empties the existing command queue
- Enters a polling loop querying for new commands
- While the worker is polling, attacker sends a request to
rc/index.phpwith a crafted$paramcontaining shell metacharacters. - The queued command is picked up and passed to
exec()while the polling loop is active.
- Why exploitation is possible:
- User input is embedded directly into a shell command within double quotes with no escaping (no
escapeshellarg()or equivalent). - The
safe_exec()function only enqueues the command and does not sanitize it. cycle_execs.phpretrieves the command and passes it straight toexec().- The polling loop creates a small race window during which newly queued commands are executed quickly, enabling predictable exploitation.
Why this happens
The underlying defect is a classic OS command injection pattern mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Instead of treating user-supplied data as opaque values, the code constructs a shell command by interpolating the $param variable inside double quotes. Double-quoted strings in the shell still interpret metacharacters such as command separators, subshells, and redirections when not properly escaped.
The abstraction layers (safe_exec() for queuing and cycle_execs.php as the worker) do not enforce any input validation, escaping, or parameterization. As a result, untrusted HTTP input flows unmodified into exec(), where the shell expands it as executable syntax. The command queue design further obscures the data flow, but does not mitigate the risk, because trust boundaries are not enforced at any stage.
Potential impact
- Remote execution of arbitrary OS commands with the privileges of the MajorDoMo process
- Full compromise of the underlying host (file read/write, lateral tooling installation)
- Exfiltration or tampering of application data and configuration
- Deployment of backdoors, cryptominers, or other persistent malware
- Use of the compromised host as a pivot point for lateral movement within the network
- Disruption of home automation or building management controlled by MajorDoMo
General mitigation guidance
Effective mitigation focuses on eliminating direct shell construction from untrusted input and tightening trust boundaries in the execution pipeline.
Recommended defensive patterns include:
- Avoid shell invocation for business logic: Prefer direct language-level APIs or libraries (e.g., PHP functions, database clients, HTTP clients) instead of wrapping operations in shell commands.
- Use safe command execution primitives: When shelling out is unavoidable, use interfaces that do not invoke a shell, or pass arguments as arrays so that the runtime handles escaping.
- Apply strict input validation and normalization: Constrain parameters to a whitelist of allowed values (enums, fixed command names, numeric identifiers) before they reach any execution path; reject or log unexpected patterns early.
- Isolate command builders and sanitize at the boundary: Centralize any command construction in a dedicated module that enforces
escapeshellarg()/equivalents and disallows shell metacharacters. - Enforce least privilege and isolation: Run the application and worker processes under minimally privileged accounts and, where feasible, inside containers or sandboxes to limit blast radius if an injection occurs.
- Harden auxiliary endpoints: Restrict access to worker scripts such as
cycle_execs.phpusing authentication, network ACLs, or moving them off the public attack surface.
How teams detect issues like this
Detection typically combines code-centric and behavioral approaches:
- Static analysis and linting:
- Flag use of
exec(),system(),shell_exec(), or backtick operators that are passed variables derived from request parameters. - Identify string concatenation or interpolation of untrusted input into command strings, especially when wrapped in quotes.
- Trace data flows from HTTP input (
$_GET,$_POST,$_REQUEST) through intermediate functions likesafe_exec()to any OS command execution APIs. - Targeted code review:
- Examine any queuing or scheduling frameworks that eventually trigger shell commands and confirm that input validation is applied before execution.
- Look for helper functions (e.g.,
safe_exec()) that imply safety but lack actual sanitization or validation logic. - Check that worker scripts (like
cycle_execs.php) are either non-public or enforce authentication and authorization. - Runtime and log analysis:
- Monitor logs for unusual commands or parameters containing shell metacharacters (e.g.,
;,&&,|, backticks). - Deploy endpoint detection tools or audit rules to alert on anomalous child processes spawned by the web server or PHP runtime.
- Automated review tools:
- Integrate SAST tools with rules for OS command injection patterns into CI pipelines.
- Use web application security scanners that specifically probe for command injection across accessible endpoints.

