Heap Spray Protections

Prorootect

Level 69
Thread author
Verified
Nov 5, 2011
5,855
On corelan.be : Exploit writing tutorial part 11 : Heap Spraying Demystified : https://www.corelan.be/index.php/2011/12/31/exploit-writing-tutorial-part-11-heap-spraying-demystified/

QUOTE:

'Heap Spray Protections:

Nozzle & BuBBle
Nozzle and BuBBle are 2 examples of defense mechanisms against heap spraying attacks. Implemented inside the browser, they will attempt to detect a heap spray and prevent it from working.

The Nozzle research paper, published by Microsoft, explains that the Nozzle mechanism attempts to detect series of bytes that would translate into valid instructions. Nozzle will attempt to recognize recurring bytes that translate into valid instructions (a NOP sled for example), and prevent the allocation.

The BuBBle routine is based on the fact that heap sprays trigger allocations that contain the same (or very similar) content : a large nop sled + shellcode (or padding + rop chain + shellcode + padding). If a javascript routine attempts to allocate multiple blocks that have the same content, BuBBle will detect this and prevent the allocations.

This technique is now implemented in Firefox.

Both these techniques would be successful in blocking most heap sprays that deploy nops + shellcode (or even nops + rop + shellcode + nops in case of a precise heap spray). In fact, when I tested heap spraying against more recent versions of most mainstream browsers (Internet Explorer 9, Firefox 9), I discovered that both of them most likely implement at least one of these techniques.



EMET
EMET, a free utility from Microsoft, allows you to enable a variety of protection mechanisms that will decrease the likelihood an exploit can be used to take over your system. You can find a brief overview of what EMET offers here.

When enabled, the heapspray protection will pre-allocate certain “popular” regions in memory. If locations such as 0a0a0a0a or 0c0c0c0c are already allocated by something else (EMET in this case), your heapspray would still work, but your popular target address would not contain your data, so jumping to it would not make a lot of sense.

If you want more control over the kind of protections EMET will enable for a given application, you can simply add any executable and set the desired options.



HeapLocker
The HeapLocker tool, written by Didier Stevens, provides yet another protection mechanism against heap sprays. It deploys a number of techniques to mitigate a heap spray attack, including:

It will pre-allocate certain memory regions (just like EMET does), and injects some custom shellcode that will show a popup, and will terminate the application immediately.It will attempt to detect nop sleds and strings in memoryIt will monitor private memory usage, and allows you to set a maximum amount of memory a given script is allowed to allocate.Heaplocker is delivered as a dll file. You can make sure the dll gets loaded into every process using LoadDLLViaAppInit or by including the heaplocker dll in the IAT of the application you want to protect.' (Emphasis by me).
 

Hungry Man

New Member
Jul 21, 2011
669
Heapspray is one of the more reliable methods for exploitation actually. Stack overflows already have a lot of mitigations, heap overflow mitigation kinda sucks.

The ones mentioned here basically try to do two things
1) Block known oft-sprayed areas, ridiculously easy to circumvent
2) Detect after-the-fact sprays kinda as they happen, which can give you a lot of FPs

ASLR and DEP are a good way to protect against any BO, really. SEHOP is basically a stack canary for a specific windows function, Windows 8 extends the same idea to the heap by performing integrity checks on the heap - I don't know the details on this though.
 

Prorootect

Level 69
Thread author
Verified
Nov 5, 2011
5,855
Hungry Man said:
Heapspray is one of the more reliable methods for exploitation actually. Stack overflows already have a lot of mitigations, heap overflow mitigation kinda sucks.

The ones mentioned here basically try to do two things
1) Block known oft-sprayed areas, ridiculously easy to circumvent
2) Detect after-the-fact sprays kinda as they happen, which can give you a lot of FPs

ASLR and DEP are a good way to protect against any BO, really. SEHOP is basically a stack canary for a specific windows function, Windows 8 extends the same idea to the heap by performing integrity checks on the heap - I don't know the details on this though.

Yeah, ASLR, DEP, SEHOP .. very nice .. but I find the accurate details you searched, with this original protection against spray attack: http://zapatopi.net/blog/propaganda-protection-against-spray-attack-original.jpg - VERY original indeed ..

It's possible that you no longer looking at these details, because this thread is a bit old .. but it is improving over time here in MT, like a fine wine .. yes all MT topics improve over time.
 

Ink

Administrator
Verified
Staff Member
Well-known
Jan 8, 2011
22,361
Noob here.

Is ASLR, DEP, SEHOP all forms of protection for memory (aka RAM)?
 

Hungry Man

New Member
Jul 21, 2011
669
ASLR randomizes address space (memory), DEP segregates the address space into code and data, and SEHOP forces the windows Exception Handler to perform an integrity check to stop exploitations after a buffer overflow.
 

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top