Tuesday, 29 October 2013

How your compiler may be compromising application security

Researchers at MIT develop a tool to identify code that your compiler may inadvertently remove, creating vulnerabilities

Compilers: can’t live with ‘em, can’t live without ‘em - at least not if you write code for a living. Compilers are great at taking your hand crafted human-readable program, translating it into machine code and, in the process, optimizing it so it runs as efficiently as possible. Sometimes, though, as new research from MIT points out, in their zeal to optimize your code, compilers can go too far and remove code that they shouldn’t, which can make the system or application more vulnerable.

Four researchers in MIT’s Computer Science and Artificial Intelligence Laboratory, in a paper which is to be presented next week at the ACM Symposium on Operating Systems Principles, looked at the problem of optimization-unstable code, which is code that gets removed by a compiler because it includes undefined behavior. Undefined behavior is code which can behave unpredictably, such as dividing by zero, null pointer dereferencing and buffer overflows. Unlike other code, compiler writers are free to deal undefined behavior however they wish. In some cases, they choose to eliminate it completely, which can lead to vulnerabilities if the code in question contains security checks.

The MIT researchers studied a dozen common C/C++ compilers to see how they dealt with undefined code. They found that, over time, compilers are becoming more aggressive in how they deal with such code, more often simply removing it, even at default or low levels of optimization. Since C/C++ is fairly liberal about allowing undefined behavior, it is more susceptible to subtle bugs and security threats as a result of unstable code.

No comments:

Post a Comment