Type Casting Verification: Stopping an Emerging Attack Vector
Many applications such as the Chrome and Firefox browsers are largely implemented in C+ for its performance and modularity. Type casting, which converts one type of an object to another, plays an essential role in enabling polymorphism in C+ because it allows a program to utilize certain general or specific implementations in the class hierarchies. However, if not correctly used, it may return unsafe and incorrectly casted values, leading to so called bad casting or type confusion vulnerabilities. Since a bad casted pointer violates a programmer's intended pointer semantics and enables an attacker to corrupt memory, bad casting has critical security implications similar to those of other memory corruption vulnerabilities. Despite the increasing number of bad casting vulnerabilities, the bad casting detection problem has not been addressed by the security community. In this paper, we present CAVER, a runtime bad casting detection tool. It performs program instrumentation at compile time and uses a new runtime type tracing mechanism the type hierarchy table to overcome the limitation of existing approaches and efficiently verify type casting dynamically. In particular, CAVER can be easily and automatically adopted to target applications, achieves broader detection coverage, and incurs reasonable runtime overhead. We have applied CAVER to large scale software including Chrome and Firefox browsers, and discovered 11 previously unknown security vulnerabilities: nine in GNU libstdc+ and two in Firefox, all of which have been confirmed and subsequently fixed by vendors. Our evaluation showed that CAVER imposes up to 7.6% and 64.6% overhead for performance intensive benchmarks on the Chromium and Firefox browsers, respectively.
USENIX Security Symposium