setuid root / buffer overflows - stack smashing

setuid root / buffer overflows - stack smashing

Post by Luke Voge » Sat, 06 Jan 2001 22:12:05



I am currently trying to learn about buffer overflows/stack smashing.

I wrote a small c prog that could be easily overflowed, made it setuid
root, and then wrote an exploit for it. (with the aid of a tutorial).

Now I'm no expert programmer, but for me to gain root as easily as I
did, surprised me no end.  In fact it really stood me up straight!

I think it would be prudent for all sysadmins to seriously review any
and all suid programs they may have review them for safety.

Comments?

--
Regards
Luke
PLEASE NOTE: Spamgard (tm) installed.
----
"Normal people ... believe that if it ain't broke, don't fix it.
Engineers believe that if it ain't broke, it doesn't have enough
features ... yet." -- Scott Adams
----
http://www.bell-bird.com.au

----

 
 
 

setuid root / buffer overflows - stack smashing

Post by Tim Hayne » Sat, 06 Jan 2001 23:22:58



> I wrote a small c prog that could be easily overflowed, made it setuid
> root, and then wrote an exploit for it. (with the aid of a tutorial).

> Now I'm no expert programmer, but for me to gain root as easily as I did,
> surprised me no end. In fact it really stood me up straight!

<nod>.

Quote:> I think it would be prudent for all sysadmins to seriously review any and
> all suid programs they may have review them for safety.

> Comments?

There's probably a reason why Part N+1 of setting up a hopefully-secure
box is automating a task that finds all set[ug]id files and mails you a
list every night....!

(And has been since I wore nappies reading O'Reilly _Essential System
Administration_, if not before then.)

~Tim
--

And you watch the ripples flow                  |http://piglet.is.dreaming.org

 
 
 

setuid root / buffer overflows - stack smashing

Post by Michael Erskin » Sun, 07 Jan 2001 03:44:39


Shocking ain't it Luke...  :-)
-m-

> I am currently trying to learn about buffer overflows/stack smashing.

> I wrote a small c prog that could be easily overflowed, made it setuid
> root, and then wrote an exploit for it. (with the aid of a tutorial).

> Now I'm no expert programmer, but for me to gain root as easily as I
> did, surprised me no end.  In fact it really stood me up straight!

> I think it would be prudent for all sysadmins to seriously review any
> and all suid programs they may have review them for safety.

> Comments?

> --
> Regards
> Luke
> PLEASE NOTE: Spamgard (tm) installed.
> ----
> "Normal people ... believe that if it ain't broke, don't fix it.
> Engineers believe that if it ain't broke, it doesn't have enough
> features ... yet." -- Scott Adams
> ----
> http://www.bell-bird.com.au

> ----

 
 
 

setuid root / buffer overflows - stack smashing

Post by Davi » Sun, 07 Jan 2001 15:45:49



> > There's probably a reason why Part N+1 of setting up a hopefully-secure
> > box is automating a task that finds all set[ug]id files and mails you a
> > list every night....!

> Got a handy script you can share for this?

-------------------------------------
#!/bin/sh
#
# Lists SGID & SUID files
# and emails to postmaster.
#
# The "find command cat" line gets wraped in email.
#
(


 echo "Subject: Daily SGID & SUID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID files on the system include:"
echo
 find / -type f \( -perm -04000 -o -perm -02000 \) \
-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

----------------------------------------------

#!/bin/sh
#
# Lists SGID files
# and emails to postmaster.
#
(


 echo "Subject: Daily SGID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID files on the system include:"
echo
 find / -type f \( -perm -02000 \) \-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

---------------------------------------------

#!/bin/sh
#
# Lists SUID files
# and emails to postmaster.
#
(


 echo "Subject: Daily SGID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID files on the system include:"
echo
 find / -type f \( -perm -04000 \) \-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

-------------------------------

--
Confucius say: He who play in root, eventually kill tree.
Registered with the Linux Counter.  http://counter.li.org
ID # 123538
Completed more W/U's than 98.987% of seti users. +/- 0.01%

 
 
 

setuid root / buffer overflows - stack smashing

Post by Davi » Sun, 07 Jan 2001 15:57:15



> > There's probably a reason why Part N+1 of setting up a hopefully-secure
> > box is automating a task that finds all set[ug]id files and mails you a
> > list every night....!

> Got a handy script you can share for this?

-------------------------------------
#!/bin/sh
#
# Lists SGID & SUID files
# and emails to postmaster.
#
# The "find command cat" line gets wraped in email.
# you can remove the \ on the find line and move the
# cat line back to the end of the find line
#
(


 echo "Subject: Daily SGID & SUID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID & SUID files on the system include:"
echo
 find / -type f \( -perm -04000 -o -perm -02000 \) \
\-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

----------------------------------------------

#!/bin/sh
#
# Lists SGID files
# and emails to postmaster.
#
(


 echo "Subject: Daily SGID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID files on the system include:"
echo
 find / -type f \( -perm -02000 \) \-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

---------------------------------------------

#!/bin/sh
#
# Lists SUID files
# and emails to postmaster.
#
(


 echo "Subject: Daily SGID audit report"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
echo "List of SGID files on the system include:"
echo
 find / -type f \( -perm -04000 \) \-exec ls -lg {} \;| cat

 ) 2>&1 | /usr/lib/sendmail -t
exit 0

-------------------------------

--
Confucius say: He who play in root, eventually kill tree.
Registered with the Linux Counter.  http://counter.li.org
ID # 123538
Completed more W/U's than 98.987% of seti users. +/- 0.01%

 
 
 

setuid root / buffer overflows - stack smashing

Post by Davi » Sun, 07 Jan 2001 16:00:10


Scripts will also work with qmail without any changes.

--
Confucius say: He who play in root, eventually kill tree.
Registered with the Linux Counter.  http://counter.li.org
ID # 123538
Completed more W/U's than 98.987% of seti users. +/- 0.01%

 
 
 

setuid root / buffer overflows - stack smashing

Post by Michael Erskin » Mon, 08 Jan 2001 08:49:08



> Thus spake Tim Haynes about Life, the Universe, and,
>   Re: setuid root / buffer overflows - stack smashing:
> > There's probably a reason why Part N+1 of setting up a hopefully-secure
> > box is automating a task that finds all set[ug]id files and mails you a
> > list every night....!

> Got a handy script you can share for this?

> -Russ

> --
> Windows : DOS for the illiterate.

Tripwire also Kwang comes with tcpwrappers.  Tim will show you how to do
it with find, I expect.

-m-
--
The most secure OS will be the one you know best and know how to secure
the best.  A very large amount of security depends on the configuration
and knowing what needs to be changes is not always easy.
        Alan Coopersmith

 
 
 

setuid root / buffer overflows - stack smashing

Post by Tim Hayne » Mon, 08 Jan 2001 10:50:00


[snip]

Quote:> > Got a handy script you can share for this?

> Tripwire also Kwang comes with tcpwrappers. Tim will show you how to do
> it with find, I expect.

Well, I thought the other chap had done a reasonable job of it, but if
you're desperate...  I'd start from:
        find / -perm +ug+s -ls | mail -s 'setuid files' root
and work up ;8)

~Tim
--

West winds blow.                                |http://piglet.is.dreaming.org

 
 
 

setuid root / buffer overflows - stack smashing

Post by Luke Voge » Mon, 08 Jan 2001 19:46:11



> ---------------------------------------------

> #!/bin/sh
> #
> # Lists SUID files
> # and emails to postmaster.
> #
> (


>  echo "Subject: Daily SGID audit report"

minor error-------------^^^^

Quote:>  echo

>  PATH=/sbin:/usr/sbin:/bin:/usr/bin:
>  export PATH
> echo "List of SGID files on the system include:"

minor error-----^^^^

Quote:> echo
>  find / -type f \( -perm -04000 \) \-exec ls -lg {} \;| cat

>  ) 2>&1 | /usr/lib/sendmail -t
> exit 0

sorry to be pedantic :)

--
Regards
Luke
PLEASE NOTE: Spamgard (tm) installed.
----
"Normal people ... believe that if it ain't broke, don't fix it.
Engineers believe that if it ain't broke, it doesn't have enough
features ... yet." -- Scott Adams
----
http://www.bell-bird.com.au

----

 
 
 

setuid root / buffer overflows - stack smashing

Post by Michael Erskin » Wed, 10 Jan 2001 04:27:58



> > Tripwire also Kwang comes with tcpwrappers. Tim will show you how to do
> > it with find, I expect.

> Well, I thought the other chap had done a reasonable job of it, but if
> you're desperate...  I'd start from:
>         find / -perm +ug+s -ls | mail -s 'setuid files' root
> and work up ;8)

See there, ;).
--
You can fool some of the people all of the time and you can fool all of
the people some of the time but you can not fool all of the people all
of the time.   A. Lincoln
 
 
 

setuid root / buffer overflows - stack smashing

Post by Clifton T. Sharp Jr » Sun, 14 Jan 2001 09:30:50




> > Got a handy script you can share for this?

> -------------------------------------
> #!/bin/sh

I did this all the time until I found sxid; does anyone know of any
problems with sxid?

--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Cliff Sharp   |  Hate spam? Take the Boulder Pledge!                      |
|      WA9PDM     | http://www.zdnet.com/yil/content/mag/9612/ebert9612.html  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 
 
 

1. Giving up SetUID privs and Buffer Overflows

  I have quite a few programs that I have written or modified which setUID
on our system, particularly CGI scripts that need to modify user accounts.
I make a habit of going through them very carefully and making sure that
they give up all privileges that they do not need (with seteuid), then get
them back again when they are needed.  This way I only need to give really
close scrutiny to the small section of code where the process is privileged.

  However, with all of the buffer overflow attacks that have been going on,
I'm concerned that this isn't enough...Even in a nonpriviliged code section,
it seems to me that a clever attacker might be able to cause a program to
execute a seteuid(0) before executing their little nastiness...

  Anybody know whether this is possible?

  Thanks for any info,

------Scott.

2. vold, an Internet daemon...

3. executable stacks and buffer overflows?

4. iptables and pcmcia => device busy => no proper shutdown

5. Stack growing and buffer overflows

6. More Linux woes

7. Changing limit of open files

8. Buffer Overflows: Question about the internals of process creation and stack maintenence.

9. gets alternatives and stack smashing

10. Is the sshd in OpenBSD 2.7 vulnerable to stack-smashing?

11. double the buffer? - buffer overflows

12. StackGuard: Automatic Protection From Stack-smashing Attacks