Stack and Heap Overflows: Different Animals

By Larry Seltzer  |  Posted 2008-09-15 Print this article Print


Stack overflows and heap overflows are different animals. Heap overflows are much more subtle, but there are some dev tools for you to use. Microsoft's David LeBlanc developed SafeInt class, a replacement integer class for which operators have been overwritten to force safe handling. (I always thought operator overriding was one of the stupider features of C++; this is the first compelling application I've seen of it.) There's also an intsafe library for C development.

But even with such safeguards in place, things can go wrong. Want a good example of how wrong things can go? Consider this US Cert alert that talks about how C compiler optimizations can end up "optimizing away" code inserted to detect and prevent overflows. The alert was inspired by an actual problem in gcc, but any optimizing compiler should be inspected for this sort of problem. In fact, LeBlanc was concerned enough to check how SafeInt was handled. I'm not clear from his blog if he had a problem or not, but I think not.

People at Microsoft tell me that the vulnerabilities they're finding these days, especially on old code, are very obscure and difficult to exploit. It's true that the overall numbers and overall severity of vulnerabilities in Windows is way down from what it was in previous years. They never claimed that they could eliminate all vulnerabilities or even all overflows. These things will always be with us, and it's a testament to how complicated software is these days that it can't be completely secured.

Security Center Editor Larry Seltzer has worked in and written about the computer industry since 1983.

For insights on security coverage around the Web, take a look at Security Center Editor Larry Seltzer's blog Cheap Hack.

Larry Seltzer has been writing software for and English about computers ever since—,much to his own amazement—,he graduated from the University of Pennsylvania in 1983.

He was one of the authors of NPL and NPL-R, fourth-generation languages for microcomputers by the now-defunct DeskTop Software Corporation. (Larry is sad to find absolutely no hits on any of these +products on Google.) His work at Desktop Software included programming the UCSD p-System, a virtual machine-based operating system with portable binaries that pre-dated Java by more than 10 years.

For several years, he wrote corporate software for Mathematica Policy Research (they're still in business!) and Chase Econometrics (not so lucky) before being forcibly thrown into the consulting market. He bummed around the Philadelphia consulting and contract-programming scenes for a year or two before taking a job at NSTL (National Software Testing Labs) developing product tests and managing contract testing for the computer industry, governments and publication.

In 1991 Larry moved to Massachusetts to become Technical Director of PC Week Labs (now eWeek Labs). He moved within Ziff Davis to New York in 1994 to run testing at Windows Sources. In 1995, he became Technical Director for Internet product testing at PC Magazine and stayed there till 1998.

Since then, he has been writing for numerous other publications, including Fortune Small Business, Windows 2000 Magazine (now Windows and .NET Magazine), ZDNet and Sam Whitmore's Media Survey.

Submit a Comment

Loading Comments...
Manage your Newsletters: Login   Register My Newsletters

Rocket Fuel