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 Software Vulnerability Exploitation Trends, Microsoft, 2013 2
Emerging Threat: Use-after-free Software Vulnerability Exploitation Trends, Microsoft, 2013 2
Emerging Threat: Use-after-free Software Vulnerability Exploitation Trends, Microsoft, 2013 2
Emerging Threat: Use-after-free 13 Security-Critical 582 Security-High 107 12 0 0 Use-after-free Stack Heap Overflow Overflow The number of reported vulnerabilities in Chrome (2011-2013) 3
Emerging Threat: Use-after-free 13 Security-Critical 582 Security-High 107 12 0 0 Use-after-free Stack Heap Overflow Overflow The number of reported vulnerabilities in Chrome (2011-2013) 3
Use-after-free • A dangling pointer – A pointer points to a freed memory region • Using a dangling pointer leads to undefined program states – May lead to arbitrary code executions – so called use-after-free Preventing Use-after-free with Dangling Pointers Nullification 4
Understanding Use-after-free class Doc : public Element { Doc *doc = new Doc(); // … Body *body = new Body(); Element *child; }; doc->child = body; class Body : public Element { delete body; // … Element *child; if (doc->child) }; doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 5
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child doc->child = body; Body delete body; *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; Body delete body; *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; Body delete body; *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; Body Free an object delete body; *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; Body Free an object delete body; freed *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; a dangling pointer Body Free an object delete body; freed *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; a dangling pointer Body Free an object delete body; freed *child *body Use a dangling pointer if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Understanding Use-after-free Allocate objects Doc Doc *doc = new Doc(); Body *body = new Body(); *doc *child Propagate pointers doc->child = body; a dangling pointer Body Free an object delete body; freed *child *body Use a dangling pointer if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 6
Why use-after-free is challenging Doc *doc Doc *doc = new Doc(); *child Body *body = new Body(); Div *div = new Div(); doc->child = body; Body body->child = div; delete body; *child *body if (doc->child) doc->child->getAlign(); Preventing Use-after-free with Dangling Pointers Nullification 7
Why use-after-free is challenging Doc Doc *doc = new Doc(); *doc Doc *doc = new Doc(); *child Body *body = new Body(); if (doc->child) Div *div = new Div(); doc->child->getAlign(); doc->child = body; Body body->child = div; doc->child = body; delete body; *child delete body; *body if (doc->child) doc->child->getAlign(); Body *body = new Body(); Preventing Use-after-free with Dangling Pointers Nullification 7
Why use-after-free is challenging Doc Doc *doc = new Doc(); *doc Doc *doc = new Doc(); *child Body *body = new Body(); if (doc->child) Div *div = new Div(); Reconstructing object relationships is challenging doc->child->getAlign(); doc->child = body; Body Static analysis body->child = div; doc->child = body; delete body; Modules are disconnected and scattered *child delete body; *body if (doc->child) Difficult to serialize execution orders doc->child->getAlign(); Body *body = new Body(); Dynamic analysis Tracing pointer semantics is non-trivial Preventing Use-after-free with Dangling Pointers Nullification 7
Contributions • Present DangNull , which detects use-after-free – (sometimes) even surviving from use-after-free • Stop sophisticated attacks – Immediately eliminate security impacts of use-after-free • Support large-scale software – Protect popular apps including web browsers Preventing Use-after-free with Dangling Pointers Nullification 8
Designs • Tracking Object Relationships – Intercept allocations/deallocations – Instrument pointer propagations • Nullify dangling pointers – A value in dangling pointers has no semantics – Dereferencing nullified pointers will turn into safe-null dereference Preventing Use-after-free with Dangling Pointers Nullification 9
Tracking Object Relationships • Intercept allocations/deallocations in runtime – Maintain Shadow Object Tree • Red-Black tree to efficiently keep object layout information • Node: (base address, size) pair Preventing Use-after-free with Dangling Pointers Nullification 10
Tracking Object Relationships • Intercept allocations/deallocations in runtime – Maintain Shadow Object Tree • Red-Black tree to efficiently keep object layout information • Node: (base address, size) pair Doc *doc = new Doc(); Preventing Use-after-free with Dangling Pointers Nullification 10
Tracking Object Relationships • Intercept allocations/deallocations in runtime – Maintain Shadow Object Tree • Red-Black tree to efficiently keep object layout information • Node: (base address, size) pair Doc *doc = new Doc(); Insert shadow obj: - Base address of allocation - Size of Doc Preventing Use-after-free with Dangling Pointers Nullification 10
Tracking Object Relationships • Intercept allocations/deallocations in runtime – Maintain Shadow Object Tree • Red-Black tree to efficiently keep object layout information • Node: (base address, size) pair Doc *doc = new Doc(); Insert shadow obj: - Base address of allocation - Size of Doc delete body; Preventing Use-after-free with Dangling Pointers Nullification 10
Tracking Object Relationships • Intercept allocations/deallocations in runtime – Maintain Shadow Object Tree • Red-Black tree to efficiently keep object layout information • Node: (base address, size) pair Doc *doc = new Doc(); Remove shadow obj : - Using base address (body) Insert shadow obj: - Base address of allocation - Size of Doc delete body; Preventing Use-after-free with Dangling Pointers Nullification 10
Tracking Object Relationships • Instrument pointer propagations – Maintain backward/forward pointer trees for a shadow obj. doc->child = body; Doc *doc *child Body *body Preventing Use-after-free with Dangling Pointers Nullification 11
Tracking Object Relationships • Instrument pointer propagations – Maintain backward/forward pointer trees for a shadow obj. doc->child = body; doc->child = body; trace(&doc->child, body); Doc *doc *child Body *body Preventing Use-after-free with Dangling Pointers Nullification 11
Tracking Object Relationships • Instrument pointer propagations – Maintain backward/forward pointer trees for a shadow obj. Shadow obj. of Doc doc->child = body; doc->child = body; back fwd trace(&doc->child, body); Doc *doc *child Shadow obj. of Body back fwd Body *body Preventing Use-after-free with Dangling Pointers Nullification 11
Tracking Object Relationships • Instrument pointer propagations – Maintain backward/forward pointer trees for a shadow obj. Shadow obj. of Doc doc->child = body; doc->child = body; back fwd trace(&doc->child, body); Forward Doc *doc *child Shadow obj. of Body back fwd Body *body Preventing Use-after-free with Dangling Pointers Nullification 11
Recommend
More recommend