HomeMatic — 1 vulnerability check

noctis ships 1 vulnerability check for HomeMatic, covering 6 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

eQ-3 HomeMatic CCU2 Unauthenticated Script Interpreter RCE

CVECVE-2018-7296, CVE-2018-7297, CVE-2018-7298, CVE-2018-7299, CVE-2018-7300, CVE-2018-7301
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/homematic/homematic-ccu2-rega-script-rce.yaml

Detects the eQ-3 HomeMatic CCU2 unauthenticated remote code execution in the ReGaHss script interpreter (CVE-2018-7297): a HomeMatic script POSTed to /Text.exe (or /Test.exe) is executed without a session, and its system.Exec runs OS commands as root. Reported with the other CVEs of the same advisory (CVE-2018-7296, -7298, -7299, -7300, -7301). Confirmation runs a benign `/bin/echo` whose argument is computed by the interpreter from two random integers, and matches the sum in the output.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST {{rega_path}} with a crafted body
  3. Checks rega_resp.body for NOCTIS[0-9]{6,7} → finding QoD 97: HomeMatic CCU2 unauthenticated script execution confirmed via POST …: system.Exec ran /bin/echo with the interpreter-computed argument NOCT…

References:

Feed source — tests/vulnerabilities/homematic/homematic-ccu2-rega-script-rce.yaml
# eQ-3 HomeMatic CCU2 — unauthenticated HomeMatic (ReGa) script execution
# (CVE-2018-7297), reported together with the other CCU2 CVEs of the same
# advisory as in the OpenVAS check (CVE-2018-7296 User.getLanguage file read,
# CVE-2018-7298 unsigned update download, CVE-2018-7299 add-on install RCE,
# CVE-2018-7300 User.setLanguage file write, CVE-2018-7301).
#
# Ported from OpenVAS/Greenbone NVT `2018/eq-3/gb_homematic_mult_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.140807, GPL-2.0-only).
#
# The CCU2 web server hands any POST to a `*.exe` path (/Text.exe in the NASL,
# /Test.exe in the public exploit EDB-44368) to the ReGaHss script interpreter
# without any session check. The body is a HomeMatic script; its
# system.Exec(cmd, &stdout, &stderr) runs an OS command as root, and
# WriteLine(stdout) returns the output in the HTTP response.
#
# Detection — benign in-band proof (QoD 97): the script declares two random
# 6-digit integers a and b and runs `/bin/echo NOCTIS` # (a + b) through
# system.Exec, printing its stdout. The sum is computed by the ReGa interpreter
# and only reaches the response through the echoed command output: it never
# appears in the request, and the command string is passed inline (not stored
# in a script variable, which ReGa would dump back in its trailing <xml>
# variable block), so neither a reflecting page nor an interpreter whose
# system.Exec is disabled can show NOCTIS<a+b>.
#
# Deviations from the NASL (intentional):
#   - Benign proof: `/bin/echo NOCTIS<a+b>` instead of `id` (the NASL's
#     `uid=[0-9]+.*gid=[0-9]+` regex also matches any page that merely
#     documents the id command, or a reflected copy of such text).
#   - Better coverage than the NASL: when /Text.exe does not confirm, the same
#     probe is sent to /Test.exe (the path of the public exploit), and the feed
#     does not need the prior CCU detection KB item — the proof is the
#     identification.
uid: 5221f902-64f0-4243-8b2d-b6aa6c7a5807
name: "eQ-3 HomeMatic CCU2 Unauthenticated Script Interpreter RCE (CVE-2018-7297)"
description: |
  Detects the eQ-3 HomeMatic CCU2 unauthenticated remote code execution in the ReGaHss
  script interpreter (CVE-2018-7297): a HomeMatic script POSTed to /Text.exe (or
  /Test.exe) is executed without a session, and its system.Exec runs OS commands as
  root. Reported with the other CVEs of the same advisory (CVE-2018-7296, -7298, -7299,
  -7300, -7301). Confirmation runs a benign `/bin/echo` whose argument is computed by
  the interpreter from two random integers, and matches the sum in the output.
cves:
  - CVE-2018-7296
  - CVE-2018-7297
  - CVE-2018-7298
  - CVE-2018-7299
  - CVE-2018-7300
  - CVE-2018-7301
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [homematic, eq-3, ccu2, rega, smart-home, iot, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-7297"
  - "https://atomic111.github.io/article/homematic-ccu2-remote-code-execution"
  - "https://www.exploit-db.com/exploits/44368"
  - "OpenVAS NASL 2018/eq-3/gb_homematic_mult_vuln.nasl (GPL-2.0-only)"

steps:
  # Per-run proof values: a/b random 6-digit integers, expected marker.
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a + b) }
    store_as: proof

  # Every step below runs once per candidate path (loop group); a finding
  # with stop: true ends the loop. Pre-initialise the result so a failed
  # request (reset, timeout) leaves a map the confirm condition can read.
  - id: init-resp
    action: set_var
    var_name: rega_resp
    var_value: {status: 0, body: ""}
    loop:
      over: ["/Text.exe", "/Test.exe"]
      var: rega_path

  # NASL request: raw HomeMatic script as the POST body (no Content-Type, as
  # OpenVAS http_post_put_req sends it), `id` swapped for the computed echo.
  - id: rega-exec
    action: http_request
    method: POST
    path: "{{rega_path}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    body: "string stdout;\nstring stderr;\ninteger a = {{proof.a}};\ninteger b = {{proof.b}};\nsystem.Exec(\"/bin/echo NOCTIS\" # (a + b), &stdout, &stderr);\nWriteLine(stdout);"
    store_as: rega_resp

  # Confirm RCE: NOCTIS<a+b> only appears if the interpreter computed the sum
  # and the echo command actually ran.
  - id: confirm
    action: match
    source: rega_resp.body
    pattern: "NOCTIS[0-9]{6,7}"
    condition: "rega_resp.status == 200 && stridx(rega_resp.body, proof.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "HomeMatic CCU2 unauthenticated script execution confirmed via POST {{rega_path}}: system.Exec ran /bin/echo with the interpreter-computed argument NOCTIS({{proof.a}}+{{proof.b}}) and the response contained {{proof.marker}}"
      stop: true

View these feeds on GitHub