Re: Stack growth direction to thwart buffer overflow attacks
From: Ken Hagan (K.Hagan_at_thermoteknix.co.uk)
Date: 08/14/03
- Previous message: Ken: "Re: Solution for botnets"
- In reply to: Douglas Siebert: "Re: Stack growth direction to thwart buffer overflow attacks"
- Next in thread: Nick Maclaren: "Re: Stack growth direction to thwart buffer overflow attacks"
- Reply: Nick Maclaren: "Re: Stack growth direction to thwart buffer overflow attacks"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 14 Aug 2003 09:54:01 +0100
Douglas Siebert wrote:
>
> I'd
> like to see it create hidden internal variables attached to every
> array whether global, automatic or created via malloc() that are
> checked
> when writing to that string, calls to e.g., sprintf and strcpy
> replaced
> with calls to snprintf and strncpy, including appropriate termination
> via SIGABRT or whatever when the buffer is exceeded, etc.
I don't think we need run-time support for this.
Simply removing sprintf, strcpy and friends from the headers allows
the compile time detection of *these* cases. The resulting compiler
errors are either trivial to fix or something that shouldn't be let
out of the door. (Why? Well, either you know size of the target
buffer, in which case that's what you write for the extra parameter,
or you don't in which case how do you know it won't overflow?)
Alternatively, the MS compiler has an extension that lets you mark
some functions as "deprecated". Deprecated functions generate a
warning which means the legacy code base still builds, but managers
can insist that the warning count falls over time. Since they've
added the feature to their own compiler, one presumes that MS are
already doing this.
For the wider problem of running off the ends of an array, PC-LINT
has an option that attempts to track buffer sizes and validate
pointer dereferences. (For problems where the array sizes are
actually available, it seems to work quite well in my experience.)
It is presumably trivial to generate a warning for the case where
that tracking cannot be done. Such warnings would direct managers
to precisely those areas of the system that couldn't be proven to
be free of overflows. Over time, they can insist that these are
dealt with.
I think the honest truth is that buffer overflows can be all but
eliminated from real life C and C++ programs but that we haven't
been hit by enough worms yet.
- Previous message: Ken: "Re: Solution for botnets"
- In reply to: Douglas Siebert: "Re: Stack growth direction to thwart buffer overflow attacks"
- Next in thread: Nick Maclaren: "Re: Stack growth direction to thwart buffer overflow attacks"
- Reply: Nick Maclaren: "Re: Stack growth direction to thwart buffer overflow attacks"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|