Static Analysis Framework for Detecting Use-After-Free Bugs in C++

Vlad-Alexandru Teodorescu
Dorel Lucanu

Pointers are a powerful, but dangerous feature provided by the C and C++ program- ming languages, and incorrect use of pointers is a common source of bugs and secu- rity vulnerabilities. Making secure software is crucial, as vulnerabilities exploited by malicious actors not only lead to monetary losses, but possibly loss of human lives. Fixing these vulnerabilities is costly if they are found at the end of development, and the cost will be even higher if found after deployment. That is why it is desirable to find the bugs as early in the development process as possible. We propose a frame- work that can statically find use-after-free bugs at compile-time and report the errors to the users. It works by tracking the lifetime of objects and memory locations point- ers might point to and, using this information, a possibly invalid dereferencing of a pointer can be detected. The framework was tested on over 100 handwritten small tests, as well as 5 real-world projects, and has shown good results detecting errors, while at the same time highlighting some scenarios where false positive reports may occur. Based on the results, it was concluded that our framework achieved its goals, as it is able to detect multiple patterns of use-after-free bugs, and correctly report the errors to the programmer.

In Mircea Marin and Laurenţiu Leuştean: Proceedings Eighth Symposium on Working Formal Methods (FROM 2024), Timişoara, Romania, September 16-18, Electronic Proceedings in Theoretical Computer Science 410, pp. 99–115.
Published: 31st October 2024.

ArXived at: https://dx.doi.org/10.4204/EPTCS.410.7 bibtex PDF
References in reconstructed bibtex, XML and HTML format (approximated).
Comments and questions to: eptcs@eptcs.org
For website issues: webmaster@eptcs.org