Summary
MariaDB Galera deployments with wsrep_notify_cmd enabled may execute shell commands embedded in the joiner node name, leading to arbitrary command execution on the server host.
This becomes especially risky in clustered environments where node names can be influenced by untrusted or partially trusted operators or automation.
Affected context
The vulnerability arises in MariaDB server deployments that:
- Run Galera-based clustering or similar replication with
wsrep_notify_cmdenabled - Pass node join/leave events into shell commands via
wsrep_notify_cmd - Incorporate the joiner node name into the command line without proper escaping or sanitization
It is most relevant where node names may be configured by scripts, orchestration systems, or administrators operating under weaker trust assumptions.
Exploit preconditions
- Attack surface: Cluster control and replication layer, specifically node join events.
- Required access: Ability to influence or set the joiner node's name, directly or via cluster/orchestration configuration.
- Trigger point: A vulnerable MariaDB node invokes
wsrep_notify_cmdwhen another node joins, passing the crafted node name into a shell command. - Why exploitation is possible: The joiner node name is interpolated into a shell command context without proper quoting or sanitization, allowing shell metacharacters in the name to be interpreted as additional commands.
Why this happens
The underlying bug class is command injection, as described by CWE-78: Improper Neutralization of Special Elements used in an OS Command.
MariaDB's wsrep_notify_cmd feature constructs a shell command using dynamic data (including the joiner node name) and delegates execution to the system shell.
Because node names are treated as trusted and incorporated directly into the command string, any shell metacharacters in that value can alter the intended command, leading to arbitrary command execution under the database server's OS account.
Potential impact
- Execution of arbitrary commands on the database server host
- Complete compromise of the MariaDB instance and underlying host OS
- Exfiltration or destruction of database contents
- Pivoting to other systems reachable from the compromised host
- Disruption of high-availability clusters and potential data loss
General mitigation guidance
Effective mitigation focuses on reducing trust in dynamic inputs and avoiding direct shell invocation when handling cluster events.
Common defensive patterns include:
- Disabling optional features that execute shell commands with dynamic parameters when not strictly necessary (such as
wsrep_notify_cmd) - Using dedicated, parameterized interfaces (e.g., scripts that accept arguments as positional parameters, not via string concatenation) rather than constructing raw shell command strings
- Strictly validating and constraining node names to a safe character set (for example, alphanumerics and limited punctuation) before they are used in any OS-level context
- Running database services and any notification scripts with least-privilege OS accounts to limit blast radius if a command injection occurs
- Separating monitoring/notification responsibilities from the database process where possible, so cluster events are not handled directly via shell
How teams detect issues like this
Organizations can detect similar issues and manifestations of this vulnerability by:
- Reviewing configuration for features that execute shell commands (
wsrep_notify_cmd, hooks, notification scripts) and checking how user-controlled or environment-derived values are passed to them - Applying static analysis or linters to deployment and automation scripts to flag string-based command construction and unquoted interpolation of variables
- Conducting focused code and configuration reviews for Galera/MariaDB cluster setups, paying attention to any integration points with the shell
- Enforcing security policies that forbid arbitrary shell commands in production database configurations unless explicitly reviewed and approved
- Monitoring logs and process execution (e.g., via auditd or EDR tools) for unexpected commands originating from database processes or notification scripts

