Heap Spraying
VXRL (valkyriex) <0xdarkfloydgmailcom> Tuesday, May 26 2009 05:36.55 CDT


Heap Spraying: Introduction

Heap spraying has become one of the most prevalent technique to exploit vulnerability in browser. IE �createTextRange()� and Mozilla Firefox �InstallVersion.compareTo()� are the examples of this technique. Because it is undocumented technique � actually not well document, I decide to start to study what is it and how it work.

This technique was introduced by hacker named �SkyLined�. He used Heap Spraying technique to attack the vulnerability in IE, MS04-040 and MS05-020. However I also found the technique like heap spraying, it was mentioned in Microsoft Internet Information Services Remote Buffer Overflow.

After I had read these exploit codes, I got some point about this technique. Heap spraying is used when the vulnerable program (IE, Firefox in this case) call or jmp into invalid memory. This invalid memory must be in the possible heap range address - not in DLL virtual address, PEB, TEB, etc. And it must not higher than 0x7fffffff because above this address is kernel address space. See
Windows Memory Layout for detail. This is one of the limitation of heap spraying technique.

So, what can we do if it jumps into the possible heap range but invalid memory? The answer depends on the nature of the vulnerable program. If we can't control (actually "injected") the application's heap - Gave Over. But if we can, we will inject heap as much as possible until the invalid memory become the valid memory. Sure, the injected heaps contain our nop + shellcode, so the vulnerable program will landing on our nop and shellcode :) That's why this technique is called "Heap Spraying"

Now, there is another limitation of this technique - we have to able to control the application's heap. As I known, there are few applications that we are able to control heap. Web browser is the one of these - inject heap via JavaScript

Here is a simple picture to demonstrate the basic concept about it.
URL: http://photos1.blogger.com/blogger/5848/3241/1600/Heap.Spray.jpg

Comments
Posted: Wednesday, December 31 1969 18:00.00 CST