Connecting Tech Pros Worldwide Forums | Help | Site Map

Assume program under constant attack

=?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?=
Guest
 
Posts: n/a
#1: Jan 19 '08

Usually someone writes a program and guarantees its behaviour so
long as people don't deliberately go and try to make it malfunction.

For instance, let's say we have a "Proceed" button on the dialog
box, but that this button is greyed out because the user hasn't entered
their username yet. Now let's say the user writes some code that sends a
message to the dialog box to enable the "Proceed" button even tho the
programmer didn't design the program to work correctly if "Proceed" is
clicked without there being a valid username.

So anyway, the user clicks "Proceed", the program crashes. The user
complains to the author and the author just replies "If you're gonna do
stuff like that then you can expect the thing to crash".

But what if you were writing programs which were expected to be
under constant attack? One such genre of programs would be a network
daemon. Let's say we've written a network daemon for FTP. On the other
side of the world, a hacker sends a dodgy FTP request which leads to a
buffer overflow. Presumably the hacker has the exectuable file himself
for this daemon and has observed what will happen when the buffer
overflow occurs, and tailors his input to arrange the machine code to do
exactly what he wants, e.g. call a function which will bring up a
command prompt shell for him.

I've read a bit about many of the exploits against Microsoft's
daemons, and a lot of them tend to be as a consequence of buffer
overrun. There was one such well-known buffer overrun in their file-
sharing daemon that allowed a hacker to bring up a command prompt shell
on their own machine and basically do whatever they wanted from there.

But anyway... back to programming...

I'm wondering what way people program the daemon functions which are
the interface to the outside world. Do they check every little detail of
the input scrutinously? Do they check string lengths and array indices
scrutinously? What kind of things do they watch out for? When writing
every line of code, do they be thinking in their head "Someone wants to
break this"?

--
Tomás Ó hÉilidhe

CBFalconer
Guest
 
Posts: n/a
#2: Jan 19 '08

re: Assume program under constant attack


Tomás Ó hÉilidhe wrote:
Quote:
>
.... snip ...
Quote:
>
I'm wondering what way people program the daemon functions which
are the interface to the outside world. Do they check every little
detail of the input scrutinously? Do they check string lengths and
array indices scrutinously? What kind of things do they watch out
for? When writing every line of code, do they be thinking in their
head "Someone wants to break this"?
If they don't check, someone or thing will break.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


--
Posted via a free Usenet account from http://www.teranews.com

Jack Klein
Guest
 
Posts: n/a
#3: Jan 20 '08

re: Assume program under constant attack


On Sat, 19 Jan 2008 11:43:21 GMT, "Tomás Ó hÉilidhe" <toe@lavabit.com>
wrote in comp.lang.c:

....absolutely nothing at all about the C language.

I'd suggest you look for a group where this would be topical. Perhaps
news:comp.programming.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
ediebur@rcn.com
Guest
 
Posts: n/a
#4: Jan 20 '08

re: Assume program under constant attack


On Jan 19, 6:43*am, "Tomás Ó hÉilidhe" <t...@lavabit.comwrote:
Quote:
* * Usually someone writes a program and guarantees its behaviour so
long as people don't deliberately go and try to make it malfunction.
>
* * For instance, let's say we have a "Proceed" button on the dialog
box, but that this button is greyed out because the user hasn't entered
their username yet. Now let's say the user writes some code that sends a
message to the dialog box to enable the "Proceed" button even tho the
programmer didn't design the program to work correctly if "Proceed" is
clicked without there being a valid username.
>
* * So anyway, the user clicks "Proceed", the program crashes. The user
complains to the author and the author just replies "If you're gonna do
stuff like that then you can expect the thing to crash".
>
* * But what if you were writing programs which were expected to be
under constant attack? One such genre of programs would be a network
daemon. Let's say we've written a network daemon for FTP. On the other
side of the world, a hacker sends a dodgy FTP request which leads to a
buffer overflow. Presumably the hacker has the exectuable file himself
for this daemon and has observed what will happen when the buffer
overflow occurs, and tailors his input to arrange the machine code to do
exactly what he wants, e.g. call a function which will bring up a
command prompt shell for him.
>
* * I've read a bit about many of the exploits against Microsoft's
daemons, and a lot of them tend to be as a consequence of buffer
overrun. There was one such well-known buffer overrun in their file-
sharing daemon that allowed a hacker to bring up a command prompt shell
on their own machine and basically do whatever they wanted from there.
>
* * But anyway... back to programming...
>
* * I'm wondering what way people program the daemon functions which are
the interface to the outside world. Do they check every little detail of
the input scrutinously? Do they check string lengths and array indices
scrutinously? What kind of things do they watch out for? When writing
every line of code, do they be thinking in their head "Someone wants to
break this"?
>
--
Tomás Ó hÉilidhe
Check everything and, at least thru Beta make sure every error
condition is reported, I once had to according to strict NSA code
constraints we weren't allowed to use recursion--there was a check at
the entry and exit of each function to insure that the function had
only been entered and exited once.That being said, this is for a
different group
JimS
Guest
 
Posts: n/a
#5: Jan 20 '08

re: Assume program under constant attack


On Sat, 19 Jan 2008 08:47:32 -0500, CBFalconer <cbfalconer@yahoo.com>
wrote:
Quote:
>Tomás Ó hÉilidhe wrote:
Quote:
>When writing every line of code, do they be thinking in their
head "Someone wants to break this"?
Yes.

Jim
=?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?=
Guest
 
Posts: n/a
#6: Jan 20 '08

re: Assume program under constant attack


Jack Klein:
Quote:
On Sat, 19 Jan 2008 11:43:21 GMT, "Tomás Ó hÉilidhe" <toe@lavabit.com>
wrote in comp.lang.c:
>
...absolutely nothing at all about the C language.


Never written a C program?


--
Tomás Ó hÉilidhe
Randy Howard
Guest
 
Posts: n/a
#7: Jan 20 '08

re: Assume program under constant attack


On Sat, 19 Jan 2008 05:43:21 -0600, Tomás Ó hÉilidhe wrote
(in article <Xns9A2A773F3746Ctoelavabitcom@194.125.133.14>):
Quote:
I'm wondering what way people program the daemon functions which are
the interface to the outside world. Do they check every little detail of
the input scrutinously? Do they check string lengths and array indices
scrutinously? What kind of things do they watch out for? When writing
every line of code, do they be thinking in their head "Someone wants to
break this"?
Pretty much, they either do, or they get burned. There is a good book
that gives some insight into some of this, sort of from the "black hat"
perspective.

It's called "The Shellcoder's Handbook". If you aren't upon on the
slang, you might think that has something to do with shell scripting.
Not true at all. See if your bookstore has a copy and take a peek and
see if it's what you're looking for.



--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw





Closed Thread