Risk of exposed home automation services

Risk of exposed home automation services

At home, I am automating many things for fun. Currently I am using Home Assistant, an incredibly powerful piece of software for automating your home. Regularly I am combining the home automation experiences with security. Home automation is often related to physical things such as changing lights, moving curtains, opening door locks or turning the car heating on. So if you find security issues in home automation stuff, it often directly has its effects on something in the physical world. Which is interesting, isn’t it? 😀

MQTT

In my home I am using a MQTT service. MQTT (Message Queuing Telemetry Transport) is a protocol which is widely used in the Internet-of-Things. In a nutshell: it is a lightweight protocol that consists of channels. The MQTT clients can subscribe and/or publish to these channels, to read or share messages. So one client would send a message to the channel, while another client waits for such a message to perform whatever behavior.

In my home MQTT is used for the Zigbee2mqtt application. Zigbee2mqtt sends all Zigbee communication onto the MQTT service. Home Assistant is reading and writing on the MQTT service. This allows me to control all the Zigbee devices through Home Assistant, such as my lights (bye bye Philips Hue, Ikea and other proprietary Zigbee hubs❤️).

Risks

Like mentioned, MQTT is definitely useful in home automation setups. And therefor it is often used for a variety of use cases. However, it also introduces new risks. Especially when someone is exposing their MQTT services to the internet without knowing it.

In this blog I want to mention a couple of real-life scenario’s that I was able to identify, by just searching for MQTT services that are currently being exposed to the internet, probably without the users even knowing it…

For an attacker it is easy to find MQTT services that are exposed to the internet: the website shodan.io scans the internet for services, such as MQTT, and makes it very easy to search through them.

Scenario #1: someone is watching you…

MQTT is often used to distribute location information, such as GPS coordinates. Imagine the following setup: a phone sends its location information to an MQTT service. Home automation software, such as Home Assistant, reads all the information from the channel. This allows the home automation service to know where devices (and their owners) are. This is great for presence detection, actually a very important component when doing home automation (e.g. turn the alarm on when somebody leaves home).

A popular application to do so is Owntracks. By doing some simple searches I was able to identify almost 400 MQTT services that have something to do with Owntracks…

So lets take one MQTT service as an example. Its fairly easy to make a connection. A simple Python script allows you to connect to an MQTT service without credentials. After connecting to this specific service, I was a little bit surprised how quickly I could track someone down. After connecting to the server, I was able to determine the following:

  • Full names of 3 individuals
  • The real-time location of those persons
  • Whether the persons were in the ‘Home’ zone
  • Profile pictures of the users
  • Two car brands, that were also connected through MQTT
  • Vacuum cleaner status
  • And some other weird stuff 🙂

Here is an example of an actual message, containing location information of an individual:

By simply Googling the names and comparing the profile pictures found in the MQTT server and on social media, it was possible to find the correct people. I contacted them to let them know their MQTT server was wide open…

Scenario #2: pwning a computer through MQTT

One of the recent Home Assistant updates mentioned an interesting internet-of-things application called iotlink. This tool allows a home automation user to connect its computer to Home Assistant. And guess what: through MQTT, the application allows someone to control its computer using Home Assistant. For example, rebooting the system, obtaining a screenshot, etc.

In other words: the connected computer is listening to the MQTT channel waiting for commands. The question is: does the tool also allow us to perform command execution? By looking into the documentation, I found out that this is actually a feature. Any application can be run using iotlink, even in a hidden mode (== hidden backdoors 😍).

In have setup a test environment with an MQTT service, Home Assistant and a host connected through iotlink. By publishing a specific payload onto the correct MQTT channel, it is possible to turn the MQTT access into code execution on the connected host:

Topic

iotlink/workgroup/<computername>/commands/run

 

Payload

{ “command”: “calc.exe”, “args”: “”, “path”: “”, “user”: “”, “visible”: true, “fallback”: true }

 

The result:

So, when having access to an MQTT service that is being used for iotlink, it could even lead to someone compromising your computer. By doing some simple searches, I found (luckily) just 13 MQTT services that have iotlink devices connected.

Scenario #3: pwning your camera’s

During my searches I found a couple of Home Assistant related MQTT services that had some other interesting behavior. The MQTT channels were displaying camera information. More specifically, they were displaying all the attribute information of a Home Assistant camera component. The problem: the attribute also contains an ‘access_token’. This access_token can be used against the Home Assistant web interface to view the camera.

Example data

hass/out b'{“event_type”: “state_changed”, “event_data”: {“entity_id”: “camera.reolink_e1_pro_profile000_mainstream”, “old_state”: {“entity_id”: “camera.reolink_e1_pro_profile000_mainstream”, “state”: “idle”, “attributes”: {“access_token”: “777777777777777777777777777777777777777777777777777“, “friendly_name”: “Reolink_E1_Pro – Profile000_MainStream”, “entity_picture”: “/api/camera_proxy/camera.reolink_e1_pro_profile000_mainstream?token=777777777777777777777777777777777777777777777777777“, “supported_features”: 2}

 

A simple search shows that currently there are about 539 Home Assistant MQTT services online.

If someone is able to obtain the access token through MQTT, and the Home Assistant web interface is also available to the attacker, he is able to view the camera of the home. Especially if the camera is inside the home, this is probably something you want to prevent.

Conclusion

Home automation is fun! But please be careful exposing your services (directly) to the internet. In this blog I mentioned just a couple of examples for MQTT, but there are loads of services and other scenario’s that could result in similar issues.

Sometimes the ease of access can leak quite some personal information, or even lead to direct access to your workstation. Once you want to make things directly accessible via internet make sure it has authentication.