🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.security.misc
8 messages
8 total messages Started by Patrik Fltstrm Thu, 05 Nov 1992 07:13
Re: Setuid script - is this unsecure?
#446
Author: Patrik Fltstrm
Date: Thu, 05 Nov 1992 07:13
28 lines
1730 bytes
In article <1992Nov5.030530.24039@zip.eecs.umich.edu> chiner@nova.gmi.edu writes:
>rickt@bnr.co.uk (Rick Tait) writes:
>: I recently installed these shell scripts on my machine (on which I am root),
>: and I'd like to know if I'm compromising it's security. Basically, they
>: just allow the users to mount/umount/eject the floppy disk (pcfs).
>
>:     /usr/etc/mount -t pcfs /dev/fd0 /pcfs
>                            ^-o nosuid
>: 
>and some other problems...  I'll point out, that all the mount commands
>need a -o nosuid...  otherwise, anyone who can get a root shell on a disk,
>can get root on your system...

Because he is mounting the floppy as a PC-filesystem and not a BSD
filesystem (-t pcfs), there is no need for the nosuid switch.

But IF you have mounted it as a BSD filesystem, you have needed
the nosuid switch and also a switch for nodev (do not accept
devices on this device) which you don't have in SunOS, well, not
in 4.1.3 at least. 

The switch nodev and nosuid is in BSD4.4 so I still hope that users
can be able to mount there own floppies in the future. You know, even
if backups are made every hour, they can fail, and it's very
comfortable for a user to at least be able to take care of his/her own
files.

       paf
Re: Setuid script - is this unsecure?
#509
Author: Amos Shapira
Date: Fri, 06 Nov 1992 10:25
45 lines
2337 bytes
In article <1992Nov5.071354.24042@kth.se> paf@cyklop.nada.kth.se (Patrik Fltstrm) writes:

   chiner@nova.gmi.edu writes:
   >(Rick Tait) writes:
   >: I recently installed these shell scripts on my machine (on which I am root),
   >: and I'd like to know if I'm compromising it's security. Basically, they
   >: just allow the users to mount/umount/eject the floppy disk (pcfs).
   >
   >:     /usr/etc/mount -t pcfs /dev/fd0 /pcfs
   >                            ^-o nosuid
   >:
   >and some other problems...  I'll point out, that all the mount commands
   >need a -o nosuid...  otherwise, anyone who can get a root shell on a disk,
   >can get root on your system...

I didn't see the entire thread from the beginning, but it seems to me you are
all missing the main problem with suid shell scripts, which is the bug in the
shell itself and the flexibility it offers with environment variables.

I can become root on your system using your /bin/sh script without even having
to know what it does or what programmes it calls.

suid shell script is a no-no. period.

If you want an suid programme write it in C (even if it does dumb things) and
don't use the system(3) and popen(3) functions because they call /bin/sh and
hance it's almost like writing a shell script.  I bet people can find some more
rules-of-thumb but these are the very basic ones you should follow.

A general suggestion for a programme which will do what you want would be:

main (ac, av)
	int ac;
	char **av;
{
	exec ("/usr/etc/mount", av);
}

and have the object of this C programme suid root.

Hope this helps,
--
--Amos Shapira (Jumper Extraordinaire)
C.S. System Group, Hebrew University, Jerusalem, Israel
amoss@cs.huji.ac.il
Re: Setuid script - is this unsecure?
#510
Author: Jurgen Botz
Date: Wed, 11 Nov 1992 04:04
14 lines
1216 bytes
In article <AMOSS.92Nov6102549@shuldig.cs.huji.ac.il> amoss@shuldig.cs.huji.ac.il (Amos Shapira) writes:
>If you want an suid programme write it in C (even if it does dumb things) and
>don't use the system(3) and popen(3) functions because they call /bin/sh and
>hance it's almost like writing a shell script.  I bet people can find some more
>rules-of-thumb but these are the very basic ones you should follow.

Or better yet, use Perl, which won't allow you to perform "unsafe" operations
when running setuid.

--
Jurgen Botz                  |   Internet: JBotz@mtholyoke.edu
Academic Systems Consultant  |     Bitnet: JBotz@mhc.bitnet
Mount Holyoke College        |      Voice: (US) 413-538-2375 (daytime)
South Hadley, MA, USA        | Snail Mail: J. Botz, 01075-0629
Re: Setuid script - is this unsecure?
#511
Author: Brian Fitzgerald
Date: Wed, 11 Nov 1992 04:59
32 lines
1308 bytes
Amos Shapira writes:
>A general suggestion for a programme which will do what you want would be:
>
>main (ac, av)
>	int ac;
>	char **av;
>{
>	exec ("/usr/etc/mount", av);
>}
>
>and have the object of this C programme suid root.

IMHO this is an extremely poor counterexample, since it lets the user
mount anything, with any options.  That presents its own security
risk.

Usually these special purpose mount wrappers are written with constant
arguments for exec.  For example, someone (I don't recall who) posted a
while ago:

char *env[]={"PATH=/usr/etc",(char*)0};
char *argv[]={"/usr/etc/mount","/pcfs",(char*)0};

main()
{
        setruid(getuid());
        execve("/usr/etc/mount",argv,env);
}

and a similar program for a cdrom, and two more programs for unmounting.

Brian
Re: Setuid script - is this unsecure? (perl)
#515
Author: matthew aardvarkious
Date: Wed, 11 Nov 1992 09:47
17 lines
1384 bytes
jbotz@mtholyoke.edu (Jurgen Botz) writes:

>In article <AMOSS.92Nov6102549@shuldig.cs.huji.ac.il> amoss@shuldig.cs.huji.ac.il (Amos Shapira) writes:
>>If you want an suid programme write it in C (even if it does dumb things) and
>>don't use the system(3) and popen(3) functions because they call /bin/sh and
>>hance it's almost like writing a shell script.  I bet people can find some more
>>rules-of-thumb but these are the very basic ones you should follow.

>Or better yet, use Perl, which won't allow you to perform "unsafe" operations
>when running setuid.

2 points!
--
These are my personal views and do not reflect those of Melbourne University.
Anything I may say that may be deemed offensive and/or damaging should NOT
be redirected to administration, as they have had nothing to do with it. 
Please direct any/all complaints/enquiries to thecure@ee.mu.oz.au
Re: Setuid script - is this unsecure?
#763
Author: J{rvinen Hannu-Matti
Date: Thu, 19 Nov 1992 13:47
27 lines
1415 bytes
In article <AMOSS.92Nov6102549@shuldig.cs.huji.ac.il> amoss@shuldig.cs.huji.ac.il (Amos Shapira) writes:
>A general suggestion for a programme which will do what you want would be:
>
>main (ac, av)
>	int ac;
>	char **av;
>{
>	exec ("/usr/etc/mount", av);
>}
>
>and have the object of this C programme suid root.

Equivalent would be that you let anybody execute mount (i.e., set
mount suid), which is not reasonable. Also you have to deny suid
programs on the floppy, and ensure that there does not exist special
devices on the floppy.

I've written a set of programs (fdmkfs, fdmount, and fdumount) to give
users access to the floppy. They are available by anonymous ftp on
site cs.tut.fi (130.230.4.2), file pub/src/tut/floppy.shar. Use on
your own risk.

-- 
-----
Hannu-Matti Jarvinen, hmj@cs.tut.fi
Opinions of tut != opinions of mine, and vice versa.
TTKK on samaa mielt{ kanssani siit{, ett{ en edusta sen mielipidett{.
Re: Setuid script - is this unsecure?
#804
Author: Jan Wortelboer
Date: Fri, 20 Nov 1992 13:50
34 lines
1682 bytes
hmj@cs.tut.fi (J{rvinen Hannu-Matti) writes:

>In article <AMOSS.92Nov6102549@shuldig.cs.huji.ac.il> amoss@shuldig.cs.huji.ac.il (Amos Shapira) writes:
>>A general suggestion for a programme which will do what you want would be:
>>
>>main (ac, av)
>>	int ac;
>>	char **av;
>>{
>>	exec ("/usr/etc/mount", av);
>>}
>>
>>and have the object of this C programme suid root.

>Equivalent would be that you let anybody execute mount (i.e., set
>mount suid), which is not reasonable. Also you have to deny suid
>programs on the floppy, and ensure that there does not exist special
>devices on the floppy.

>I've written a set of programs (fdmkfs, fdmount, and fdumount) to give
>users access to the floppy. They are available by anonymous ftp on
>site cs.tut.fi (130.230.4.2), file pub/src/tut/floppy.shar. Use on
>your own risk.

Everybode executing mount isn't indeed a good idea:
How about mount /dev/fd /etc


Jan.
-- 
Jan Wortelboer,  University of Amsterdam
                 Computer Science Department  Email: janw@fwi.uva.nl
Unix             Kruislaan 403 Kamer F003     Phone: +31 20 525 7501
systems manager  1098 SJ AMSTERDAM            Fax  : +31 20 525 7490
Re: Setuid script - is this unsecure?
#844
Author: Steven Leikeim
Date: Mon, 23 Nov 1992 16:52
34 lines
2160 bytes
In article <1eg5tmINN9eh@cs.tut.fi> hmj@cs.tut.fi (J{rvinen Hannu-Matti) writes:
>Equivalent would be that you let anybody execute mount (i.e., set
>mount suid), which is not reasonable. Also you have to deny suid
>programs on the floppy, and ensure that there does not exist special
>devices on the floppy.
>
>I've written a set of programs (fdmkfs, fdmount, and fdumount) to give
>users access to the floppy. They are available by anonymous ftp on
>site cs.tut.fi (130.230.4.2), file pub/src/tut/floppy.shar. Use on
>your own risk.
>
>-- 
>-----
>Hannu-Matti Jarvinen, hmj@cs.tut.fi
>Opinions of tut != opinions of mine, and vice versa.
>TTKK on samaa mielt{ kanssani siit{, ett{ en edusta sen mielipidett{.

Another set of programs which I have used is mntdisk. This was posted in
comp.sources.unix volume 22, and is available from many ftp sites. It includes
support for diskettes UNIX and PC formats (at least on Suns), CD's and
Erasable Optical Disks. It attempts to make sure that you do not mount
diskettes with device files and mounts with the nosuid option to prevent
misuse of diskettes.

As shipped it lets you mount the diskette wherever you like. However, it
is easy to modify to only allow mounts on specific directories if this is
necessary.


-- 
Steven Leikeim                        |
University of Calgary                 |   There are lies, damned lies,
Department of Electrical Engineering  |        and statistics.
Internet: steven@enel.ucalgary.ca     |
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads