Re: Stack growth direction to thwart buffer overflow attacks

From: Barry Margolin (barry.margolin_at_level3.com)
Date: 08/14/03


Date: Thu, 14 Aug 2003 19:24:00 GMT

In article <bhgmd8$psp$1@pegasus.csx.cam.ac.uk>,
Nick Maclaren <nmm1@cus.cam.ac.uk> wrote:
>You cannot produce corruption from outside unless there is a failure
>of the input checking, whether the program uses strncpy, strcpy or
>a for-loop. In none of those is the checking fully automatic, and
>therefore there is scope for human error.

Nothing is perfect, but some things are better than others.

Using routines that automatically check for overflow reduces the likelihood
of bugs, because it's much easier to provide the correct buffer length than
it is to write your own overflow checking.

Consider a function like gets(). Unless you have direct control over the
contents of standard input, it's virtually impossible to prevent buffer
overflow. By contrast fgets() gives you the opportunity to provide the
buffer length; the only way to mess up is to give the wrong length.

Most buffer overflows can essentially be traced to lazy programming.
There's two solutions to lazy programming: get rid of all the lazy
programmers, or make it easier for them to program safely (so they can
remain lazy and achieve better results). In an ideal world the first
solution would be used, but we don't live in that world. We have to make
do with the programmers available, so the second solution should help.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


Relevant Pages