Summary
Cockpit contains an OS command injection vulnerability in its system logs UI, where user-controlled parameters from crafted links are incorporated into shell commands without proper sanitization.
A remote attacker who can get such crafted values processed by the UI can inject shell metacharacters and command substitutions, resulting in arbitrary command execution on the host and potential full system compromise.
Affected context
The vulnerability arises in Cockpit deployments where the system logs UI processes user-controlled parameters taken from links or log entries and forwards them to shell commands.
It is relevant when:
- Cockpit is exposed over the network and accessible to users or external systems
- Log-related operations or helpers invoke shell commands using these parameters
- Input is passed to the shell without robust escaping or argument separation
The issue does not depend on a specific platform but on the presence of shell invocation with untrusted data in the system logs UI handling.
Exploit preconditions
- Attack surface: Network-accessible Cockpit web interface, specifically the system logs UI.
- Required access: Ability to influence or provide values used in crafted links or log entries that the system logs UI will process (e.g., via remote log sources, services that log attacker-controlled data, or crafted URLs).
- Trigger point: A Cockpit user or automated process causes the system logs UI to process and act on log entries or links containing attacker-controlled parameters.
- Why exploitation is possible: The application composes shell commands using these parameters without strict validation, proper escaping, or use of safe non-shell invocation APIs, allowing shell metacharacters and command substitution syntax to be interpreted by the shell.
Why this happens
This vulnerability is rooted in OS command injection (CWE-78).
The system logs UI code path constructs shell commands that include data derived from user-controlled parameters, likely by concatenating strings or passing them through the shell rather than as discrete, safely escaped arguments.
When input containing shell metacharacters or command substitution is passed directly to a shell, the shell parses and executes the injected fragments as part of the command.
Abstractly, this is the insecure pattern where untrusted input is treated as part of a command line, allowing the interpreter (shell) to interpret control characters and execute additional commands.
Potential impact
- Execution of arbitrary commands with the privileges of the Cockpit backend process.
- Complete compromise of the underlying host system, including installation of backdoors or malware.
- Exfiltration or tampering of sensitive data and configuration files.
- Lateral movement to other systems through stolen credentials or pivoting from the compromised host.
- Disruption of services, including stopping critical processes or wiping data.
General mitigation guidance
Effective mitigation focuses on removing direct shell interpretation of untrusted input and hardening how commands are invoked:
- Prefer APIs that execute commands without a shell (e.g., process execution interfaces that take argument arrays and do not invoke a shell parser).
- When a shell cannot be avoided, apply strict allowlist-based validation of all parameters, rejecting or normalizing any unexpected characters or patterns.
- Treat all log-derived values as untrusted; do not blindly propagate log fields into command lines, and avoid passing them through to the shell at all.
- Apply the principle of least privilege to the Cockpit backend so that, if command execution is abused, the blast radius is reduced.
- Separate responsibilities so that UI-triggered actions operate through narrowly scoped services with limited, predefined commands instead of generic shell access.
How teams detect issues like this
Detection typically combines code-level analysis with runtime monitoring:
- Use static analysis rules to flag string concatenation or template-based construction of shell commands that include request parameters, log-derived fields, or other untrusted sources.
- During code review, watch for use of generic shell execution APIs (e.g., system-like calls, shell=True-style helpers) in UI or log-handling paths, and require justification or refactoring to safer patterns.
- Enforce development policies that prohibit direct shell invocation with untrusted data and require argument-based process execution APIs by default.
- Employ security testing (including fuzzing and dynamic analysis) against the system logs UI to identify inputs that cause unexpected command behavior.
- Centralized logging and host-based intrusion detection can be configured to alert on anomalous command patterns originating from Cockpit-related processes.

