/

CVE-2026-32608

Severity:

HIGH RISK

(7.0)

Command Injection in Glances Monitoring

CVE-2026-32608

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution in the Monitoring Environment

Severity:

HIGH RISK

(7.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Glances' alert action system allows administrators to configure shell commands that include Mustache template variables populated from runtime monitoring data.

Before version 4.5.2, unsafe splitting of the rendered command string allowed attacker-controlled values such as process or container names to inject additional commands when special shell metacharacters were present.

Affected context

This vulnerability appears when Glances is configured with alert or action commands that interpolate runtime values using Mustache templates (for example {{name}} or {{key}}).

The issue is relevant in environments where untrusted actors can influence monitored attributes such as process names, filesystem mount points, container names, or similar metadata used in those templates.

When these values include shell metacharacters (like pipes, redirects, or command chaining operators), the internal parsing performed by secure_popen() can misinterpret them as control operators, despite using subprocess.Popen(shell=False).

Exploit preconditions

  • Attack surface: Glances alert/action command processing path.
  • Required access: Ability to control runtime values that are interpolated into action commands (e.g., process name, container name, mount point, or other Mustache-backed fields).
  • Configuration requirement: Glances must have one or more action commands configured that embed Mustache variables derived from attacker-influenced fields.
  • Trigger point: A monitoring threshold or condition must be reached so that Glances executes the configured action command.
  • Why exploitation is possible: secure_popen() performs its own parsing for pipes, redirects, and chaining by splitting the fully rendered command string. If an attacker-controlled value contains these metacharacters, the splitting logic treats them as structural delimiters, effectively appending or altering commands that will be executed as separate subprocesses.

Why this happens

The underlying bug is a form of command injection (CWE-78) caused by custom command parsing applied to untrusted, templated input.

Glances renders Mustache templates into a single command string, then attempts to emulate shell pipe/redirect/chain behavior by manually splitting that string before passing components to subprocess.Popen(shell=False).

Because this parsing treats characters such as |, >, <, ;, or similar operators as structural separators, any unescaped instance of these characters in attacker-controlled template values is interpreted as part of the command structure rather than data.

This design couples user-influenced data with command syntax, violating the principle of strict separation between code and data and reintroducing shell-like injection risks even though the underlying Popen invocation disables the shell.

Potential impact

  • Execution of arbitrary commands with the privileges of the Glances monitoring process.
  • Lateral movement within the monitored host or container, including reconnaissance and data exfiltration.
  • Tampering with monitoring data or log files to hide malicious activity.
  • Use of the monitoring service as a foothold for further compromise in multi-tenant or shared environments.

General mitigation guidance

Effective mitigation centers on treating all templated command parameters as untrusted data and eliminating custom shell-like parsing:

  • Prefer structured command execution by building argument lists programmatically (e.g., ["/usr/bin/script", param1, param2]) instead of composing and post-processing a single command string.
  • Avoid implementing custom parsing of pipe, redirect, or chaining operators; instead, model multi-step actions as explicit sequences of subprocess calls or internal logic.
  • Strictly validate or sanitize data that may be interpolated into action templates, ensuring that shell metacharacters are either rejected or safely encoded before use.
  • Limit the set of fields allowed in action templates to those not under direct user or tenant control, reducing the risk of hostile data influencing command construction.
  • Run Glances with the least privileges necessary, and consider system-level controls (such as restricted PATH, AppArmor/SELinux profiles, or containerization) to constrain the impact of misconfigured or abused actions.

How teams detect issues like this

Identifying this class of issue generally involves a combination of code analysis and configuration review:

  • Static analysis: Flag patterns where:
  • Command strings are assembled from templates or formatted strings including runtime values; and
  • Custom parsing of shell metacharacters occurs prior to subprocess calls, even when shell=False is used.
  • Code review signals: Look for wrapper utilities around process execution (like secure_popen()), especially those that:
  • Split on characters such as |, ;, &&, <, or >, or
  • Attempt to emulate shell features at the string level.
  • Configuration auditing: Search Glances configuration files for action commands that interpolate Mustache variables tied to user- or tenant-influenced attributes (process names, container names, labels, or mount points).
  • Runtime monitoring: Use host-based intrusion detection or command auditing (e.g., auditd, process accounting, EDR telemetry) to spot unexpected command invocations triggered from the Glances process, particularly around alert threshold events.

Automated SAST or security-focused linters can be configured to highlight subprocess usage patterns that combine templating and manual command parsing, enabling earlier detection during development.

Sources

SourceLink
github.comgithub.com/nicolargo/glances/commit/6f4ec53d967478e69917078e6f73f448001bf107
github.comgithub.com/nicolargo/glances/releases/tag/v4.5.2
github.comgithub.com/nicolargo/glances/security/advisories/GHSA-vcv2-q258-wrg7

Frequently asked

questions

It can be, if an attacker can influence monitored attributes (such as process or container names) via a remote interface—like deploying containers, starting processes, or mounting filesystems whose names are under their control—and those attributes are included in Glances action templates. In such setups, the attacker does not need direct access to the Glances configuration itself.

The attacker must be able to control one or more runtime values that are interpolated into action commands (for example, naming a process or container with crafted metacharacters). They also depend on Glances being configured with an action template that uses those fields and is triggered by a reachable monitoring condition.

The robust fix pattern is to eliminate custom command-string parsing and instead construct argument arrays directly for each subprocess invocation, treating all templated data as pure arguments rather than command syntax. Multi-step behavior should be modeled explicitly in code (separate subprocess calls, pipelines implemented via APIs) instead of relying on shell-like operators embedded in a single string.

Future designs should maintain a strict separation between code and data in any execution path: avoid passing composite strings that mix user-controllable data with command syntax, prefer high-level APIs that accept structured arguments, and restrict which runtime values can reach execution sinks. Incorporating security reviews, static analysis focused on subprocess usage, and secure coding guidelines for templating and actions into the development lifecycle further reduces the likelihood of reintroducing command injection risks.

Find out what's already
exploitable in your codebase.