Title
VTrust: Regaining Trust on Virtual Calls
Chao Zhang, Sco5 A. Carr, Tongxin Li, Yu Ding, Chengyu Song, Mathias Payer, Dawn Song
UC Berkeley, Purdue University, Peking University, Georgia Tech
VTrust: Regaining Trust on Virtual Calls Chao Zhang , Sco5 A. Carr, - - PowerPoint PPT Presentation
Title VTrust: Regaining Trust on Virtual Calls Chao Zhang , Sco5 A. Carr, Tongxin Li, Yu Ding, Chengyu Song, Mathias Payer, Dawn Song UC Berkeley, Purdue University, Peking University, Georgia Tech Title Virtual Call Hijacking in real world A
Title
UC Berkeley, Purdue University, Peking University, Georgia Tech
Title
use aEer free format string heap
… Virtual Call Hijacking
plenty of vulnerabiliMes:
Google: "80% a5acks exploit use-aEer-free...” Microso-: 50% CVEs targeted Winows7 are UAF
A common way to exploit:
2
Title
§ How to resolve the virtual funcMon of an object at runMme?
class B{ virtual void foo(); } class D1: public B{ virtual void foo(); int data1; } class D2: public B{ virtual void foo(); int data2; }
Class Hierarchy: void test ( B* obj ) {
} B::foo, D1::foo, or D2::foo?
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1 vfptr
data2 D2::foo() ...
VTable of Class D2
RunMme Memory: Resolve virtual funcMons: Step 1: read VTable pointer from obj Step 2: read funcMon pointer from VTable
3
Title
§ A5acks: breaking the integrity of VTable pointers
§ VTable injecMon a5ack: vfptr points to forged VTables Resolve virtual funcMons: Step 1: read VTable pointer from obj Step 2: read funcMon pointer from VTable RunMme Memory:
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1 ROP() ...
forged VTable
PracAcal and reliable: virtual call hijacking + ROP
4
Title
§ A5acks: breaking the integrity of VTable pointers
§ VTable injecMon a5ack: vfptr points to forged VTables § VTable reuse a5ack: vfptr points to exisAng but out-of-context VTables
Resolve virtual funcMons: Step 1: read VTable pointer from obj Step 2: read funcMon pointer from VTable RunMme Memory:
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1 fp() ...
COOP aEack [S&P’15]
5
Title
§ MoMvaMon § Related Work § Design § ImplementaMon § EvaluaMon § Conclusion
6
Title
§ VTint [NDSS’15] § T-VIP [ACSAC’14]
§ Pro:
§ Con:
writable section read-only? vf() ... vfptr
VTable
data 7
Title
§ GCC-VTV [Usenix’14], whitelist-based
§ Pro:
§ Con:
8
Title
§ CCS’15, CFI-based
§ Con:
9
Title
§ MoMvaMon § Related Work § Design:
§ ImplementaMon § EvaluaMon § Conclusion
10
Title
§ A virtual funcMon is allowed at a virtual call site if and only if it has:
void test ( B* obj, int arg1, void* arg2) { // virtual call site
} class D: public B { // virtual funcMons virtual void foo(int arg1, void* arg2); }
11
Title
// virtual call site: expected type
// virtual funcMons definiMons: target type virtual void foo(int arg1, void* arg2);
§ How to encode the type informaMon, to enable fast
ASSERT( expected_type == target_type )
12
Title
// virtual call site: expected type
// virtual funcMons definiMons: target type virtual void foo(int arg1, void* arg2);
§ Our soluMon: compute a signature for the type § All signatures can be computed staMcally and independently.
ASSERT( expected_type == target_type )
signature = hash ( funcName, typeList, qualifiers, classInfo )
ASSERT( expected_signature == target_signature )
13
Title
§ No ma5er what VTables are used, target virtual
§ A5ackers can forge signatures if and only if
Virtual Func Type Enforcement
Target Applications
VTable Reuse VTable Injection
14
Title
§ SoluMon: limit the target funcMons to staMc code § How?
virtual funcMon lookup.
writable section read-only section D1::foo() ... vfptr
VTable of Class D1
data1
writable section read-only section D1::foo() ... vt_idx
VTable of Class D1
data1 D1::vfptr ...
Translation Table
15
Title
§ MoMvaMon § Related Work § Design § ImplementaMon § EvaluaMon § Conclusion
16
Title
§ Compute signatures
§ destructor funcMons § member funcMon pointers
§ top-most primary class’ name
§ Instrument signatures
ASSERT( expected_signature == target_signature )
signature = hash ( funcName, typeList, qualifiers, classInfo )
17
Title
§ A centralized translaMon table is impracMcal
§ Our soluMon: distributed translaMon table
writable section read-only section D1::foo() ... vt_idx
VTable of Class D1
data1 D1::vfptr ...
Translation Table
writable section read-only section D1::foo() ... idx_pair
D1's VTable
data1 D1::vfptr ...
Translation Table for lib1
D2::vfptr ...
Translation Table for lib2
D1::foo() ...
D2's VTable
lib1 lib2 ...
Global Translation Table
translaMon tables.
18
Title
LLVM Opt *.cpp LLVM IR (metadata) Clang/ Clang++ LLVM IR (checks) LLVMgold.so *.obj LLVM CodeGen VTLib.so *.cpp VTable metadata Collector VTLib.cpp executable/ libraries ld.gold
layer 1: VFunc Type Enforcement (part 2) layer 2: VTable Pointer Sanitization layer 1: VFunc Type Enforcement (part 1)
19
Title
§ MoMvaMon § Related Work § Design § ImplementaMon § EvaluaMon § Conclusion
20
Title
§ SPEC 2006
0.00%$ 1.00%$ 2.00%$ 3.00%$ 4.00%$ 5.00%$ 6.00%$ x a l a n c . $ a s t a r $
n e t p p $ s
l e x $ d e a l I I $ n a m d $ p
r a y $ G e
M e a n $ TypeEnforce$ VTableSanCze$
The 1st layer defense is much faster than the 2nd layer, sufficient for programs without dynamic generated code.
21
Title
§ Firefox
!0.50%& 0.00%& 0.50%& 1.00%& 1.50%& 2.00%& 2.50%& 3.00%& 3.50%& L i t e B r i t e & K r a k e n & S u n s p i d e r & B r
s e r m a r k & O c t a n e & P e a c e K e e p e r & G e
M e a n . & TypeEnforce& VTableSaniHze&
22
Title
§ VTable injecMon a5acks § VTable reuse a5acks (few in real world)
23
Title
§ Custom virtual funcMon definiMons
§ Custom virtual call sites
§ VTrust could idenMfy all these corner cases
24
Title
§ VTrust provides two layers of defenses against all virtual
§ Virtual funcAon type enforcement introduces a very low
§ VTable pointer saniAzaAon could help defeat all a5acks
§ The performance and security evaluaMon show that
25
Title