On Tue, Oct 27, 2009 at 08:09:57PM +0300, Dan Yefimov wrote: || On 27.10.2009 14:04, Vincent Zweije wrote: || > After chmodding the directory to 0700, *first* || >check the link count, *then* chmod the file to 0666: || > || > User1 creates file with permissions 0644 || > User2 opens file for read access on file descriptor 4 || > User1 chmod's directory to 0700 || > User1 verifies no hard links to file || || Here's a window, during which User2 is able to create a hardlink || and that will remain unnoticed by User1. There's no way to perform || link check and conditionally do chmod in an atomic manner. User2 cannot create a hard link on the file any more now because it requires search access on the directory, and that has been revoked by chmod 0700 on the directory. || > User1 chmod's file to 0666 || > User2 can not open the file for read or write access || > User2 can not write to file descriptor 4 || > User2 _can_ write to /proc/$$/fd/4 However, as has been pointed out elsewhere in this thread, openat() will at this point allow User2 to open the file for writing, provided that he has a open file descriptor on the directory, opened with O_SEARCH. This is a valid but different attack from the race above. Ciao. Vincent. -- Vincent Zweije <zweije@xxxxxxxxx> | "If you're flamed in a group you <http://www.xs4all.nl/~zweije/> | don't read, does anybody get burnt?" [Xhost should be taken out and shot] | -- Paul Tomblin on a.s.r.
Attachment:
signature.asc
Description: Digital signature