Barnaby Jack developed a method for exploiting certain NULL pointer dereferences on the ARM and XScale architectures (and likely PowerPC). This method affects a lot of devices since most mobile phones and PDA are ARM based, and high-end routers often use the XScale architecture.
Could you introduce yourself?
Barnaby Jack: I'm a Staff Security Researcher at Juniper Networks. I've been involved in computer security for a number of years, mostly dealing with operating system internals, reverse engineering, and anything low-level. I've recently started to focus some of my research efforts into embedded systems -- I'm having fun with it. I'm a kiwi born and bred, but these days I'm living way across the pond up in the bay area.
Could you describe the vector rewrite attack you have developed?
Barnaby Jack: The Vector Rewrite Attack is a method for exploiting certain NULL pointer dereferences on the ARM and XScale architectures. In general, NULL pointer dereference flaws are considered non-exploitable. On the XScale and ARM architectures the memory address 0 is mapped, and also holds the exception vector table. The exception vector table is a set of branch instructions that correspond to different exceptions, such as software and hardware interrupts. When a case arises that writes to the 0 address with user-defined source data, it is possible to gain execution control by rewriting the exception table.
On many embedded devices, execution is running in Supervisor (SVC) mode so memory access is unrestricted. The PowerPC architecture also stores the vector table at a low address, and is likely vulnerable to this same attack. Research into the PPC architecture is ongoing.
A short paper describing the attack is available [PDF].
There were some comments around the net about your attack and its link with the JTAG interface. Could you please explain us how you used JTAG and the link with your attack?
Barnaby Jack: The JTAG interface is a hardware interface that when used in conjunction with a hardware debugging probe, allows live debugging of the embedded processor. JTAG is simply used as a debugging mechanism. JTAG is in no way required for an attack, and is used for exploit development in the same way a debugger such as ollydbg would be used on a PC. Most modern cores have JTAG support built into the processor design.
Which architectures are affected?
Barnaby Jack: ARM and XScale architectures, and likely the PowerPC architecture. The MIPS processor maps the vectors to a high address, and is not susceptible to this exploitation method. Any architecture that stores the vector table at 0x0 would be vulnerable to this attack.
Can we consider this a hardware design problem?
Barnaby Jack: This could be considered more of a problem in the architecture design. The MIPS architecture for example bases the exception vectors at a high address, at 0x8000xxxx. Thankfully, with ARM, XScale, and PowerPC -- there is an option to map the vectors to a high address.
On ARM9 and newer cores, the exception table can be relocated high by driving the HIVECS processor pin high. On the XScale core, the vectors can be relocated high by setting the Exception Vector Relocation Bit of the ARM control register to 1. The vectors will be mapped to address 0xFFFF0000.
Manufacturers of networked devices could issue a firmware update to remap the vectors to high memory.
I saw a thread on the dailydave mailing list, where Brad Spengler posted: "I submit for your record-keeping what I believe to be the first public exploit for a null ptr dereference bug in the Linux kernel." It seems they are talking about x86 too?
Barnaby Jack: There have been examples of NULL pointer exploitation on a variety of architectures and platforms, including a locally exploitable vulnerability in pt_chmod from 1994 found by 8lgm. More recently, skape wrote a paper on exploiting NULL pointers in Internet Explorer.
The Vector Rewrite Attack is not the first time a NULL pointer dereference has been manipulated to cause an exploitable vulnerability -- but I haven't been made aware of any published vulnerabilities that use the NULL address to overwrite interrupt entries to gain execution control. What I like about the Vector Rewrite Attack, is the fact that it can be leveraged both locally and remotely and is 100% reliable -- it also affects the most popular embedded architectures.
So we could remotely exploit a NULL pointer dereference if the code is running on a vulnerable architecture?
Barnaby Jack: Yes, if you can write to the NULL pointer with user defined data, this attack can certainly be exploited remotely. In fact, this attack is more reliable than a remote stack overflow, due to the fact that no offsets are required. You will always be writing to address 0. The only data needed by an attacker is a copy of the vector table, which can be acquired by downloading and reversing the targets firmware, or retrieving the table via the JTAG interface. The vector table will remain static, and will only change with some firmware revisions.
The fact that your attack works without having to guess an offset means that it could be suitable for worms attacking these devices?
Barnaby Jack: As embedded exploitation is still in its infancy, I don't foresee a worm in the very near future -- but yes, if a worm was targeting embedded devices, this would be a reliable attack vector.
What type of devices use this hardware?
Barnaby Jack: ARM cores are the most widely-used 32 bit cores in the world. Most mobile phones and PDA's are ARM based. Higher end routers often use the XScale architecture, while home routers tend to split between ARM and MIPS based cores. In general, if you have a consumer electronics product, there is a high chance it has an ARM based processor.
Some of these devices features very limited resources, so what type of limits are there once you have broken in?
Barnaby Jack: As an example, I gave a live attack demonstration that remotely compromised a popular home router. The shellcode of the remote exploit first cleared the administrator password on the router by patching the password location in memory. The shellcode then set the flag that enables remote administration of the router. The exploit then forced a soft reset on the device. Once the device re-initialized, it was possible to log into the router, with administrator privileges, with no password, from anywhere on the internet. The remote administration interface allows a remote firmware upgrade. The next step was to upload a modified version of the firmware. The firmware had additional code that would watch for any portable executable file being downloaded over the HTTP port. Once a PE file was detected, the PE file would be patched to include a stub that would retrieve a remote executable and execute the file, before returning to the host executable.
i.e.: if a router you were using had been exploited, and the firmware patch was active, any seemingly legit executable download would be infected with a stub that would execute a file of my choosing. The hostile executable would run transparently along with the original executable.
This was a method to ultimately compromise an internal network via the router.
It really comes down to the creativity of the attacker, any device that is connected to a network poses a threat.