Preventing Use-after-free with Dangling Pointers Nullification
Byoungyoung Lee, Chengyu Song, Yeongjin Jang Tielei Wang, Taesoo Kim, Long Lu, Wenke Lee
Georgia Institute of Technology Stony Brook University
Preventing Use-after-free with Dangling Pointers Nullification - - PowerPoint PPT Presentation
Preventing Use-after-free with Dangling Pointers Nullification Byoungyoung Lee , Chengyu Song, Yeongjin Jang Tielei Wang, Taesoo Kim, Long Lu, Wenke Lee Georgia Institute of Technology Stony Brook University Emerging Threat: Use-after-free
Georgia Institute of Technology Stony Brook University
2
Software Vulnerability Exploitation Trends, Microsoft, 2013
2
Software Vulnerability Exploitation Trends, Microsoft, 2013
2
Software Vulnerability Exploitation Trends, Microsoft, 2013
3
Use-after-free Stack Overflow Heap Overflow Security-Critical Security-High
13 582 12 107 The number of reported vulnerabilities in Chrome (2011-2013)
3
Use-after-free Stack Overflow Heap Overflow Security-Critical Security-High
13 582 12 107 The number of reported vulnerabilities in Chrome (2011-2013)
– A pointer points to a freed memory region
– May lead to arbitrary code executions – so called use-after-free
4 Preventing Use-after-free with Dangling Pointers Nullification
class Doc : public Element { // … Element *child; }; class Body : public Element { // … Element *child; }; Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign();
5 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
Allocate objects
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
Propagate pointers Allocate objects
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
Propagate pointers Allocate objects
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
Free an object Propagate pointers Allocate objects
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
freed Free an object Propagate pointers Allocate objects
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
freed Free an object Propagate pointers Allocate objects a dangling pointer
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
freed Use a dangling pointer Free an object Propagate pointers Allocate objects a dangling pointer
6 Preventing Use-after-free with Dangling Pointers Nullification
*doc *body Doc Body Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); *child *child
freed Use a dangling pointer Free an object Propagate pointers Allocate objects a dangling pointer
6 Preventing Use-after-free with Dangling Pointers Nullification
Doc *doc = new Doc(); Body *body = new Body(); Div *div = new Div(); doc->child = body; body->child = div; delete body; if (doc->child) doc->child->getAlign(); Doc *doc *body Body *child *child
7 Preventing Use-after-free with Dangling Pointers Nullification
Doc *doc = new Doc(); Body *body = new Body(); Div *div = new Div(); doc->child = body; body->child = div; delete body; if (doc->child) doc->child->getAlign(); Body *body = new Body(); Doc *doc = new Doc(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); Doc *doc *body Body *child *child
7 Preventing Use-after-free with Dangling Pointers Nullification
Doc *doc = new Doc(); Body *body = new Body(); Div *div = new Div(); doc->child = body; body->child = div; delete body; if (doc->child) doc->child->getAlign(); Body *body = new Body(); Doc *doc = new Doc(); doc->child = body; delete body; if (doc->child) doc->child->getAlign(); Doc *doc *body Body *child *child
Reconstructing object relationships is challenging Static analysis Modules are disconnected and scattered Difficult to serialize execution orders Dynamic analysis Tracing pointer semantics is non-trivial
7 Preventing Use-after-free with Dangling Pointers Nullification
– (sometimes) even surviving from use-after-free
– Immediately eliminate security impacts of use-after-free
– Protect popular apps including web browsers
8 Preventing Use-after-free with Dangling Pointers Nullification
– Intercept allocations/deallocations – Instrument pointer propagations
– A value in dangling pointers has no semantics – Dereferencing nullified pointers will turn into safe-null dereference
9 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain Shadow Object Tree
10 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain Shadow Object Tree
Doc *doc = new Doc();
10 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain Shadow Object Tree
Doc *doc = new Doc();
Insert shadow obj:
10 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain Shadow Object Tree
delete body; Doc *doc = new Doc();
Insert shadow obj:
10 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain Shadow Object Tree
delete body; Doc *doc = new Doc();
Insert shadow obj:
Remove shadow obj:
10 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
doc->child = body;
*doc *body Doc Body *child
11 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
doc->child = body; doc->child = body; trace(&doc->child, body);
*doc *body Doc Body *child
11 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
Shadow obj. of Doc back fwd back fwd Shadow obj. of Body
doc->child = body; doc->child = body; trace(&doc->child, body);
*doc *body Doc Body *child
11 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
Shadow obj. of Doc back fwd back fwd Shadow obj. of Body
doc->child = body; doc->child = body; trace(&doc->child, body);
*doc *body Doc Body *child
Forward
11 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
Shadow obj. of Doc back fwd back fwd Shadow obj. of Body
doc->child = body; doc->child = body; trace(&doc->child, body);
*doc *body Doc Body *child
Backward Forward
11 Preventing Use-after-free with Dangling Pointers Nullification
– Maintain backward/forward pointer trees for a shadow obj.
Shadow obj. of Doc back fwd back fwd Shadow obj. of Body
doc->child = body; doc->child = body; trace(&doc->child, body);
*doc *body Doc Body *child
Backward Forward
11 Preventing Use-after-free with Dangling Pointers Nullification
– All backward pointers of Body are dangling pointers – Dangling pointers have no semantics – Immediately eliminate dangling pointers
safe-null dereference.
*doc Freed *body Doc Body *child
12 Preventing Use-after-free with Dangling Pointers Nullification
– All backward pointers of Body are dangling pointers – Dangling pointers have no semantics – Immediately eliminate dangling pointers
safe-null dereference.
*doc Freed *body Doc Body *child
12 Preventing Use-after-free with Dangling Pointers Nullification
– Instrumentation: LLVM pass, +389 LoC – Runtime: compiler-rt, +3,955 LoC
– SPEC CPU 2006: one extra compiler and linker flag – Chromium: +27 LoC to .gyp build configuration file
13 Preventing Use-after-free with Dangling Pointers Nullification
– JavaScript benchmarks
– Rendering benchmarks
– A page loading time for the Alexa top 100 websites
Preventing Use-after-free with Dangling Pointers Nullification 14
– Use-after-free prevention for end-users – Debugging use-after-free vulnerability – Backend new use-after-free vulnerability finding
Preventing Use-after-free with Dangling Pointers Nullification 15
16 Preventing Use-after-free with Dangling Pointers Nullification
– Hardened using DangNull
– Testing use-after-free exploit (PoC)
WebCore::RenderBlock::determineStartPosition
17 Preventing Use-after-free with Dangling Pointers Nullification
Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; delete body; if (doc->child) doc->child->getAlign();
Use a dangling pointer Free an object Propagate pointers Allocate objects if (doc->child) doc->child->getAlign(); delete body; Doc *doc = new Doc(); Body *body = new Body(); doc->child = body; trace(&doc->child, body);
18 Preventing Use-after-free with Dangling Pointers Nullification
– Use-after-free happens iif a dangling pointer is used.
– A pointer points to the freed memory region – No data semantics
– Never dereferenced dangling pointers
– Dereferenced dangling pointers
19 Preventing Use-after-free with Dangling Pointers Nullification
20
Software Vulnerability Exploitation Trends, Microsoft, 2013
20
Software Vulnerability Exploitation Trends, Microsoft, 2013