Summary
High-privileged MariaDB users can abuse Galera State Snapshot Transfer (SST) configuration variables to inject and execute arbitrary shell commands on a joiner node.
When these cluster variables are constructed from untrusted input and passed to the underlying shell without strict validation, an attacker can run commands as the MariaDB daemon user.
Affected context
This vulnerability arises in MariaDB deployments using Galera clustering where State Snapshot Transfer (SST) is configured and controlled via global system variables such as wsrep_sst_receive_address and wsrep_sst_donor.
The risk materializes when high-privileged database accounts can modify these variables and the SST mechanism subsequently uses their values to build shell-level commands on a joiner node.
Environments that rely on automated or dynamic configuration of cluster addresses without robust input constraints are particularly exposed.
Exploit preconditions
- Attack surface: MariaDB SQL interface on a Galera cluster node where SST can be triggered.
- Required access: High-privileged MariaDB account capable of setting global system variables (e.g., SUPER or equivalent administrative privileges).
- Trigger point: Execution of Galera SST operations in which the values of
wsrep_sst_receive_addressorwsrep_sst_donorare consulted to build shell commands for snapshot transfer. - Why exploitation is possible: User-controlled values are incorporated into shell command strings without adequate sanitization or strict parameterization, allowing crafted data to break out of expected argument boundaries and introduce attacker-defined commands.
Why this happens
The underlying flaw is a classic OS command injection pattern, mapping to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
MariaDB's Galera SST mechanism appears to construct shell commands using configuration values from global system variables and executes them with the privileges of the MariaDB daemon user.
Because these variable values are not fully constrained to safe formats (e.g., strictly validated addresses or identifiers) and are instead treated as raw command fragments or arguments, special shell metacharacters and additional tokens can alter the command's structure.
This design couples configuration data directly with shell execution logic, breaking the separation between data and code and enabling arbitrary command execution in contexts where an attacker has sufficient database-level privileges.
Potential impact
- Execution of arbitrary shell commands as the MariaDB daemon user on Galera joiner nodes.
- Installation of backdoors, web shells, or persistence mechanisms on affected database servers.
- Exfiltration, tampering, or destruction of database files and configuration data.
- Lateral movement within the infrastructure using the database server as a pivot.
- Disruption of cluster availability through destructive or resource-exhausting commands.
General mitigation guidance
Effective mitigation focuses on ensuring that configuration values cannot influence shell commands in an unsafe way and that privileged access is tightly controlled.
Recommended defensive patterns include:
- Designing SST and similar subsystems to avoid direct shell invocation where possible, or to rely on fully parameterized execution APIs that never concatenate raw strings into commands.
- Restricting global system variables used by cluster components to strictly validated formats (e.g., IP/host:port syntax) and rejecting any value containing shell metacharacters or unexpected characters.
- Enforcing principle of least privilege for administrative database accounts, minimizing the number of roles that can modify SST-related global variables.
- Isolating Galera nodes using network segmentation and tightening OS-level permissions and SELinux/AppArmor profiles so that the database daemon has limited ability to affect the broader system.
- Incorporating security reviews for any feature that takes database-level configuration and passes it into external processes, ensuring a clear boundary between data and executable context.
How teams detect issues like this
Detection efforts can combine configuration review, audit logging, and code-level analysis:
- Static analysis and code review: Look for code paths that:
- Construct shell commands using values from global system variables or configuration tables.
- Build command strings through concatenation or string formatting instead of parameterized execution functions.
- Do not apply rigorous validation or normalization to configuration values before invoking external processes.
- Configuration auditing: Regularly inspect
wsrep_sst_receive_address,wsrep_sst_donor, and related variables for unusual content such as shell metacharacters, multiple commands, or non-standard address formats. - Behavioral monitoring: Monitor SST operations and system logs for anomalous command invocations, unexpected subprocess executions, or unusual network connections originating from MariaDB processes.
- Policy enforcement and CI checks: Integrate automated checks in development pipelines to flag patterns where database configuration is passed to shell commands without validation, and use security linting tools that specialize in command construction and subprocess usage.

