home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!uwm.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!ogicse!das-news.harvard.edu!husc-news.harvard.edu!husc8.harvard.edu!maziere1
- From: maziere1@husc8.harvard.edu (David Mazieres)
- Newsgroups: comp.unix.sys5.r4
- Subject: SUID shell script weirdness
- Message-ID: <1993Jan8.160453.19117@husc3.harvard.edu>
- Date: 8 Jan 93 21:04:52 GMT
- Article-I.D.: husc3.1993Jan8.160453.19117
- Distribution: world
- Organization: Harvard University Science Center
- Lines: 72
- Nntp-Posting-Host: husc8.harvard.edu
-
-
- I have been experiencing an extremely bizarre problem with SETUID shell
- scripts on SVR4 (Consensys), and would appreciate any advice.
-
- First, the kernel actually allows SETUID shell scripts (without a C
- wrapper, that is). Does this mean the "exec a symbolic link to a
- SUID shellscript + quickly change to a different file" bug has been
- fixed in SVR4? If not, how do I disable SUID shell scripts in the
- kernel. I checked the description of all the mtune parameters in
- the System Administrator's Guide, but couldn't find anything having
- to do with this.
-
- Second, and even more disturbing, the plain old "/bin/mkdir" (not
- SETUID) appears to be able to do things it is not supposed to be
- able to do. I am running with RSTCHOWN set to 1 in the kernel (i.e.
- BSD-style chown and chgrp restrictions). Now, I quote from the
- mkdir (2) man page:
-
- The directory's owner ID is set to the process's effective
- user ID. The directory's group ID is set to the process's
- effective group ID, or if the SETGID bit is set in the
- parent directory, then the group ID of the directory is
- inherited from the parent.
-
- And yet, observe the following behaviour:
-
- > id
- uid=100(dm) gid=100(oper)
- > ls -al sh
- -r-sr-xr-x 1 font oper 63992 Jan 8 12:55 sh
- > ./sh
- $ id
- uid=100(dm) gid=100(oper) euid=108(font)
- $ cd /tmp
- $ /bin/mkdir suid_bug
- $ ls -ald suid_bug
- drwxr-xr-x 2 dm oper 512 Jan 8 15:35 suid_bug
- $ /bin/rm -rf suid_bug
- rm: Unable to remove directory
- Permission denied
- $ /usr/local/gnubin/rmdir suid_bug
- /usr/local/gnubin/rmdir: suid_bug: Permission denied
- $ /bin/rmdir suid_bug
- $ /usr/local/gnubin/mkdir suid_bug
- $ ls -ald suid_bug
- drwxr-xr-x 2 font oper 512 Jan 8 15:36 suid_bug
- $ /bin/rmdir suid_bug
- rmdir: suid_bug: Search or write permission needed
- $ /bin/rm -rf suid_bug
- $ > exit
-
- Process shell finished
-
- That's right, "/bin/mkdir" and "/bin/rmdir" only seem to work with the
- real, rather than effective user id's. But with RSTCHOWN set to 1,
- those programs shouldn't even be allowed to create files with UID's
- other than the current EUID. I looked a the source for the GNU version
- of mkdir, and it just uses mkdir(2), which behaves as expected.
-
- So, what does the AT&T mkdir(1) use to make it's directories, and why?
- (I know it doesn't to a flat out seteuid(getuid()), because I still need
- write permission on the parent directory.) This is really annonying in
- SUID shell scripts that need to create temporary directories, as those
- scripts cannot create files in the directories they just created. Should
- I just use GNU mkdir, or is there some major security hole that I'm
- overlooking?
-
- Thanks for any help. Please reply via E-Mail, and I'll post a summary if
- the solution is anything non-trivial. (Please let me know explicitly if
- you would object to my quoting your reply in the follow-up article.)
-
- david (maziere1@husc.harvard.edu)
-