From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10952f,b69d377feb5a8a2,start X-Google-Attributes: gid10952f,public X-Google-Thread: 10872d,d4c1f7c0fe672a4 X-Google-Attributes: gid10872d,public X-Google-Thread: fcda7,d4c1f7c0fe672a4 X-Google-Attributes: gidfcda7,public X-Google-Thread: 1070f0,d4c1f7c0fe672a4 X-Google-Attributes: gid1070f0,public X-Google-Thread: 1020c6,d4c1f7c0fe672a4 X-Google-Attributes: gid1020c6,public X-Google-Thread: 1164f8,d4c1f7c0fe672a4 X-Google-Attributes: gid1164f8,public From: Jim Mellander Subject: Re: Different UNIX pro's and con's. Date: 1998/09/18 Message-ID: <3602C849.C70612C6@llnl.gov>#1/1 X-Deja-AN: 392525482 Content-Transfer-Encoding: 7bit References: <35F71814.1E0B911C@iakom.com> <35FB108D.F8FEFEBE@home.com> <6ti5t2$lbr$1@Venus.mcs.net> <35FDE10D.3380C3C1@home.com> <6tkqni$m41@web.nmti.com> <36019311.0@news.thefree.net> <6tsafu$4cr$1@camco.celestial.com> <360253C8.BB71898@home.com> <3602837C.5A77@lmt.ens-cachan.fr> Content-Type: text/plain; charset=us-ascii Organization: Lawrence Livermore National Laboratory Mime-Version: 1.0 Newsgroups: comp.unix.admin,comp.sys.hp.hpux,comp.sys.sgi.admin,comp.sys.sun.admin,comp.sys.dec,comp.security.unix Sanchez Philippe wrote: > > Jan-Frode Myklebust wrote: > > > > > > 'find' doesn't remove anything, it finds a real file called > > /tmp/foo/bar/passwd and then calls 'rm' to remove it. The security risk is > > that in the time between when 'find' finds and 'rm' removes, one can move > > away /tmp/foo/bar/bar, and create a link from /tmp/foo/bar to /etc. Then > > 'rm' will remove your /etc/passwd, or whatever file you wanted rm'd. > > > > -janfrode > > what is the time spent between 'find' finds and 'rm' removes ? A malicious user could run many jobs on a machine, thus loading it down, so that the time window is enlarged. This time delay (which may be small, or could be arbritarily large) allows the classic 'race condition' attack, one of which is described here. Any operation that accesses a file in a public directory is vulnerable to this type of attack. By creating a link, an abuser can perform the desired operation on any file as the user running the script. One basic principal of Unix security is to perform a task with as little permission as possible, to limit the damage in the event of compromise. Unfortunately, cleaning tmp directories requires root permission, since (in all modern Unices) /tmp , et al. are created with permissions 1777, which allows the directory to be publically read/write, but only allows the owner of a file (or root) to delete files from it. With cooperation between all users, you could change the perms of /tmp to 777, but any user could delete any other users temporary files. OTOH, the exploit described would be avoided in this case, by running the clean script as a non-root user. I would be interested in hearing from others about this topic. Without some method of ensuring that swapping won't take place between identification of the file to be deleted & the actual system call to delete the file, cleaning /tmp as root is inherantly insecure.