Owners of WeMo home automation devices should upgrade them to the latest firmware version, which was released this week to fix a critical vulnerability that could allow hackers to fully compromise them.

The vulnerability was discovered by researchers from security firm Invincea in the Belkin WeMo Switch, a smart plug that allows users to remotely turn their electronics on or off by using their smartphones. They confirmed the same flaw in a WeMo-enabled smart slow cooker from Crock-Pot, and they think it's probably present in other WeMo products, too.

WeMo devices like the WeMo Switch can be controlled via a smartphone app that communicates with them over a local Wi-Fi network or over the Internet through a cloud service run by Belkin, the creator of the WeMo home automation platform.

The mobile app, which is available for both iOS and Android, lets users create rules to turn the device on or off based on the time of day or day of the week. These rules are configured on the app and are then pushed to the device over the local network as an SQLite database. The device parses this database using a series of SQL queries and loads them into its configuration.

Invincea researchers Scott Tenaglia and Joe Tanen found an SQL injection flaw in this configuration mechanism that could allow attackers to write an arbitrary file on the device in a location of their choosing. The vulnerability can be exploited by tricking the device into parsing a maliciously crafted SQLite database.

This is trivial to accomplish, because there is no authentication or encryption used for this process, so anyone on the same network can send a malicious SQLite file to the device. The attack could be launched from another compromised device like a malware-infected computer or a hacked router.

Tenaglia and Tanen exploited the flaw to create a second SQLite database on the device that would be interpreted as a shell script by the command interpreter. They then placed the file in a specific location from where it would be automatically executed by the device's network subsystem at restart. Remotely forcing the device to restart its network connection is easy and only requires sending an unauthenticated command to it.

The two researchers presented their attack technique at the Black Hat Europe security conference on Friday. During the demonstration, their rogue shell script opened a Telnet service on the device that would allow anyone to connect as root with no password.

However, instead of Telnet, the script could just as easily have downloaded malware like Mirai, which recently infected thousands of internet-of-things devices and used them to launch distributed denial-of-service attacks.

The WeMo switches are not as powerful as some other embedded devices like routers, but they could still be an attractive target for attackers because of their large number. According to Belkin, there are more than 1.5 million WeMo devices deployed in the world.

Attacking such a device does require access to the same network. But attackers could, for example, configure Windows malware programs, delivered through infected email attachments or any other typical method, that would scan local networks for WeMo devices and infect them. And once such a device is hacked, attackers can disable its firmware upgrade mechanism, making the compromise permanent.

The two Invincea researchers also found a second vulnerability in the mobile application that's used to control the WeMo devices. The flaw could have allowed attackers to steal photos, contacts and files from users' phones, as well as track the locations of phones, before it was patched in August.

The exploit involved setting a specially crafted name for a WeMo device that, when read by the WeMo mobile app, would force it to execute rogue JavaScript code on the phone.

When installed on Android, the application has permissions to access the phone's camera, contacts and location as well as the files stored on its SD card. Any JavaScript code executed in the app itself would inherit those permissions.

In their demonstration, the researchers crafted JavaScript code that grabbed photos from the phone and uploaded them to a remote server. It also continuously uploaded the phone's GPS coordinates to the server, enabling remote location tracking.

"WeMo is aware of the recent security vulnerabilities reported by the team at Invincea Labs and has issued fixes to address and correct them," Belkin said in an announcement on its WeMo community forums. "The Android app vulnerability was fixed with the release of version 1.15.2 back in August, and the firmware fix (versions 10884 and 10885) for the SQL injection vulnerability went live on November 1st."

Tenaglia and Tanen said Belkin was very responsive to their report and is one of the better IoT vendors out there when it comes to security. The company actually did a pretty good job of locking down the WeMo Switch on the hardware side, and the device is more secure than average IoT products on the market today, they said.