Summary
Glances AMP modules pass configuration-defined command strings into a helper that interprets shell operators like redirection, pipes, and command chaining without validation.
If an attacker can modify glances.conf, they can cause Glances to write arbitrary data to files, invoke additional commands, or pipe output to arbitrary programs during monitoring.
Affected context
This vulnerability appears in Glances deployments that use Application Monitoring Process (AMP) modules whose command or service_cmd values are loaded from glances.conf.
In affected versions, those configuration values are handed to secure_popen() in glances/secure.py, which interprets shell-like operators (>, |, &&) embedded in the string.
Installations where configuration files are editable by non-privileged users, external automation, or misconfigured services are more exposed, especially when Glances runs with elevated permissions or broad filesystem access.
Exploit preconditions
- Attack surface: Glances runtime, specifically AMP modules invoked via secure_popen().
- Required access: Ability to modify glances.conf or any configuration source that influences AMP command/service_cmd values.
- Trigger point: Execution of an AMP command or service_cmd that includes redirection (
>), piping (|), or chaining (&&) operators. - Why exploitation is possible: secure_popen() interprets and applies shell operators from the configuration string without validating paths, commands, or destinations, effectively treating configuration as trusted shell syntax.
Why this happens
The root cause is the insecure handling of command strings originating from configuration in the secure_popen() function.
Instead of treating configuration values as data with strict constraints, the implementation parses and applies shell-style operators such as file redirection, pipes, and command chaining directly.
This maps to CWE-22 in the sense that untrusted input is used to construct filesystem paths and influence where data is written, combined with a broader command-injection pattern where configuration content controls process invocation behavior.
The abstract pattern is: "application logic uses unvalidated configuration text to build commands and file operations that the OS interprets," allowing attackers who control configuration to extend or redirect those operations.
Potential impact
- An attacker can cause Glances to write arbitrary content to arbitrary filesystem paths using output redirection.
- Monitoring commands can be chained with additional arbitrary commands, expanding the actions taken during AMP execution.
- Command output can be piped into other programs to perform unintended data processing or leakage.
- Glances may be abused to modify configuration files, logs, or application data, depending on its runtime privileges.
- In environments where Glances runs with elevated permissions, exploitation can lead to broader system compromise.
General mitigation guidance
Mitigation typically involves constraining how commands are formed and executed from configuration-driven values.
Defensive patterns include:
- Treat configuration as data, not shell syntax: avoid parsing or interpreting operators like
>,|, and&&in helper functions. - Use fixed command templates where only well-defined, validated parameters (e.g., arguments or flags) are substituted into a safe execution API.
- Validate filesystem paths against allowlists or scoped directories before permitting any file write or redirection originating from configuration.
- Run Glances with least privilege, limiting its ability to write to sensitive system locations or execute external programs.
- Separate monitoring command configuration from execution logic using structured formats (e.g., lists of arguments) rather than free-form command strings.
How teams detect issues like this
Detection can focus on both code and configuration behavior:
- Static analysis and code review can flag functions that parse or interpret shell operators from strings loaded from configuration, environment variables, or user input.
- Look for helper routines that reconstruct command lines, concatenate operators, or pass unsanitized strings to subprocess execution APIs.
- Enforce internal policies that prohibit free-form shell command configuration for monitoring or automation services; prefer structured commands with validated arguments.
- Periodically scan glances.conf and related configuration files for suspicious operators (
>,|,&&) and unexpected destinations or commands. - Automated security reviews or CI checks can be configured to detect patterns where configuration-derived values are used to influence filesystem write locations or chained commands.

