Cisco has patched three of its RV-series routers after Pen Test Partners (PTP) found them using hoary old C function
strcpy insecurely in login authentication function. The programming blunder can be exploited to potentially hijack the devices.
PTP looked at how the routers' web-based control panel handled login attempts by users, and found that it was alarmingly easy to trigger a buffer overflow by simply supplying a long string of characters as the password, something which Cisco admitted "could allow an unauthenticated, remote attacker to execute arbitrary code on an affected device".
Lobbing in a password of 447 characters, such as 'A', followed by four characters, would allow the hijacker to control a subroutine return address on the web app's stack using the values of those final characters. That means the hacker could force the device's 32-bit Arm-based processor to jump to malicious code stashed in the login request.
An attacker has to be able to reach the web interface – either on the local network, or via the remote administration feature that is admittedly disabled by default.
The three routers affected – the RV110W, RV130W and RV215W – run "some form of embedded Linux" instead of Cisco OS, according to PTP's definitely-not-pseudonymous blogger Dave Null. The network equipment provides physical Ethernet ports as well as Wi-Fi connectivity, firewall protections, and VPN tunneling.
The discovery of the flaw was credited to Yu Zhang and Haoliang Lu at the GeekPwn conference, and T. Shiomitsu of Pen Test Partners, who worked and informed Cisco separately.
When following the RV130W's login process at the binary executable level, PTP found that the router was placing the user-inputted password string into a memory buffer, ready for authentication against the saved password, using
strcpy with no bounds checks. That means if the password is larger than the buffer size, it will blow past the end of the buffer and overwrite other data and return addresses on the stack.
As El Reg reported years ago when a similarly worrying use of
strcpy emerged in glibc: "
strcpy is dangerous and an obvious target in an audit because it blindly copies the entire contents of a zero-terminated buffer into another memory buffer without checking the size of the target buffer."
Null from PTP elaborated on Thursday: "If someone else has control over the source string, you are giving an external entity the capability to overwrite the bounds of the memory that you allocated – which might mean they can overwrite something important with something bad. In most exploitable cases, this will mean overwriting a saved return pointer on the stack and redirecting the execution flow of the process."
He cheerily added: "Oh yeah, also, no PIE/ASLR in the binary," meaning it's pretty easy to exploit. Tutorials on how to leverage buffer overflows on embedded Arm-based gadgets can be found here, for instance.
The security patches for the hardware are free to download, and were released earlier this week; you don't need a support contract. Cisco customers should check their routers are running the latest firmware versions, to ensure they are not vulnerable, as follows:
- RV110W Wireless-N VPN Firewall: 18.104.22.168
- RV130W Wireless-N Multifunction VPN Router: 22.214.171.124
- RV215W Wireless-N VPN Router: 126.96.36.199
A decade ago Microsoft banned the use of a superficially similar function,
memcopy, from its code. PTP's Null suggested latterday C authors might want to switch to
strlcpy instead, "a nonstandard function which takes a third length argument, and always null terminates". ®