Nytro Posted November 17, 2013 Report Posted November 17, 2013 Understanding the Low Fragmentation HeapBlackhat USA 2010Chris ValasekX-Force Researchercvalasek = gmail.com@nudehaberdasherTable of ContentsIntroduction ................................................................................................................................................ 4Overview ................................................................................................................................................. 4Prior Works ............................................................................................................................................. 5Prerequisites ........................................................................................................................................... 6Terminology ............................................................................................................................................ 6Notes ...................................................................................................................................................... 7Data Structures ........................................................................................................................................... 7_HEAP ..................................................................................................................................................... 7_HEAP_LIST_LOOKUP.............................................................................................................................. 9_LFH_HEAP ........................................................................................................................................... 10_LFH_BLOCK_ZONE ............................................................................................................................... 11_HEAP_LOCAL_DATA ............................................................................................................................ 11_HEAP_LOCAL_SEGMENT_INFO ........................................................................................................... 12_HEAP_SUBSEGMENT ........................................................................................................................... 12_HEAP_USERDATA_HEADER ................................................................................................................. 13_INTERLOCK_SEQ .................................................................................................................................. 14_HEAP_ENTRY ....................................................................................................................................... 15Overview ............................................................................................................................................... 16Architecture .............................................................................................................................................. 17FreeLists ................................................................................................................................................ 17Algorithms ................................................................................................................................................ 20Allocation .............................................................................................................................................. 20Back-end Allocation .............................................................................................................................. 21RtlpAllocateHeap .............................................................................................................................. 21Overview ........................................................................................................................................... 27Front-end Allocation ............................................................................................................................. 28RtlpLowFragHeapAllocFromContext ................................................................................................. 28Overview ........................................................................................................................................... 36Example ............................................................................................................................................ 37Freeing .................................................................................................................................................. 40Back-end Freeing .............................................................................................................................. 41RtlpFreeHeap .................................................................................................................................... 41Overview ........................................................................................................................................... 47Front-end Freeing ................................................................................................................................. 48RtlpLowFragHeapFree ....................................................................................................................... 48Overview ........................................................................................................................................... 51Example ............................................................................................................................................ 52Security Mechanisms ................................................................................................................................ 55Heap Randomization ............................................................................................................................. 55Comments ......................................................................................................................................... 56Header Encoding/Decoding .................................................................................................................. 56Comments ......................................................................................................................................... 57Death of bitmap flipping ....................................................................................................................... 58Safe Linking ........................................................................................................................................... 59Comments ......................................................................................................................................... 59Tactics ....................................................................................................................................................... 60Heap Determinism ................................................................................................................................ 60Activating the LFH ............................................................................................................................. 60Defragmentation ............................................................................................................................... 61Adjacent Data ................................................................................................................................... 62Seeding Data ..................................................................................................................................... 63Exploitation ........................................................................................................................................... 67Ben Hawkes #1 .................................................................................................................................. 67FreeEntryOffset Overwrite ................................................................................................................ 71Observations ......................................................................................................................................... 79SubSegment Overwrite ..................................................................................................................... 79Example ............................................................................................................................................ 83Issues ................................................................................................................................................ 83Conclusion ................................................................................................................................................ 85Bibliography .............................................................................................................................................. 86Download:http://www.illmatics.com/Understanding_the_LFH.pdf Quote