Hardware-Based Always-On Heap Memory Safety

Hardware-Based Always-On Heap Memory Safety

2020 53rd Annual IEEE/ACM International Symposium on Microarchitecture (MICRO) Hardware-based Always-On Heap Memory Safety Yonghae Kim Jaekyu Lee Hyesoon Kim Georgia Institute of Technology Arm Research Georgia Institute of Technology [email protected] [email protected] [email protected] Abstract—Memory safety violations, caused by illegal use of of memory objects as redzones and prohibit their access to pointers in unsafe programming languages such as C and C++, prevent over/underflow attacks. Such an approach is efficient have been a major threat to modern computer systems. However, since monitoring could be performed in parallel with normal implementing a low-overhead yet robust runtime memory safety solution is still challenging. Various hardware-based mechanisms operations, as in REST [8]. However, they cannot prevent non- have been proposed, but their significant hardware requirements adjacent illegal accesses that jump over the redzones. Given have limited their feasibility, and their performance overhead is the upward trend of non-adjacent spatial safety violations (over too high to be an always-on solution. 60% since 2014) [2], we expect that their effectiveness will In this paper, we propose AOS, a low-overhead always-on be increasingly limited. heap memory safety solution that implements a novel bounds- checking mechanism. We identify that the major challenges of Whitelisting mechanisms enforce memory operations to existing bounds-checking approaches are 1) the extra instruction only access allowed memory locations, providing stronger overhead for memory checking and metadata propagation and security capabilities. For example, bounds-checking mecha- 2) the complex metadata addressing. To address these challenges, nisms [10]–[13] associate bounds metadata with pointers to using Arm PA primitives, we leverage unused upper bits of protect and perform address range checking. Despite more a pointer to store a key and have it propagated along with the pointer address, eliminating propagation overhead. Then, powerful security guarantees, they incur significant hardware we use the embedded key to index a hashed bounds table to changes and design complexity. Their performance overhead achieve efficient metadata management. We also introduce a is also too high to be an always-on solution. micro-architectural unit to remove the need for memory checking We observe that the major challenges of existing bounds- instructions. We show that AOS overcomes all the aforementioned checking approaches are 1) the extra instruction overhead challenges and demonstrate its feasibility as an efficient runtime memory safety solution. Our evaluation for SPEC 2006 workloads for memory checking and metadata propagation and 2) the shows an 8.4% performance overhead on average. complex metadata addressing. For instance, Watchdog [11], Index Terms—Security; software and system safety; pointer a prior hardware-based bounds-checking mechanism, showed authentication; 44% more dynamic instruction counts, causing significant performance degradation. It also requires register extensions I. INTRODUCTION (up to 256-bit) to propagate the metadata and use it inside a Memory safety violations have been a conventional but CPU core, which significantly increases power consumption. persistent problem in computer systems. Memory safety issues Moreover, prior approaches often require a complex address- have inherently existed in unsafe programming languages such ing scheme for metadata accesses. For example, Intel Memory as C and C++ because of the illicit use of pointers. Recent Protection Extensions (MPX) [12] requires approximately industry reports [1], [2] revealed that memory safety errors three register-to-register moves, three shifts, and two memory addressed in their products accounted for more than 70% of all loads to access its hierarchical bounds table. security issues. This demonstrates that memory safety errors To tackle these challenges, we propose AOS, a low- are still prevalent and exploitable by attackers. overhead Always-On memory Safety solution for heap pro- Researchers have proposed extensive amounts of software- tection that implements a novel bounds-checking mechanism. and hardware-based work to prevent such vulnerabilities. Soft- We utilize Arm pointer authentication (PA) primitives [14] to ware techniques [3]–[7] provide strong security guarantees, but store a pointer authentication code (PAC) into the unused high- they are not suitable runtime solutions because of their sig- order bits of a pointer for memory safety. By doing so, we nificant performance overhead. Instead, their primary purpose allow the embedded PAC to be passed along with the pointer is for testing and debugging. For example, AddressSanitizer address, removing extra instructions for metadata propagation. (ASan), one of the most popular memory error detectors, Furthermore, we sign all data pointers returned by dynamic showed a 73% slowdown [3]. memory allocation, i.e., placing a PAC into the pointer, and Hardware-based mechanisms typically achieve less per- use the PAC to index a hashed bounds table that stores bounds formance overhead, but they do not attain desired proper- metadata. This scheme enables efficient metadata management ties altogether, such as broad security coverage, high per- since the addressing becomes simplified using the base address formance, and low hardware overhead. Instead, they trade of the table and the PAC as an offset. off one property for another. For example, hardware-based To remove additional instructions required by prior blacklisting mechanisms [8], [9] set the surrounding regions work [10]–[12] for bounds checking, we introduce a new 978-1-7281-7383-2/20/$31.00 ©2020 IEEE 1153 DOI 10.1109/MICRO50266.2020.00095 micro-architectural structure, a memory check unit (MCU). In 1 struct fast_chunk { AOS, every memory instruction is enqueued in the MCU when 2 size_t prev_size, size; it is issued to the load-store unit (LSU). If a pointer address 3 struct fast_chunk *fd, *bk; 4 char buf[0x20]; is signed, i.e., has an embedded PAC, we perform bounds 5 }; checking to validate the access, which enables an efficient 6 selective memory safety checking mechanism. 7 struct fast_chunk fchunk[2]; 8 void *ptr, *victim; AOS achieves efficient yet complete spatial and temporal 9 memory safety for a heap region. AOS prevents spatial safety 10 // Craft chunks to pass security tests violations (e.g., out-of-bounds access) by checking bounds 11 fchunk[0].size = sizeof(struct fast_chunk); 12 fchunk[1].size = sizeof(struct fast_chunk); for all signed memory accesses. Moreover, AOS can detect 13 temporal errors, such as the use of a dangling pointer, use- 14 // Attacker overwrites a pointer after-free (UAF), and double free. When a signed data pointer 15 ptr = (void *) &fchunk[0].fd; 16 is freed, AOS clears the associated bounds information while 17 // fchunk[0] gets inserted into fastbin leaving the pointer as being signed. Because of the absence 18 free(ptr); of its bounds metadata, subsequent use of the pointer will 19 20 // Returns 16 bytes ahead of fchunk[0] fail in bounds checking. With the prevalence of heap memory 21 victim = malloc(0x30); vulnerabilities, AOS provides robust protection against the Fig. 1. Heap exploitation example: House of Spirit. most prevailing attack vectors. We also discuss how AOS can be extended to support pointer integrity by utilizing Arm PA primitives and achieve practical defenses against runtime control-flow attacks, such as Stack Corruption Heap OOB Read Type Confusion Other Heap Corruption Use After Free Uninitialized Use return-oriented programming (ROP) [15] and jump-oriented 100% 59 90% 30 41 59 programming (JOP) [16], and data-oriented attacks by cor- 44 44 159 139 197 80% 61 120 9 221 103 25 rupted data pointers. AOS also provides precise exception 4 8 11 70% 4 6 8 21 22 19 handling by delaying architectural state updates until an 30 82 4 16 13 5 6 25 36 60% 7 15 61 12 6 instruction retires with a successful bounds checking. This 1 1 18 44 71 50% 22 14 81 2 186 87 4 9 39 183 enables AOS to prevent leakage of secret data by an illegal 40% 36 35 113 81 57 99 30% 43 7 read and memory corruption by an illegal write. 45 64 76 88 5 20% 13 39 55 Given the limited PAC size (11 to 32 bits) under typical 32 30 36 17 10% 24 35 71 104 21 22 26 61 79 virtual address schemes in a processor, some memory objects 13 28 0% 4 11 4 1 3 7 8 may have the same PAC value, causing PAC collisions. To address this issue, we develop a multi-way bounds-table struc- 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 ture with gradual resizing to accommodate multiple bounds Fig. 2. The root cause trend of memory safety issues. metadata for each PAC. A process begins its execution with a modest-size table and increases the associativity of the table upon an insertion failure due to insufficient capacity. This approach enables efficient and scalable bounds-table exploitation, House of Spirit, which is a data-oriented attack management. on glibc. The attack crafts a data pointer controlled by an This paper claims the following contributions: attacker so it can bypass the security tests of free(). Once • We propose AOS, which overcomes the main challenges of freed, the pointer is inserted into a fastbin, which is one of existing bounds-checking approaches and realizes a practi- the linked lists holding free chunks. Then, the next malloc() cal bounds-checking mechanism for heap protection. returns the address 16 bytes ahead of the crafted data pointer • We implement the AOS design and present performance and ends up allowing subsequent malicious operations on the evaluation for SPEC 2006 workloads. Our results show a attacker-controlled memory locations. marginal 8.4% performance overhead on average. • We describe how AOS can cooperate with pointer integrity Fig. 2 shows a root cause trend of memory safety vul- solutions, which demonstrates that the security capabilities nerabilities reported by Microsoft [2].

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us