Hacking Zyxel IP cameras to gain a root shell
The Zyxel IP cameras expose an unauthenticated RTSP video stream and a UPnP service that serves configuration files, and the profile export/import feature allows adding cron jobs or startup scripts that run as root. An attacker with network access could view the video feed without credentials, crash the RTSP server on one model, and, with admin credentials, gain a root shell.
Published on hydrogen18.com
I bought these cameras primarily to use as a test device for work. I needed something that had an ethernet interface and worked as an IP based device.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the RTSP server lacks authentication, the UPnP service exposes configuration files, and the profile import feature allows arbitrary files (cron jobs, startup scripts) to be placed in a directory that is executed with root privileges.
Impact
An attacker on the same network could view the video stream without authentication, crash the RTSP server on one model, and, if they have admin credentials, gain a root shell on the device.
What the attacker needed
Network access to the camera; admin credentials for root shell
The fix
The devices are no longer supported and should be removed from service; otherwise, authentication should be added to the RTSP stream, UPnP should be disabled, and profile imports should be restricted.
How it was found
- Scan the device to find open ports including RTSP on 554 and UPnP on 49152.
- Send an RTSP DESCRIBE request to the /medias1 path to access the video stream without authentication.
- Send an RTSP DESCRIBE request to /medias2 to crash the RTSP server on the IPC-3605N model.
- Export the profile from the web interface, which is a gzip-compressed tarball containing a crontab file.
- Modify the crontab to add a line that starts a telnet daemon, then re-import the profile.
- Connect to the telnet daemon to obtain a root shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
These cameras have several security holes. Anyone on the network can watch the video without logging in, and one model can be crashed remotely. If you know the admin password, you can also upload a modified settings backup that makes the camera run your commands as the root user, giving full control.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.