Multiple Zyxel network-attached storage (NAS) devices running firmware version 5.21 contain a pre-authentication command injection vulnerability, which may allow a remote, unauthenticated attacker to execute arbitrary code on a vulnerable device. Zyxel NAS devices achieve authentication by using the weblogin.cgi CGI executable. This program fails to properly sanitize the username parameter that is passed to it. If the username parameter contains certain characters, it can allow command injection with the privileges of the web server that runs on the Zyxel device. Although the web server does not run as the root user, Zyxel devices include a setuid utility that can be leveraged to run any command with root privileges. As such, it should be assumed that exploitation of this vulnerability can lead to remote code execution with root privileges. By sending a specially-crafted HTTP POST or GET request to a vulnerable Zyxel device, a remote, unauthenticated attacker may be able to execute arbitrary code on the device. This may happen by directly connecting to a device if it is directly exposed to an attacker. However, there are ways to trigger such crafted requests even if an attacker does not have direct connectivity to a vulnerable device. For example, simply visiting a website can result in the compromise of any Zyxel device that is reachable from the client system.
Affected products include: NAS326 before firmware V5.21(AAZF.7)C0 NAS520 before firmware V5.21(AASZ.3)C0 NAS540 before firmware V5.21(AATB.4)C0 NAS542 before firmware V5.21(ABAG.4)C0 Zyxel has made firmware updates available for NAS326, NAS520, NAS540, and NAS542 devices.
Affected models that are end-of-support: NSA210, NSA220, NSA220+, NSA221, NSA310, NSA310S, NSA320, NSA320S, NSA325 and NSA325v2
Thanks to Brian Krebs, an independent investigative journalist, for reporting the issue to us and CERT/CC for coordinating the disclosure process.
Zyxel released a hotfix firmware which disables the use of special characters on admin/user accounts created on the NAS. If you were using a password which contained special characters and update to the hotfix firmware, you will notice that you can no longer login to the WebUI. To regain access to the device please press the reset button and hold it down for about 5 seconds (or until the NAS beeps one time). This procedure will reset the admin account password and Ethernet adapter only. Once the procedure is completed you will be able to login using the Zyxel default credentials, admin/1234. New passwords created for accounts will need to be alphanumeric.