Killing the Myth of Cisco IOS Diversity∗ :
Recent Advances in Reliable Shellcode Design
Ang Cui Jatin Kataria Salvatore J. Stolfo
Department of Computer Department of Computer Department of Computer
Science Science Science
Columbia University Columbia University Columbia University
New York NY, 10027, USA New York NY, 10027, USA New York NY, 10027, USA
ang@[Link] jk3319@[Link] sal@[Link]
ABSTRACT 1. INTRODUCTION
IOS firmware diversity, the unintended consequence of a Over the past decade, Cisco IOS has been shown to be vul-
complex firmware compilation process, has historically made nerable to the same types of attacks that plague general
reliable exploitation of Cisco routers difficult. With approx- purpose computers [13, 11]. Various exploitation techniques
imately 300,000 unique IOS images in existence, a new class and proof-of-concept rootkits [14, 12] have been proposed.
of version-agnostic shellcode is needed in order to make the However, all current offensive techniques are impeded by an
large-scale exploitation of Cisco IOS possible. We show unintended security feature of IOS: diversity. As Felix “FX”
that such attacks are now feasible by demonstrating two Lindner points out, Cisco IOS is not a homogenous collec-
different reliable shellcodes which will operate correctly over tion of binaries, but a collection of approximately 300,000
many Cisco hardware platforms and all known IOS versions. diverse firmwares [12]. Although never intended as a de-
We propose a novel two-phase attack strategy against Cisco fense against exploitation, this diversity makes the creation
routers and the use of offline analysis of existing IOS im- of reliable exploits and rootkits difficult.
ages to defeat IOS firmware diversity. Furthermore, we dis-
cuss a new IOS rootkit which hijacks all interrupt service Known proof-of-concept rootkits operate by patching spe-
routines within the router and its ability to use intercept cific locations within IOS. In the case of DIK [14], the rootkit
and modify process-switched packets just before they are intercepted a specific function responsible for checking pass-
scheduled for transmission. This ability allows the attacker word. The major drawback of this approach is that it re-
to use the payload of innocuous packets, like ICMP, as a lies on a priori knowledge of the location of this function.
covert command and control channel. The same mechanism As previously noted, this knowledge is generally difficult
can be used to stealthily exfiltrate data out of the router, to obtain with accuracy prior to attack. Therefore, any
using response packets generated by the router itself as the rootkit which depends on specific memory locations cannot
vehicle. We present the implementation and quantitative re- be used reliably in large-scale attacks against the Internet
liability measurements by testing both shellcode algorithms substrate. Conversely, version-agnostic shellcode, combined
against a large collection of IOS images. As our experi- with known vulnerabilities in IOS, makes such large-scale
mental results show, the techniques proposed in this paper attacks against Cisco routers a feasible reality.
can reliably inject command and control capabilities into
arbitrary IOS images in a version-agnostic manner. We be- For reliable, large-scale payload execution in IOS to be fea-
lieve that the technique presented in this paper overcomes sible, we must construct attacks and shellcodes which are
an important hurdle in the large-scale, reliable rootkit exe- version and platform agnostic. Towards this end, we outline
cution within Cisco IOS. Thus, effective host-based defense a two-stage attack methodology as follows:
for such routers is imperative for maintaining the integrity
of our global communication infrastructures.
Stage 1: Leverage some IOS invariant to compute a host
fingerprint. Using computed information, inject stage-
2 shellcode. Furthermore, exfiltrate host fingerprint
back to attacker.
∗Video demos of both IOS shellcodes and our stealthy exfil- Stage 2: Persistent rootkit with covert command and con-
tration module can be found at [7]. trol capability. The attacker will use exfiltrated fin-
gerprint data to construct a version specific rootkit,
which is loaded via the second-stage shellcode.
The attacker is at a disadvantage when attempting an online
attack. However, since all IOS images can be obtained, and
such images are not polymorphically mutated, an attacker
can construct a large collection of version specific rootkits
offline. If the attacker is able to simultaneously inject a
simple rootkit and exfiltrate a host-environment fingerprint
Phase 1.a the CPU overhead of this shellcode will be distributed across
a large number of random IOS processes. Unlike with shell-
codes which take over a specific process, the network ad-
ministrator can not detect unusual CPU spikes within any
Phase 1.b Victim particular process using commands like show proc cpu, mak-
IOS Device ing it very difficult to detect by conventional means.
Attacker
The remainder of this paper is organized as follows: Section
Phase 2.a 2 outlines the challenges of reliable IOS rootkit execution
Phase 2.b
and provides motivation for the need for version-agnostic
shellcodes. Section 3 presents a survey of advancements in
Cisco IOS exploitation over the past decade and provides
IOS Database
a timeline of public disclosures of significant vulnerabilities
and exploitation techniques. Section 4 outlines a general
Figure 1: Timeline of two-stage attack against vul- two-stage attack strategy against unknown Cisco devices.
nerable IOS router of unknown hardware platform Section 5 presents our first reliable IOS shellcode, a disas-
and firmware version. Attacker launches exploit sembling shellcode, which was first proposed by Felix Lind-
with reliable shellcode (1.a). Shellcode installs ner for PowerPC based Cisco devices. Section 6 presents
rootkit and exfiltrates victim device’s IOS finger- our second reliable IOS shellcode. This shellcode hijacks all
print (1.b). The attacker finds exact IOS version interrupt handler routines within the victim device, and is
from fingerprint by consulting offline database (2.a). faster, stealthier and more reliable than our first shellcode.
The attacker then creates a version specific rootkit Experimental data, performance, overhead and reliability
for victim, and uploads it using 1.b rootkit (2.b). measurements are presented in Section 8. Potential defenses
against our proposed shellcodes are discussed in Section 9.
Concluding remarks are presented in Section 10. Lastly, the
full source code of both shellcodes are listed in Appendix A.
during the first phase of the attack, the attacker can then
load a rootkit specifically parameterized for the exact IOS
Please note that the remainder of this paper will focus on
version of the victim router. Figure 1 shows the timeline of
MIPS-based Cisco IOS. All code examples will be shown in
our proposed attack, which is intentionally broken into two
MIPS. However, the techniques presented can be applied to
phases to shift the advantage towards the attacker.
PowerPC, ARM and even x86-based systems.
The two requirements of our first-stage shellcode, the need to
reliably inject a basic second-stage rootkit, and the need to 2. MOTIVATION
accurately fingerprint the victim device, can be satisfied si- Several recent studies demonstrate that there are vast num-
multaneously. Both shellcodes presented in this paper com- bers of unsecured, vulnerable embedded devices on the In-
pute a set of critical memory locations within IOS’s .text ternet [9], such devices are vulnerable to the same types of
section. These memory addresses are used both as intercept attacks as general purpose computers [3, 11], and can be
points for our second-stage code, but also used to uniquely systematically exploited in much the same way [1, 3, 5].
identify the exact micro-version of the victim’s firmware. As For example, various exploitable vulnerabilities [13, 12] and
figure 1 shows, this fingerprint data is exfiltrated back to the rootkits [14] have been found and disclosed for Cisco’s flag-
attacker and compared to a database of pre-computed finger- ship system, IOS. Cisco devices running IOS constitutes a
prints for all known IOS firmwares. As Section 8 shows, the significant portion of our global communication infrastruc-
fingerprints can be computed using simple linear-time algo- ture, and are deployed within critical areas of our residential,
rithms and efficiently stored in a database. Pre-computing commercial, financial, government, military and backbone
such fingerprints for all 300,000 IOS images should not take networks.
more than a few days on a typical desktop.
Typical of the embedded security landscape, IOS is an ag-
We present two different techniques for implementing this ing system which does not employee standard protection
two-stage attack. The disassembling shellcode is discussed schemes found within modern operating systems [14], and
in Section 5. A novel interrupt hijack shellcode is discussed does not have any host-based anti-virus to speak of. In fact,
in Section 6. A stealthy exfiltration technique which mod- not only is the installation of third-party anti-virus (which
ifies process-switched packets just before it is scheduled for does not yet exist for IOS) not possible via any published OS
transmission is discussed in Section 7. The intercept hi- interface, any attempt to do so will also violate the vendor’s
jacking shellcode and the exfiltration mechanism built on EULA and thus void existing support contracts.
top of it has several interesting advantages over existing
rootkit techniques. First, the command and control pro- Consider the availability of proof-of-concept exploits and
tocol is built into the payload of incoming packets. No spe- rootkits, the wide gamut of high-value targets which can be
cific protocol is required, as long as the packet is punted to compromised by the exploitation of devices like routers and
the router’s control-plane. This allows the attacker to access firewalls, and the lack of host-based defenses within close-
the backdoor using a wide gamut of packet types, thus evad- source embedded device firmwares. Such conditions should
ing network-based intrusion detection systems. Hiding the make the vast numbers of vulnerable embedded devices on
rootkit inside interrupt handlers also allows it to execute for- the Internet highly attractive targets. Indeed, we have ob-
ever without violating any watchdog timers. Furthermore, served successful attempts to create botnets using Linux-
based home routers [4]. As Section 3 shows, the necessary Cisco IOS and other similar embedded devices.
techniques of exploiting Cisco IOS and installing root-kits
on running Cisco routers are well understood. However, an 3. RELATED WORK
obstacle still stands in the way of reliable large-scale ex-
A timeline of significant advancements in offensive technolo-
ploitation of Cisco devices: firmware diversity.
gies against Cisco IOS is listed below.
As Felix Lindner and others have pointed out [12], there
are over 300,000 unique versions of Cisco IOS. Diverse hard- FX, 2003: FX analyzes several IOS vulnerabilities and var-
ware platforms, overlapping feature-sets, cryptography ex- ious exploitation techniques [11].
port laws, licensing agreements and varying compilation and
Lynn, 2005: Lynn described several IOS shellcode and ex-
build procedures all contribute to create an operating envi-
ploitation techniques, demonstrating VTY binding shell-
ronment that is highly diverse. Although unintentional and
code [13].
not strictly a defense mechanism, this firmware diversity has
made the deployment of reliable attacks and shellcodes dif- Lynn, 2005: Cisco and ISS Inc. files injunction against Michael
ficult in practice. Therefore, in order for IOS exploitation Lynn [2].
to be feasible and practical, reliable shellcode that operate Uppal, 2007: Uppal releases IOS Bind shellcode v1.0 [16].
correctly across large populations of IOS versions is needed. Davis, 2007: Davis releases IOS FTP server remote exploit
code [10].
As Lindner demonstrates [12], certain common features within Muniz: 2008 Muniz releases DIK (Da IOS rootKit) [14].
Cisco routers can be used to improve the chances of reli- FX, 2009: FX demonstrates IOS diversity, demonstrates
able execution of IOS shellcode. The disassembling shell- reliable disassembling shellcode and reliable execution
code concept was proposed in the same work. Building off methods involving ROMMON [12].
this insight, we first tested the reliability of the proposed dis- Muniz and Ortega, 2011: Muniz and Ortega releases GDB
assembling shellcode. While this technique works smoothly support for the Dynamips IOS emulator, and demon-
across all versions of IOS for several major hardware plat- strates fuzzing attacks against IOS [15].
forms, it failed on all versions of IOS for several popular plat-
forms, including the Cisco 2800 series routers. Furthermore,
its computational complexity frequently triggered watchdog The techniques presented in this paper extend the above line
timer exceptions, which logs a clear trace of the shellcode. of work by introducing novel methods of constructing reli-
Section 5 discusses the reason for this failure, and several able IOS shellcodes and stealthy exfiltration, making large-
other drawbacks of this disassembling approach. scale exploitation feasible across all IOS-based devices.
Looking to improve reliability and performance, we con- 4. TWO-STAGE ATTACK STRATEGY
structed a different shellcode by leveraging a common in-
Sections 5 and 6 discusses two reliable shellcode techniques.
variant of not only Cisco IOS, but all embedded systems,
Unlike existing IOS shellcodes, these two examples are de-
interrupt handler routines. Hijacking interrupt handlers is
signed to work in a two-phase attack. Figure 1 illustrates
advantageous for several reasons. First, such routines can
the attack process. In general, this attack first computes a
be identified by a single 32-bit instruction, eret, or excep-
series of memory locations which the second-stage shellcode
tion return. The search for a single eret instruction re-
will intercept to obtain minimal rootkit capability. This
duces the computational complexity of the first-stage shell-
series of memory locations is also exfiltrated back to the at-
code. Whereas the disassembling shellcode frequently causes
tacker after the first-stage rootkit finishes execution. Using
watchdog timer exceptions on busy routers (See Section 5),
this information as a host fingerprint, the attacker queries
the interrupt-handler hijacking first-stage shellcode executes
a database of pre-computed fingerprints for all known IOS
quickly enough to avoid such timer exceptions, even on heav-
images to determine the exact micro-version of firmware run-
ily utilized routers. Second, there are approximately two
ning on the victim router. Once this is known, a version spe-
dozen interrupt handler routines on any IOS image, all of
cific rootkit can be constructed automatically, then loaded
which are clustered around a common memory range. By
onto the victim router via the rootkit installed by the first-
using offline analysis of large numbers of IOS images, we can
stage shellcode.
safely reduce the memory range searched by the first-stage
shellcode to a small fraction of IOS’s .text section, further
Each shellcode computes a different set of features. In the
improving the efficiency of the shellcode (See Figures 8 and
case of the disassembling shellcode, a 2-tuple is computed;
9).
the address of an invariant string and the address of the
password authentication function. In the case of the inter-
As our experimental data shows, the two proposed shell-
rupt hijacking shellcode, a n-tuple is exfiltrated, containing
codes, along with our proposed data exfiltration mechanism
a list of memory address for all interrupt handler routines
presented in Section 7, combined with available vulnerabili-
on the victim device. Section 8 will discuss how accurately
ties of Cisco IOS makes the large-scale of Cisco routers fea-
each feature-set can uniquely identify the micro-version of
sible. Weaponizing the techniques presented in this paper
the victim IOS environment.
to create worms which target routers is possible, and can
seriously damage the Internet substrate. Therefore, the de-
As the demonstration videos [7] show, the two shellcodes
velopment of advanced host-based defense mechanisms to
presented in this paper are tested using standard IOS im-
mitigate such techniques should now be considered a neces-
ages with an artificially introduced vulnerability allowing
sity. Section 9 discusses potential host-based defenses for
arbitrary memory modification and code execution. More
t s"
re
wd
ec
ps
dS
hk
Ba
c
B: xref
f_
A: str
"%
.text .data
Figure 2: The disassembling shellcode first locates a
known string (A), then locates a xref to this string
(B). Once this xref location is found, the attacker
can patch the function containing the xref. This
shellcode requires two linear scans of IOS memory,
one through the .data section, and a second one Figure 3: A disassembly of a typical f chkpasswd.
through the .text section. The string xref is the first highlighted block. The
second highlighted block is the single instruction
which can disable password authentication in IOS.
specifically, the shellcodes are tested with a simple code While these addresses vary greatly, they can be re-
loader which overwrites the IOS command ”show call fil- liably computed at exploitation time by the disas-
ter component”. The efficacy of both shellcodes is tested sembling shellcode.
on both Dynamips emulations and physical Cisco hardware.
During the development and testing process, Muniz and Or-
tega’s GDB patch [15] for Dynamips as well as a custom of computational complexity. In the case of Cisco routers,
GDB proxy for physical Cisco devices were used. this limit is a very practical one. A watchdog timer con-
stantly monitors every process within IOS, terminating any
5. SHELLCODE #1: DISASM SHELLCODE process running for longer than several seconds.1 As Figure
First proposed by Felix Lindner [12] for PowerPC-based 11 shows, our implementation of the disassembling shellcode
routers, the disassembling shellcode scans the victim router’s frequently caused watchdog timer exceptions to be thrown,
memory twice in order to locate and patch a target function leaving clear evidence of the attack in the router’s logs.
based on some functional invariant, and works as follows:
Once the first-stage completes execution, the attacker can
connect to the victim router with level 15 privilege, bypass-
A. Find String Addr: Scan through memory, looking for ing authentication. The attacker can then identify the exact
a specific string pattern. For example, ‘%Bad Secrets’. IOS version by a number of methods by using the router’s
B. Find String-Xref: With the string’s memory location administrative interface. While this backdoor gives the at-
known, construct the instruction which loads this ad- tacker persistent control of the device, it is not covert. Sec-
dress. Rescan through memory, looking for code which tion 6 shows our interrupt hijack shellcode, which installs an
references this string. equivalent backdoor through a covert channel, using pay-
C. Patch Function: The data reference is located within loads of IP packets punted2 to the router’s CPU. In our
the function we wish to find. Search within this func- demonstration, we use a large collection of arbitrary UDP
tion for the desired intercept point. For example, the and ICMP packets to load complex rootkits into the router’s
function entry point, or a specific branch instruction. memory.
The video demonstration of the disassembling shellcode run-
Any function which prints a predictable string can be iden- ning on a Cisco 7204 and 12.4T IOS can be found at [7].
tified and patched in this manner. A particularly useful
function is the credential verification function, which prints
‘%Bad Secrets’ when the wrong enable password is entered 6. SHELLCODE #2: INTERRUPT HIJACKER
3 times. As Section 5 showed, the disassembling shellcode can be used
reliably, at least for several major hardware platforms, to lo-
Figure 3 shows the disassembly of this function. We can cate and intercept a critical function which handles creden-
bypass password authentication by overwriting a single move tial verification in IOS. However, this shellcode must search
instruction, highlighted in red. through large portions of the router’s memory twice in or-
der to identify the target string reference, and the target
As experimental results in Section 8 shows, this first-stage function. This required computation frequently triggered
shellcode reliably disables password authentication for all the router’s watchdog timer, leaving evidence of the shell-
versions of Cisco 7200 and 3600 IOS images tested. However, code in the router’s log. In general, we want to minimize
it failed for all Cisco 2800 series IOS images. the amount of computation required by the first-stage shell-
1
The default watchdog timer value is 2 seconds.
In general, this type of disassembling shellcode is suitable for 2
A packet is punted to a router’s CPU when it cannot be
finding direct data references, and will fail to find indirect handled by its linecards, and must be inspected and process
references. Indirect references can be identified at the price switched.
indicated by the packet, or jumps the PC to a specified
location. In order to load such packets into the victim
e
od
$GP router’s IOMEM, the attacker simply needs to craft IP pack-
ec
k1
kN
4
2
k3
ISR ook
ISR ook
ag
oo
oo
oo
ets which will be punted to the router’s CPU. Any packets
-st
-H
-H
-H
-H
-H
d
ISR
ISR
which must be inspected by the router’s control-plane will
ISR
2n
.text ... suffice.3 For demonstration purposes, we used a variety of
UDP and ICMP packets. Such packets need not even be des-
tined to the router’s interface. Various malformed broadcast
and multicast packets are automatically punted to CPU and
copied to the router’s IOMEM region (on the 7200 platform).
Figure 4: The interrupt hijack shellcode first locates When the first-stage shellcode completes, the attacker has:
all eret (exception return) instructions within IOS’s
.text section. The second-stage rootkit is then un-
Host fingerprint: The list of eret addresses is exfiltrated
packed inside the $gp memory area (which is unused
to the attacker, and will uniquely identify the micro-
by IOS). All eret instructions, and thus all interrupt
version of the victim’s IOS (See Section 8).
service routines are hooked to invoke the second-
Perpetual CPU control: The second-stage code, copied
stage code. We now have reliable control of the
to the global-scope memory area, is invoked each time
CPU by intercepting all interrupt handlers of the
an interrupt is serviced by IOS.
victim router.
code to evade the watchdog timer, and avoid any perceivable We now present a second-stage rootkit which monitors all
CPU spike or performance degradation. incoming packet-data entries, or payloads of packets which
have been punted to the router’s control-plane for process
6.1 First-stage shellcode switching, continuously scanning incoming packets for com-
The interrupt hijacking shellcode performs a single scan through mands from the attacker. Using the second-stage rootkit
the router’s .text section, locating and intercepting the end presented below, the attacker can load and execute arbitrary
of all interrupt handler routines, and works as follows: code by crafting command and control packets in the pay-
load of any IP packet which will be punted to the router’s
CPU. The attacker can stealthily assemble large programs
Unpack second-stage: The second-stage shellcode, which within the router’s memory by using a wide spectrum of
contains a basic rootkit, is unpacked and copied to different packet types, like ICMP, DNS, mDNS, etc.
the location pointed to by $gp, the general purpose
register. Since we intercept all interrupt handlers, the second-stage
Locate ERET instructions: Scan through memory, look- code is invoked whenever any interrupt is serviced, including
ing for all [eret] instructions. All such addresses are timer interrupts, interrupts from linecards, etc. Therefore,
stored and exfiltrated for offline fingerprinting (See a very limited amount of computation (under a hundred
Section 7). instructions) can be done inside interrupt handlers with-
Intercept all interrupt handler routines: Hijack all in- out seriously impacting the router’s stability and perfor-
terrupt handler routines by replacing all eret instruc- mance. Figure 5 illustrates a second-stage rootkit that is de-
tions with the [jr $gp] instruction. signed specifically for high-frequency execution within inter-
rupt handlers. Each time the second-stage code is invoked,
the rootkit scans through the linked-list of packet data en-
The eret, or exception return instruction takes no operands,
tries located within IOMEM. Figure 6 shows a snapshot of
and is represented by the 32-bit value [0x42000018]. As the
this data structure in IOMEM. Each time the second-stage
name suggests, eret is the last instruction in any interrupt
code is invoked, it scans through a fixed number of packet-
handler routine, and returns the CPU context back to the
data entries, looking for specially marked packets containing
previous state before the interrupt was serviced. Once inter-
a 32-bit magic number. The number of packet data entries
cepted, any interrupt serviced by the CPU will invoke our
scanned at each iteration directly impacts the reliability of
second-stage code, giving us persistent, perpetual control of
this method (See Section 8).
the CPU to execute our second-stage rootkit.
Once such an entry is found, the second-stage code does the
6.2 Second-stage shellcode following:
The second-stage is essentially a simple code loader which
continuously monitors the router’s IOMEM range, looking
for incoming packets with a specific format. The second- Parse OpCode: Parse the packet data entry, looking for
stage rootkit locates packet payloads marked with a 32-bit a 1-byte opcode, along with a 4-byte target address
magic-number. Such packets contain a 4-byte target address value.
value, a 1-byte flag and variable length data (up to the MTU 3
of the network). Different router platforms have different packet handling
capabilities, trying to reduce the number of packets that
must be punted to CPU. However, packets destined to rout-
When such a packet is found, the second-stage either copies ing processes, like BGP, OSPF, along with ICMP and SNMP
the variable length data to the 4-byte memory location as packets are typically punted to CPU.
ISR #1 ISR #2 ISR #3 ... ISR #N
2nd-stage shellcode: init
Load Code
IOMEM Packet
Scrubber Execute Code
2nd-stage shellcode: exit
eret
Figure 5: Interrupt hijack second-stage rootkit. Each Figure 6: Highlighted words, left to right, top to bot-
time any ISR (interrupt service routine) is invoked, tom. 1: Pointer to previous packet data node. 2.
the rootkit will seek through the latest punted pack- Pointer to next packet data node. 3. Exfiltration re-
ets within IOMEM for specially crafted command and quest magic pattern. 4. Beginning of next packet data
control packet payloads. entry, pointed to by 2.
If OpCode = Load: The second-stage code will copy the The video demonstration of the interrupt hijack shellcode
content of the remainder of the packet-data entry to running on a Cisco 7204 router and 12.4T IOS can be found
the 4-byte address indicated by the packet. at [7].
If OpCode = Run: The second-stage code will jump the
PC to the target address indicated by the packet. 7. STEALTHY DATA EXFILTRATION
After the first-stage shellcode completes, it yields a sequence
of memory addresses where the eret instruction is located.
As Section 8 shows, this data can serve as a host fingerprint,
The second-stage code is designed to execute with high fre- allowing the attacker to identify the exact micro-version of
quency, but in small bursts. It will execute approximately the victim’s IOS firmware. Several known methods can be
100 instructions each time it is invoked, which allows us to used to exfiltrate this fingerprint back to the attacker. Note
scan through several dozen packets before returning control that the entire memory sequence need not be transmitted, as
of the CPU back to the interrupt handler, and thus the pre- a simple hash of the data will suffice. The attacker can carry
empted IOS code. out a VTY binding [16] to open a reverse shell back to the
attacker, or simply use the console connection to generate
Note that the head of the packet-data linked-list structure an ICMP packet back to the attacker. Depending on which
is located in a well-known address within the IOMEM re- services are publicly accessible on the router, the attacker
gion, which is mapped to the same virtual-memory address can inject the fingerprint data into the server response. For
regardless of router model or IOS version [6], making this example, the HTTP server’s default HTML can be modified.
packet-scrubbing technique reliable across all IOS versions
on many router platforms. These methods will most likely leave some detectable side-
effect which can trigger standard network intrusion detection
The intercept hijacking shellcode has several interesting ad- system. We present a new exfiltration technique which mod-
vantages over existing rootkit techniques. First, the com- ifies the payload content of process-switched packets just
mand and control protocol is built into the payload of in- prior to transmission. The data is exfiltrated using packets
coming packets. No specific protocol is required, as long as generated by router itself, thus making the detection of this
the packet is punted to the router’s control-plane. This al- covert channel more difficult.
lows the attacker to access the backdoor using a wide gamut
of packet types, thus evading network-based intrusion detec- Once a packet is punted to the router’s control-plane, it is
tion systems. Hiding the rootkit inside interrupt handlers copied from the network interface hardware to the router’s
also allows it to execute forever without violating any watch- IOMEM region. For efficiency, when such a packet is pro-
dog timers. Furthermore, the CPU overhead of this shell- cess switched, the packet-data entry is not copied. Instead,
code will be distributed across a large number of random IOS the pointer to this data is simply moved from the router’s
processes. Unlike with shellcodes which take over a specific RX queue to its TX queue. Once there, the packet is sched-
process, the network administrator cannot detect unusual uled for transmission, then forwarded appropriately. If the
CPU spikes within any particular process using commands attacker can modify the contents of the packet-data entry be-
like show proc cpu, making it very difficult to detect by con- fore it is transmitted, such payloads can be used as a vehicle
ventional means. for stealthy exfiltration. Figure 7 illustrates this exfiltration
Victim Router
Hardware Platform Sample Size Reliability
xref 7200 76 100%
RX Queue TX Queue eret 7200 76 100%
2: Packet data
copied to IOMEM. xref 3600 52 100%
icmp
request Packet Data eret 3600 52 100%
icmp
reply
xref 2800 31 0%
...magic-pattern... eret 2800 31 100%
4: ICMP
{Exfiltrated Data} request
serviced by Table 1: Reliability of the disassembling shellcode
CPU. Packet
Interrupt
3: Shellcode Data linked to and interrupt hijack shellcode when tested on 159
locates magic- TX Queue.
Hijack
pattern, overwrites IOS images.
Shellcode
payload with
exfiltrated data.
2 4 8 16 32 64
reliability 0% 0.67% 1.29% 4.67% 5.38% 10.10%
1: Attacker 5: Exfiltrated data
sends ICMP sent via ICMP
request with Attacker response back to Table 2: Reliability of exfiltration mechanism when
magic pattern in attacker. Win!
payload. the number of packet-data nodes searched per invo-
cation varies. Searching more than 64 nodes caused
the test router to behave erratically.
Figure 7: Data exfiltration through forwarded
packet payload. 1: The attacker crafts a packet with
a magic pattern in its payload indicating exfiltration The computational overhead of both shellcodes are shown
request. 2: Packet payload is copied into a *packet in Figure 10 for a typical 7200 IOS 12.4 image. In some in-
data* structure. 3: Rootkit locates magic pattern, stances, the disassembling shellcode did not terminate in
overwrites remaining packet with exfiltrated data. time, which triggered a watchdog timer exception to be
4: Packet is process-switched. The packet data en- thrown and logged (See Figure 11). The interrupt hijack
try is linked to the TX queue. 5: The requested shellcode consistently completed first-stage execution with-
data is sent back to the attacker inside an ICMP out triggering any watchdog timer exception.
response packet.
Table 2 shows the reliability of the exfiltration mechanism
presented in Section 7, as the number of packet-data nodes
searched during each interrupt-driven invocation. The re-
process. liability rate is calculated by counting the number of exfil-
tration requests the rootkit successfully answered out of 150
This type of manipulation is highly time-sensitive, as the ICMP requests. Searching more than 64 nodes at each in-
attacker will typically only have a few milliseconds after the vocation caused the router to behave erratically, sometimes
packet’s arrival to locate and manipulate its payload, before leading to crashes.
the packet is transmitted. However, since the second-stage
rootkit is invoked with every interrupt, it can precisely in- Figure 8 and 9 shows the distribution of features found by
tercept the desired packet before it is placed on the TX the disassembling shellcode and interrupt hijack shellcode
queue, allowing the attacker to use the same covert com- respectively across 159 tested IOS images. Note that while
mand and control channel for data exfiltration. Section 8
discusses the performance of this exfiltration method. Due
to the timing constraints of the interrupt hijack shellcode
and various race conditions related to process-switching and
CEF, not all exfiltration requests sent by the attacker will
be processed. In practice, approximately 10% of exfiltra-
tion requests are answered by the rootkit when tested on an
emulated 7204VXR/NPE-400 router.
The video demonstration of this exfiltration method can be
found at [7].
8. EXPERIMENTAL DATA
The reliability of the disassembling shellcode, presented in
Section 5 and the interrupt hijack shellcode, presented in Figure 10: CPU utilization of 7204 router during the
Section 6, are shown in Table 1. Three major Cisco router first-stage execution of both the disassembling and
platforms, the 7200, 3600 and 2800 series routers are tested. intercept hijack shellcodes. Note that the interrupt
The two proposed shellcode algorithms are tested against hijack shellcode is simpler, requires less CPU and
159 IOS images, ranging from IOS version 12.0 to 15. thus avoids watchdog timer exceptions.
Distribution of "Bad Secrets" string x−ref in IOS (32−bit memory space) Distribution of ERET instruction in IOS (32−bit memory space)
250 250
200 200
0x00 − 0xff
0x00 − 0xff
150 150
100 100
50 50
0 0
4000 4000
3000 4000 3000 4000
2000 3000 2000 3000
2000 2000
1000 1000
1000 1000
0x000 − 0xfff 0 0 0x000 − 0xfff 0 0
0x000 − 0xfff 0x000 − 0xfff
Figure 8: Distribution of the location of the Figure 9: Distribution of the location of eret
password authentication function. This lo- instructions over 162 IOS images. These lo-
cation varies greatly across the IOS .text cations mark the end of all interrupt ser-
segment, forcing the disassembling shell- vice routines in IOS, and tend to be concen-
code to search a large region. trated within a predictable region of IOS.
Such a defensive mechanism, called Symbiotic Embedded
Machines, have been proposed by the authors to solve this
problem [8]. We have shown that Symbiotes can be injected
into Cisco IOS in a version-agnostic manner to provide con-
tinuous integrity validation capability to the host router.
Our experimental results show that such Symbiotes can de-
tect unauthorized modification to any static region of IOS
in approximately 300ms. Symbiotic defenses of this type is
the focus of ongoing research.
10. CONCLUSION
Figure 11: CPU intensive shellcodes will be caught We present a two-stage attack strategy against Cisco IOS, as
by Cisco’s watchdog timer, which terminates and well as two unique multi-stage shellcodes capable of reliable
logs all long running processes. The disassembling execution within a large collection of IOS images on differ-
shellcode, although reliably bypasses password ver- ent hardware platforms. The disassembling shellcode, first
ification, consistently triggered the watchdog timer, proposed by Felix Lindner [12] operates by scanning through
generating the above logs, which give precise mem- the router’s memory, looking for a string reference, allowing
ory location of the shellcode. the attacker to disable authentication on the victim router.
The interrupt hijack shellcode injects a second-stage shell-
code capable of continuously monitoring incoming punted
the string reference tends to be more widely distributed, packets for specially crafted command and control packets
interrupt handler routines are typically found in a much from the attacker. The attacker can use this covert backdoor
smaller area. While the exact location of interrupt han- by sending a wide gamut of packet types, like ICMP and
dlers still remain unpredictable, this concentration allows UDP, with specially crafted payloads. In both shellcodes,
the interrupt hijack first-stage shellcode to search through when the first-stage completes execution, a host fingerprint
a relatively small range of memory when compared to the is computed and exfiltrated back to the attacker. Using this
disassembling shellcode. data, the attacker can accurately identify the exact micro-
version of IOS running on the host router. Using the second-
9. DEFENSE stage rootkit, the attacker can then upload a version specific
In order to categorically mitigate against the offensive tech- rootkit, which can be pre-made a priori for all IOS images,
niques described in this paper, host-based defenses must onto the victim router. This two-stage attack scenario al-
be introduced into the router’s firmware. Since persistent lows the attacker to compromise any vulnerable IOS router
rootkits must modify portions of the router’s code, a self- as if the specific version of the firmware is known, bypass-
checksumming mechanism can be injected into IOS to de- ing the software diversity hurdle which has obstructed the
tect and prevent unauthorized modification of IOS itself. reliable, large-scale rootkit execution within Cisco routers.
This can be generalized to all regions of the router which
should remain static during normal operation of the router, 11. ACKNOWLEDGEMENTS
and can include large portions of the .data, ROMMON, and This work was partially supported by DARPA Contract,
.text sections. CRASH Program, SPARCHS, FA8750-10-2-0253.
12. REFERENCES Target Platform Tested IOS versions Size
[1] kaiten.c IRC DDOS Bot. All MIPS (12.0 - 12.4) 200 bytes
[Link]
[2] Injunction Against Michael Lynn. Table 3: MIPS-based disassembling rootkit statis-
[Link] tics.
[Link].
[3] The Target Platform Tested IOS versions Size
End of Your Internet: Malware for Home Routers, 2008. All MIPS (12.0 - 12.4) 420 bytes
[Link]
[4] Network Bluepill. [Link], 2008.
Table 4: MIPS-based interrupt hijack rootkit statis-
[Link]
tics.
[5] New worm can infect home modem/routers.
[Link], 2009.
[Link] APPENDIX
[6] Vijay Bollapragada, Curtis Murphy, and Russ White. A. DISASSEMBLING SHELLCODE
Inside cisco ios software architecture. Cisco Press, Source code is available to reputable researchers upon formal
2000. Demonstration of Hardware Trojans. request.
[7] Ang Cui.
[Link]
[8] Ang Cui and Salvatore J. Stolfo. Generic Rootkit
B. INTERRUPT HIJACKING SHELLCODE
Source code is available to reputable researchers upon formal
Detection for Embedded Devices Using Parasitic
request.
Embedded Machines. Technical report, Columbia
University, Department of Computer Science, 2010.
[9] Ang Cui and Salvatore J. Stolfo. A quantitative
analysis of the insecurity of embedded network
devices: results of a wide-area scan. In Carrie Gates,
Michael Franz, and John P. McDermott, editors,
ACSAC, pages 97–106. ACM, 2010.
[10] Andy Davis. Cisco ios ftp server remote exploit. In
[Link] 2007.
[11] Felix ”FX” Lindner. Cisco Vulnerabilities. In In
BlackHat USA, 2003.
[12] Felix ”FX” Lindner. Cisco IOS Router Exploitation. In
In BlackHat USA, 2009.
[13] Michael Lynn. Cisco IOS Shellcode, 2005. In BlackHat
USA.
[14] Sebastian Muniz. Killing the myth of Cisco IOS
rootkits: DIK, 2008. In EUSecWest.
[15] Sebastian Muniz and Alfredo Ortega. Fuzzing and
Debugging Cisco IOS, 2011. In Blackhat Europe.
[16] Varun Uppal. Cisco IOS Bind shellcode v1.0. In
[Link] 2007.