How many people and companies use Cisco routers? You do not need to be a system integration engineer to know the specific figure. Baidu will tell you the answer. Do you panic when knowing that a backdoor targeting Cisco routers may affect most models? An experienced network administrator knows that the firmware of routers is not frequently upgraded. Once an attacker gets the knack of exploiting such backdoors, he or she can use them against those routers in a long time. Are you scared of that?
People often consider it difficult or only theoretically feasible to implant a backdoor into a Cisco router. However, FireEye, a US security company, discovered that backdoors targeting Cisco routers were in the wild stealthily, involving Cisco 1841, 2841, and 3825 routers and other common models. Up to now, at least 14 similar implants have been found to propagate in four countries, namely Ukraine, the Philippines, Mexico, and India.
SYNful Knock is implemented by implanting malicious code upon modification of the firmware of Cisco routers, similar to the process of infecting a good file with a virus. Attackers need to upload or load this backdoor-infected firmware unto the target router by other means. By far, they have not used any 0-day vulnerabilities to upload the firmware. Instead, they log in to the target router with the default password or a weak password and then upload the backdoor-infected firmware to replace the normal firmware. As long as the router administrator does not upgrade the firmware, attackers can maintain persistent control over the router.
This backdoor is embedded with a universal backdoor password, with which an attacker can log in to the target router via Telnet or the console. By employing the dynamic module loading technique, it can conveniently load new malicious functional modules whenever it deems necessary (this is a common technique frequently used in botnets under Windows or UNIX, but seldom seen in router backdoors). Each module can be updated, loaded, or deleted via the Hypertext Transfer Protocol (HTTP).
This backdoor program is named “SYNful Knock” maybe because its network command and control (CnC) functionality is triggered via a special TCP SYN packet.
(With no real samples at hand, we provide technical details here by reference to the related report released by FireEye.) This backdoor manages to implant malicious functions by modifying a normal Cisco IOS image as follows:
In normal IOS images, certain TLBs are Read Only (RO). The backdoor forces all TLB Read and Write attributes to be Read-Write (RW). This is probably done to support the hooking of IOS functions by loaded modules. If TLB attributes are not set to RW, modifications to the cached pages may not be propagated to the original page in memory. The TLB attributes can be examined using the “show platform” command. If all TLB attributes are set to RW (as shown in the following figure), it indicates that the system may be implanted with a malicious backdoor.
It is believed that a function associated with process scheduling was modified to point to the malware hook processing function. After being initialized, the malware executes the original IOS function. This function was chosen because it, after being modified, is called during the IOS boot sequence, and is always called, as long as the IOS boots correctly. In this way, attackers can have the persistent power of control over the system.
To prevent the size of the image from changing, the backdoor overwrites several legitimate IOS functions with its own executable code.
Also for the purpose of preventing the size of the image from changing, attackers may replace strings referenced by legitimate functions with some strings used in CnC communication. In this way, abnormal results as follows may be returned when some legitimate IOS commands are executed:
Attackers implant a universal password into the backdoor-infected image to ensure that they can log in to the system by bypassing restrictions of legitimate passwords. This backdoor password can be entered via the console, Telnet, or elevation to administrative privileges (enable). If the user input is the backdoor password, access is granted; otherwise, the implanted code will pass the credentials on for verification of potentially valid credentials. Currently, the background password has not been set for login via Secure Shell (SSH) or HTTPS.
The CnC portion of the implant is modular and allows additional functionality to be loaded into the IOS, which is rarely seen in router backdoors. It can significantly increase the scalability of the malware. Once a router is restarted, all loaded malicious modules will disappear. In this case, attackers need to reload malicious modules.
Attackers enable CnC by sending certain special TCP packets. Even if filters are enabled on the router, these packets can still be received and processed by the malware.
The process of implementing CnC is as follows:
The command format is as follows:
The command data portion is XOR encoded with a static key.
The backdoor supports five types of CnC commands, including displaying module status, allocating space for an additional module to load, populating the memory allocated for the module, activating a loaded module, and removing a module. A total of 100 additional modules can be loaded.
Each command message starts with 8 bytes. The first four are set to 0 and the second four identifies the message type (0 to 4). The following table describes the meaning of each command type.
If the first four bytes of a message are not 0, they will be deemed as a module ID and the code associated with the module ID is executed.
Generally, security vendors outside of China choose to release patches for users to patch their system. But in practice, this could be rather challenging for the following reasons:
NSFOCUS recommends a protection scheme featuring one baseline and three phases. One baseline is to turn extensive risks to sporadic risks. Three phases refer to design and implementation, test run and acceptance, and long-term operation and maintenance (O&M). Each phase involves a lot of details. Following is a brief description of these phases.
• Fast handling: Set up a TFTP server to forcibly back up all live IOS images and check the consistency of MD5 values between backed-up IOS images and IOS images downloaded from the official website.
• If an IOS image fails the MD5 check:
1 2 3 4 |
For the sake of security, replace the problematic device instead of just deleting the IOS. Return the problematic device to the vendor or use it as a honeypot. Overhaul the entire business system to eliminate risk factors. |
• Rectify the management zone according to system design standards.
The technical details provided in this document are based on a technical report from FireEye. The attack process is roughly like this:
According to FireEye’s report, the backdoor implanting technique targeting Cisco routers has gradually evolved from theoretical existence to practical application. The backdoor does not just use universal passwords now, but has the capability of remotely loading arbitrary modules with malicious code. Routers are deployed at the ingress and egress of a network, which are very important locations. Once an attacker executes code on a router, he or she can perform any operations on the network traffic passing through the router, without being restricted by the original functions of the router. Therefore, attacks targeting routers tend to cause more damage to the network.
Chinese version: http://blog.nsfocus.net/cisco-router-door-synful-knock-2/