From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10952f,b69d377feb5a8a2 X-Google-Attributes: gid10952f,public X-Google-Thread: 10872d,d4c1f7c0fe672a4 X-Google-Attributes: gid10872d,public X-Google-Thread: 1164f8,d4c1f7c0fe672a4 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1070f0,d4c1f7c0fe672a4 X-Google-Attributes: gid1070f0,public X-Google-Thread: 1020c6,d4c1f7c0fe672a4 X-Google-Attributes: gid1020c6,public X-Google-Thread: fcda7,d4c1f7c0fe672a4 X-Google-Attributes: gidfcda7,public From: peter@baileynm.com (Peter da Silva) Subject: Yet Another Ultimate TMP-cleaner algorithm! Re: Different UNIX pro's and con's. Date: 1998/09/22 Message-ID: <6u88qm$t5u@web.nmti.com>#1/1 X-Deja-AN: 393641833 References: <35F71814.1E0B911C@iakom.com> <36069F96.E8127ED3@llnl.gov> <6u67ug$ccd@web.nmti.com> <36079B1B.2781@s054.aone.net.au> Organization: Bailey Network Management Newsgroups: comp.unix.admin,comp.sys.hp.hpux,comp.sys.sgi.admin,comp.sys.sun.admin,comp.sys.dec,comp.security.unix In article <36079B1B.2781@s054.aone.net.au>, Mark & Suzanne (gcs might work) wrote: > The solution is to pin the directory path in /tmp by changing >owner down the path to root:daemon or nobody:nobody then pass it again >that way the evil user will not get to change the directory to a link >they wont have the permission. That's not "the" solution, but it's certainly "a" solution. I think it'd be disruptive to running applications to have permissions change under them, so this adds yet another new kind of race condition, like the one Barry Margolin was concerned about. And it's one that's much more likely to trigger than his condition (where a file is deleted and replaced by another file of the same name in the window between the stat and the delete) but it's one that's much more likely to trigger. You can get the same security by using chdir, at the cost of a fork. And someone just posted some other code that avoids that fork (it's in the dirutils patches). Another solution that just occurred to me, that would avoid both race conditions, would be to rename the file and then check that the renamed file matched the original stat info... and rename it back if it didn't. There's still a race if a second program needed to access the file with that name in that time window. I judge that possibility sufficiently infinitesimal, especially if you combine it with the chdir trick. -- In hoc signo hack, Peter da Silva `-_-' "Milloin halasit viimeksi suttasi?" 'U` "Tell init(8) to lock-n-load, we're goin' zombie slaying!"