Summary
The smart plug’s update file is a plain archive with a header, a kernel and a compressed filesystem. Unpacking it takes one command; understanding the local web service takes the rest of this post. A parameter passed unsanitised to a shell helper yields root without authentication.
Background
Cheap plugs run a stripped-down Linux with a single web service for local setup. That service is often the entire attack surface, because the cloud connection is outbound only.
Method
I downloaded the update file, ran binwalk to carve out the filesystem, and mounted it read-only. A grep for system( and popen( in the web binary produced a short list of calls worth reading.
Findings
One handler builds a shell command from the ssid field. Quotes are not escaped, so a crafted network name runs arbitrary commands as root.
Takeaways
Validate and quote everything that reaches a shell, or better, stop shelling out. For researchers: start from the strings, not from the disassembly.