Qiang Zeng, Golam Kayas, Emil Mohammed, Lannan Luo, Xiaojiang Du, and Junghwan Rhee
DSN 2019
HeapTherapy+: Efficient Handling of (Almost) All Heap - - PowerPoint PPT Presentation
HeapTherapy+: Efficient Handling of (Almost) All Heap Vulnerabilities Using Targeted Calling-Context Encoding Qiang Zeng , Golam Kayas, Emil Mohammed, Lannan Luo, Xiaojiang Du, and Junghwan Rhee DSN 2019 2 Trend of Memory Vulnerability
Qiang Zeng, Golam Kayas, Emil Mohammed, Lannan Luo, Xiaojiang Du, and Junghwan Rhee
DSN 2019
Heap overflow => overwrite a function pointer => stack pivoting
2
[1] McAfee, “Emerging ‘Stack Pivoting’ Exploits Bypass Common Security”, 2013
3
“Because the success of stack-based exploits has been reduced by the numerous security measures, heap-based attacks are now common” [Ratanaworabhan 2009]
[Ratanaworabhan 2009] Ratanaworabhan, et al.."NOZZLE: A Defense Against Heap-spraying Code Injection Attacks." USENIX Security. 2009.
4
str = (char*) malloc(128); … // str is not initialized cout << str;
5
(1) D *p = new D(); … (2) delete p; (3) … (4) p->foo(); // use-after-free this // buffer re-allocated and used p malicious virtual function table “More than 50% of known attacks targeting Windows 7 exploit use-after-free” [Zhang 2016]
[Zhang 2016] Zhang, Chao, et al. "VTrust: Regaining Trust on Virtual Calls." NDSS. 2016.
Virtual function table foo() bar()
Ø Over-write
Ø Over-read
6
XFI, CPI (code pointer integrity), …
7
software system; however,
8 [1] S. Frei, “The Known Unknowns,” 2013. [2] S. frei, “” “End-point security failures, insight gained from secunia psi scans,” 2011.
9
More generally, for a use-after-free or uninitialized-read vulnerability, the vulnerable buffers share the same calling context when they are allocated Given a heap buffer overflow bug, the vulnerable buffers share the same calling context when they are allocated
10
→
clone start_thread handle_one_connection do_handle_one_connection my_malloc malloc thd_prepare_connection do_command MDL_key::mdl_key_init stpcpy Pathogen buffers are allocated. Pathogen buffers are overflowed.
Vulnerable buffers are allocated Vulnerable buffers are exploited
Given this vulnerability, many different exploits were collected and replayed
11
Using allocation-time calling context to characterize vulnerable buffers
calling context of each buffer. When the offending
allocation-time calling context of the vulnerable buffer
allocation-time calling context, enhance it
generation?
12
13
calling context
simple arithmetic operations
compilation optimization, logging, …
14
PCC
[Bond 2007]
PCCE
[Sumner 2010]
DeltaPath [Zeng 2014] Support Object-Oriented
✔ ✗ ✔
Decoding
✗ ✔ ✔
Scalability
✗ ✗ ✔
15
1 B() { 2 C(); 3 D(); 4 } 5 6 C() { 7 D(); 8 } 9 10 D() { 11 Sensitive API! // calling context? 12 } B C D ID = 13 ID = 3 ID = 0 ID = t * 3 + 2 ID = t * 3 + 3 Answer: Read the variable “ID” to get the calling context ID t = ID t = ID ID = t * 3 + 7 ID = 2
contexts are of interest, are known, many call sites do no need to be instrumented
to the target functions
16
17
(a) FCS (full-call-site instrumentation): original PCC encoding (b) TCS (targeted-call-site): H and I cannot reach the targets T1 and T2 (c) Slim: B, E and G each has only one out-going edge that reaches the targets (d) Incremental: F-T1 and F-G-T2 can be distinguished through the target
18
19
20
One-time program instrumentation Patch generation Patched program execution Program Instrumentation Tool
Instrumented program
Online Defense Generator Program Attack inputs Configuration file Patches Offline Patch Generator
21
Byte1 Byte2 ………….. Byten Application Memory Byte2 Shadow Information Shadow Information ………….. Shadow Information Shadow Memory Shadow Information 1 1 1 1 1 1 1 1 1
A bit V bits
0 0 0 0 0 0 0 0
A bit V bits
… … … …
(1) Detect overflow: an overflow will touch the inaccessible red zone (2) Detect use-after-free: a free-ed buffer is set as inaccessible and then added to a queue to delay the space reuse (3) Detect uninitialized read: more complex, but mainly relies on V-bits
<alloc-API, CCID, vul-type>
in the config file
22
………… …………
<API, CCID, Vulnerability> <memalign, 1854955292, OVERFLOW> <calloc, 8643565443, USE-AFTER-FREE> <malloc, 2598251483, UNINITIALIZED-READ> … ... Read by Online … … … Configuration file
23
24
………… …………
<API, CCID, Vulnerability> <memalign, 1854955292, OVERFLOW> <calloc, 8643565443, USE-AFTER-FREE> <malloc, 2598251483, UNINITIALIZED-READ> … ... Read by Online Defense Generator Key Value <MEMALIGN, 1854955292> <CALLOC, 8643565443> <MALLOC, 2598251483> ….. (001)2 (010)2 (100)2 … … Configuration file Hash table
A shared lib
25
26
27 Program Vulnerability Reference Heartbleed UR & Overflow CVE-2014-0160 bc-1.06 Overflow Bugbench [57] GhostXPS 9.21 UR CVE-2017-9740
UaF CVE-2015-7801 tiff-4.0.8 Overflow CVE-2017-9935 wavpack-5.1.0 UaF CVE-2018-7253 libming-0.4.8 Overflow CVE-2018-7877 SAMATE Dataset Variety 23 heap bugs [58]
manual analysis effort
combined with lightweight online defenses
28
Q&A
30
free call Align bit is set? Get alignment information Get original buffer address Invoke original free End Push the buffer into the queue of freed blocks Overflow bit is set? Turn the guard page into a normal page Yes Yes No No Use-after-free bit is set? No Yes