Presentation is loading. Please wait.

Presentation is loading. Please wait.

The future of Software Security Dr. Si Chen

Similar presentations


Presentation on theme: "The future of Software Security Dr. Si Chen"— Presentation transcript:

1 The future of Software Security Dr. Si Chen (schen@wcupa.edu)
Class22 CSC 495/583 Topics of Software Security Heap Exploitation (3): , House of Force The future of Software Security Dr. Si Chen

2 glibc source code

3 free(buffer); Heap Chunk (freed) Forward Pointer Backwards Pointer
Heap Chunks – Freed unsigned int * buffer = NULL; buffer = malloc(0x100); free(buffer); Forward Pointer A pointer to the next freed chunk Backwards Pointer A pointer to the previous freed chunk Heap Chunk (freed) Previous Chunk Size (4 bytes) Chunk Size (4 bytes) FD (4 bytes) BK (4 bytes) Flags *(buffer-2) *(buffer-1) *buffer *(buffer+1)

4 unsigned int * buffer = NULL; buffer = malloc(0x100);
Heap Chunks unsigned int * buffer = NULL; buffer = malloc(0x100); //Out comes a heap chunk Heap Chunk Previous Chunk Size (4 bytes) Chunk Size (4 bytes) Data (8 + (n / 8)*8 bytes) Flags *(buffer-2) *(buffer-1) *buffer

5 Heap Allocations Runtime Memory Heap Segment Previous Chunk Size
0x Runtime Memory Libraries (libc) ELF Executable .text segment .data segment Heap Stack Heap Segment > Grows towards higher memory Previous Chunk Size Chunk Size Data 0xFFFFFFFF

6 Heap Allocations Runtime Memory Heap Segment Previous Chunk Size
0x Runtime Memory Libraries (libc) ELF Executable .text segment .data segment Heap Stack Heap Segment > Grows towards higher memory Previous Chunk Size Chunk Size Data 0xFFFFFFFF

7 The truth

8 The Malloc Maleficarum (2004)
In late 2001, "Vudo Malloc Tricks" and "Once Upon A free()" defined the exploitation of overflowed dynamic memory chunks on Linux. In late 2004, a series of patches to GNU libc malloc implemented over a dozen mandatory integrity assertions, effectively rendering the existing techniques obsolete. It is for this reason, a small suggestion of impossibility, that they present the Malloc Maleficarum: The House of Prime The House of Mind The House of Force The House of Lore The House of Spirit The House of Chaos

9 The Malloc Maleficarum (2004)
In late 2001, "Vudo Malloc Tricks" and "Once Upon A free()" defined the exploitation of overflowed dynamic memory chunks on Linux. In late 2004, a series of patches to GNU libc malloc implemented over a dozen mandatory integrity assertions, effectively rendering the existing techniques obsolete. It is for this reason, a small suggestion of impossibility, that they present the Malloc Maleficarum: The House of Prime The House of Mind The House of Force The House of Lore The House of Spirit The House of Chaos

10 House of Force House of Force: In this technique, attacker abuses top chunk size and tricks ‘glibc malloc’ to service a very large memory request (greater than heap system memory size) using top chunk. Now when a new malloc request is made, GOT entry of free would be overwritten with shellcode address. Hence from now on whenever free is called, shellcode gets executed!!

11 Mechanism of glibc malloc
Allocated chunk Free chunk Top chunk

12 Top Chunk Top Chunk: Chunk which is at the top border of an arena is called top chunk. It doesn't belong to any bin. Top chunk is used to service user request when there is NO free blocks, in any of the bins. If top chunk size is greater than user requested size top chunk is split into two: User chunk (of user requested size) Remainder chunk (of remaining size) The remainder chunk becomes the new top. If top chunk size is lesser than user requested size, top chunk is extended using sbrk (main arena) or mmap (thread arena) syscall.

13 House of Force

14 House of Force This attack assumes an overflow into the top chunk's header. The size is modified to a very large value (-1 in this example). This ensures that all initial requests will be services using the top chunk, instead of relying on mmap. On a 64 bit system, -1 evaluates to 0xFFFFFFFFFFFFFFFF. A chunk with this size can cover the entire memory space of the program. 

15 House of Force  Let us assume that the attacker wishes 'malloc' to return address P. Now, any malloc call with the size of: &top_chunk - P will be serviced using the top chunk. Note that P can be after or before the top_chunk.

16 House of Force Prerequisites: Three malloc calls are required to successfully apply house of force as listed below: Malloc 1: Attacker should be able to control the size of top chunk. Hence heap overflow should be possible on this allocated chunk which is physically located previous to top chunk. Malloc 2: Attacker should be able to control the size of this malloc request. Malloc 3: User input should be copied to this allocated chunk.

17 Exercise: House_of_force.c
Source Code: Solution:

18 Exercise: BambooBox Source Code:
Solution:

19 The future …

20 Unsustainable Complexity
Exploits are getting more and more complex More bugs More time More money

21 Unsustainable Complexity
$$$$$ Exploit Complexity $ 2017 Years 20?? At what point do hobbyists have to draw the line? Companies? Contractors? Nation States?

22 Unsustainable Complexity
$$$$$ nation states sec firms the hobbyist Exploit Complexity $ 2017 Years 20??

23 Systems and applications will never be perfectly secure. Period.
The Security Mindset Systems and applications will never be perfectly secure. Period. They just have to be hard enough to break that nobody can afford it anymore

24 The Weakest Link - Humans

25 The Future of Security Memory corruption based exploits will no longer be feasible to produce for the average desktop or server In the immediate years (?) Embedded devices are further behind

26 Implementation & logic flaws will probably always exist
The Future of Security Implementation & logic flaws will probably always exist – You can’t really fix stupid What we will see and discover more of: Sponsored backdoors, ‘cheating’ Hardware backdoors, flaws, supply chain trust Crypto backdoors, subtle design flaws

27 Q & A


Download ppt "The future of Software Security Dr. Si Chen"

Similar presentations


Ads by Google