dongseok jang zachary tatlock sorin lerner uc san diego
play

Dongseok Jang Zachary Tatlock Sorin Lerner UC San - PowerPoint PPT Presentation

Dongseok Jang Zachary Tatlock Sorin Lerner UC San Diego University of UC San Diego Washington Vulnerable Control Flow Hijacking Lead Program to


  1. ¡ Dongseok ¡Jang ¡ Zachary ¡Tatlock ¡ Sorin ¡Lerner ¡ UC ¡San ¡Diego ¡ University ¡of ¡ UC ¡San ¡Diego ¡ Washington ¡

  2. Vulnerable ¡

  3. Control ¡Flow ¡Hijacking ¡ Lead ¡Program ¡to ¡Jump ¡to ¡Unexpected ¡Code ¡ That ¡does ¡what ¡a7acker ¡wants ¡ ¡ Example: ¡Stack ¡Buffer ¡Overflow ¡ALacks ¡ Well ¡studied ¡and ¡hard ¡to ¡be ¡cri=cal ¡by ¡itself ¡ ¡ ¡ New ¡FronNer ¡: ¡Vtable ¡Hijacking ¡

  4. Vtable ¡Pointers ¡ Mechanism ¡for ¡Virtual ¡FuncNons ¡ x ¡ class C { virtual int foo(); virtual int bar(); foo’s ¡impl ¡ vptr ¡ foo ¡ int fld; bar’s ¡impl ¡ fld ¡ bar ¡ }; ... C *x = new C(); vtable ¡ heap ¡obj ¡

  5. Vtable ¡Pointers ¡ Virtual ¡Call ¡: ¡2-­‑Step ¡Dereferencing ¡for ¡Callee ¡ x ¡ x->foo(); foo’s ¡impl ¡ vptr ¡ foo ¡ vptr = *((FPTR**)x); f = *(vptr + 0); bar’s ¡impl ¡ fld ¡ bar ¡ f(x); vtable ¡ heap ¡obj ¡

  6. Vtable ¡Hijacking ¡ Arbitrary ¡ Code ¡ x ¡ x->foo(); fake ¡vtable ¡ foo’s ¡impl ¡ bad ¡ foo ¡ vptr = *((FPTR**)x); f = *(vptr + 0); bar’s ¡impl ¡ fld ¡ bar ¡ f(x); vtable ¡ heap ¡obj ¡

  7. Vtable ¡Hijacking ¡via ¡Use-­‑aSer-­‑Free ¡ Use ¡Corrupted ¡Data ¡for ¡x’s ¡vptr x ¡ x ¡ C *x = new C(); x->foo(); corrupted ¡ C::vptr ¡ buf[0] ¡ delete x; // forget x = NULL; y ¡ buf[1] ¡ buf[1] ¡ x’s ¡fld ¡ ... D *y = new D(); y->buf[0] = input(); candidate ¡for ¡ ¡ ... realloca3on ¡ x->foo();

  8. Vtable ¡Hijacking: ¡Real ¡Case ¡ Vtable ¡Hijacking ¡of ¡Chrome ¡via ¡Use-­‑aSer-­‑Free ¡ Pinkie ¡Pie’s ¡demonstra=on ¡at ¡Pwn2Own ¡ Used ¡to ¡trigger ¡ROP ¡for ¡sandbox ¡escaping ¡of ¡Chrome ¡ Found ¡in ¡IE, ¡Firefox, ¡ Chrome

  9. ¡ How ¡to ¡Prevent ¡Vtable ¡Hijacking? ¡ ¡ ¡With ¡Accuracy ¡& ¡Low ¡Overhead? ¡

  10. Code ¡InstrumentaNon ¡ C *x = ... Check(x); x->foo();

  11. Code ¡InstrumentaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); x->foo(); Valid(C) ¡= ¡{ ¡vptr ¡of ¡C ¡or ¡C’s ¡subclasses ¡} ¡ Obtained ¡by ¡class ¡hierarchy ¡analysis ¡(CHA) ¡

  12. Code ¡InstrumentaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); x->foo(); Simple ¡ImplementaNon ¡Can ¡Be ¡Slow ¡ Involved ¡data ¡structure ¡lookup/func=on ¡calls ¡

  13. Inlining ¡OpNmizaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); x->foo() x->foo(); vptr = *((FPTR**)x); f = *(vptr + 0); f(x);

  14. Inlining ¡OpNmizaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); // vptr = *((FPTR**)x); ASSERT(vptr ∈ Valid(C)); f = *(vptr + 0); f(x);

  15. Inlining ¡OpNmizaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); // vptr = *((FPTR**)x); // ASSERT(vptr ∈ Valid(C)); ASSERT(vptr ∈ {C::vptr, D::vptr}); f = *(vptr + 0); f(x); Say ¡that ¡C ¡has ¡only ¡one ¡subclass ¡D ¡ à ¡SpecializaNon ¡of ¡Checks à

  16. Inlining ¡OpNmizaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); // vptr = *((FPTR**)x); // ASSERT(vptr ∈ Valid(C)); // ASSERT(vptr ∈ {C::vptr, D::vptr}); f = *(vptr + 0); f(x); SAFE:

  17. Inlining ¡OpNmizaNon ¡ C *x = ... ASSERT(VPTR(x) ∈ Valid(C)); // vptr = *((FPTR**)x); // ASSERT(vptr ∈ Valid(C)); // ASSERT(vptr ∈ {C::vptr, D::vptr}); if (vptr == C::vptr) goto SAFE; if (vptr == D::vptr) goto SAFE; exit(-1); SAFE: f = *(vptr + 0); f(x);

  18. Inlining ¡OpNmizaNon ¡ C *x = ... How ¡to ¡Order ¡Inlined ¡Checked? ¡ ASSERT(VPTR(x) ∈ Valid(C)); // vptr = *((FPTR**)x); à ¡Profile-­‑guided ¡Inlining ¡ à // ASSERT(vptr ∈ Valid(C)); // ASSERT(vptr ∈ {C::vptr, D::vptr}); if (vptr == C::vptr) goto SAFE; if (vptr == D::vptr) goto SAFE; exit(-1); SAFE: f = *(vptr + 0); f(x);

  19. Method ¡Pointer ¡Checking ¡ C *x = ... vptr = *((FPTR**)x); x->foo() ASSERT(vptr ∈ {C::vptr, D::vptr}); f = *(vptr + 0); f(x)

  20. Method ¡Pointer ¡Checking ¡ C *x = ... vptr = *((FPTR**)x); // ASSERT(vptr ∈ {C::vptr, D::vptr}); f = *(vptr + 0); ASSERT(f ∈ ValidM(C,foo)); f(x) Checking ¡Callee ¡Before ¡It ¡Is ¡Called ¡ Provides ¡same ¡security ¡as ¡vtable ¡checking ¡

  21. Method ¡Pointer ¡Checking ¡ C *x = ... vptr = *((FPTR**)x); // ASSERT(vptr ∈ {C::vptr, D::vptr}); f = *(vptr + 0); // ASSERT(f ∈ ValidM(C,foo)); ASSERT(f ∈ {C::foo}); f(x) Say ¡that ¡C ¡has ¡one ¡subclass ¡D ¡ Save ¡Checks ¡for ¡Shared ¡Methods ¡ and ¡D ¡doesn’t ¡override ¡C::foo() ¡

  22. Member ¡Pointers ¡in ¡C++ ¡ A *x = ... // m: index into a vtable // x->*m can be any methods of A (x->*m)() Say ¡that ¡A ¡has ¡1000 ¡methods ¡ à ¡Up ¡to ¡1000 ¡method ¡ptr ¡checks! ¡ à Vtable ¡Checking ¡Can ¡Be ¡Faster ¡

  23. Method ¡Pointer ¡Checking ¡ Fewer ¡Checks ¡for ¡Usual ¡Virtual ¡Calls ¡ ¡ More ¡Checks ¡for ¡Member ¡Pointer ¡Calls ¡

  24. Hybrid ¡Checking ¡ Method ¡Checking ¡for ¡Usual ¡Virtual ¡Calls ¡ ¡ Vtable ¡Checking ¡for ¡Member ¡Pointer ¡Calls ¡

  25. Tamper ¡Resistance ¡ Inserted ¡Checks ¡in ¡Read-­‑Only ¡Memory ¡ ¡ Checking ¡Data ¡in ¡Read-­‑Only ¡Memory ¡

  26. Performance: ¡Benchmark ¡ Chromium ¡Browser ¡ Realis=c ¡: ¡≈ ¡3 ¡millions ¡of ¡C++/C ¡LOC ¡ Popular ¡target ¡of ¡vtable ¡hijacking ¡ ¡ Running ¡On ¡JS, ¡HTML5 ¡Benchmark ¡

  27. Performance ¡ UnopNmized ¡(Avg: ¡23%) ¡ 35 ¡ RunNme ¡Overhead(%) ¡ 30 ¡ 25 ¡ 20 ¡ 15 ¡ 10 ¡ 5 ¡ 0 ¡ JS ¡ HTML ¡

  28. Performance ¡ Profile-­‑Guided ¡Inlining ¡(Avg: ¡6%) ¡ 35 ¡ 35 ¡ RunNme ¡Overhead(%) ¡ RunNme ¡Overhead(%) ¡ 30 ¡ 30 ¡ 25 ¡ 25 ¡ 20 ¡ 20 ¡ 15 ¡ 15 ¡ 10 ¡ 10 ¡ 5 ¡ 5 ¡ 0 ¡ 0 ¡ JS ¡ JS ¡ HTML ¡ HTML ¡

  29. Performance ¡ Inlined ¡Method ¡Ptr ¡Checking ¡(3%) ¡ 35 ¡ 35 ¡ 35 ¡ RunNme ¡Overhead(%) ¡ RunNme ¡Overhead(%) ¡ RunNme ¡Overhead(%) ¡ 30 ¡ 30 ¡ 30 ¡ 25 ¡ 25 ¡ 25 ¡ 20 ¡ 20 ¡ 20 ¡ 15 ¡ 15 ¡ 15 ¡ 10 ¡ 10 ¡ 10 ¡ 5 ¡ 5 ¡ 5 ¡ 0 ¡ 0 ¡ 0 ¡ JS ¡ JS ¡ JS ¡ HTML ¡ HTML ¡ HTML ¡

  30. Performance ¡ Hybrid ¡Checking ¡(Avg: ¡2%) ¡ 35 ¡ RunNme ¡Overhead(%) ¡ 30 ¡ 25 ¡ 20 ¡ 15 ¡ 10 ¡ 5 ¡ 0 ¡ JS ¡ HTML ¡

  31. Code ¡Size ¡Overhead ¡ 7% ¡Code ¡Size ¡Increase ¡ 8.3 ¡MB ¡out ¡of ¡119 ¡MB ¡ Checking ¡Data ¡+ ¡Inlined ¡Checks ¡

  32. Future ¡Work ¡ Separate ¡CompilaNon ¡ Link-­‑=me ¡CHA ¡/ ¡inlining ¡ ¡ Dynamic ¡Link ¡Library ¡ Run=me ¡update ¡of ¡checking ¡data ¡

  33. Summary ¡ Vtable ¡Hijacking ¡ O\en ¡happening ¡in ¡web ¡browsers ¡ Compiler-­‑based ¡Approach ¡ Code ¡Instrumenta=on ¡/ ¡sta=c ¡Analysis ¡ RealisNc ¡Overhead ¡ Careful ¡compiler ¡op=miza=ons ¡

  34. Thank ¡you! ¡ ¡ hLp://goto.ucsd.edu/safedispatch ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend