GHSA-59fj-m2j6-hcxh: OS Command Injection
Summary In Glances 4.5.5 the --disable-config-exec flag was extended (GHSA-3vwc-qwhc-3mj7) to stop securepopen() from interpreting the shell operators &&, | and > in AMP command values taken from the configuration file. The hardening was not applied to the on-alert action command path, which reads its command lines from the same configuration file. As a result, with --disable-config-exec enabled, a configured alert action that contains > (file redirection), && (chaining) or | (pipe) still has those operators interpreted, allowing arbitrary file write / command chaining at the privilege of the glances process when the alert triggers.
Affected code glances/actions.py (Glances 4.5.5, latest): python ret = securepopen(cmdfull) # line 111 — no allowoperators=, defaults to True By contrast the AMP modules were fixed: python glances/amps/default/init.py:69 self.setresult(securepopen(res, allowoperators=self.allowoperators()).rstrip()) glances/amps/systemv/init.py:60 res = securepopen(self.get('servicecmd'), allowoperators=self.allowoperators())
PoC (benign) glances.conf: ini [cpu] usercritical=1 usercriticalaction=echo MARKER > /tmp/pocmarker Run glances --disable-config-exec and generate CPU load. When the cpu user alert reaches CRITICAL, /tmp/pocmarker is created — i.e. the > operator was interpreted despite --disable-config-exec. The same > in an [amp] command value is correctly not interpreted.
Impact Arbitrary file write (>), command chaining (&&) and pipe (|) from config-defined alert actions, contrary to the guarantee of --disable-config-exec. Trust boundary = the glances configuration file.
Suggested fix Pass allowoperators=not args.disableconfigexec from GlancesActions.run() into securepopen() (GlancesActions already holds args).
Credit Reported via responsible-disclosure incomplete-fix measurement study.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/glancesto a version that resolves this vulnerability.Fixed in 4.5.6 - Upgrade
Upgrade
Glancesto a version that resolves this vulnerability.Fixed in 4.5.5Patch GHSA-3vwc-qwhc-3mj7 - Configuration
Run Glances with the --disable-config-exec flag enabled so configured alert action commands are not executed with shell operators interpreted.
Glances --disable-config-exec = enabled - Compensating control
Ensure the Glances configuration file (the trust boundary for AMP command values) is protected so untrusted users cannot modify on-alert action command strings.
Event History
Frequently Asked Questions
What is the severity of GHSA-59fj-m2j6-hcxh?
The severity of GHSA-59fj-m2j6-hcxh is rated at 47.
What is the impact of GHSA-59fj-m2j6-hcxh?
GHSA-59fj-m2j6-hcxh involves OS Command Injection vulnerability due to improper handling of shell operators in on-alert actions.
How do I fix GHSA-59fj-m2j6-hcxh?
To fix GHSA-59fj-m2j6-hcxh, update to Glances version 4.5.6 or later where the vulnerability is addressed.
Who is affected by GHSA-59fj-m2j6-hcxh?
Any users of Glances version 4.5.5 who have configured on-alert action commands are affected by GHSA-59fj-m2j6-hcxh.
What versions of Glances are vulnerable to GHSA-59fj-m2j6-hcxh?
Glances versions prior to 4.5.6 are vulnerable to GHSA-59fj-m2j6-hcxh.