January 26, 2011
The origin of Unix file delete permissions

Unix file permissions fall into three basic categories, read, write and execute. Which one do you think controls file deletion? It’s probably write, right? Well, let’s test it:

$ touch foo; chmod -w foo
$ ls -l foo
-r-------- 1 user group 0 2011-01-24 12:16 foo
$ rm foo
$ ls foo
ls: cannot access foo: No such file or directory

That’s weird, it looks like I successfully deleted that file. Maybe it’s governed by user/group ownership.

$ touch foo; sudo chown root:root foo
$ ls -l foo
-rw------- 1 root root 0 2011-01-24 12:18 foo
$ rm foo
$ ls foo
ls: cannot access foo: No such file or directory

I just deleted a file owned by root. WTF?

It turns out, Unix file deletion (and creation) is controlled by write access to the parent directory. Let’s demonstrate quickly:

$ mkdir test; touch test/foo
$ chmod -w test
$ rm test/foo
rm: test/foo: Permission denied

You see, each Unix file has a dedicated datastructure that stores metadata called an inode. While inodes store permissions, access/modification timestamps and other useful info, they do not track file location or name. Instead, directories map file names to inodes. The name of an inode is derived from its location. When we delete a file with the rm command, we are merely removing a directory entry. Hence, we only need write permissions to the directory in question.

You can even link to an inode from multiple directory locations with the ln command. These references are called hard links and are counted by the inode. The inode is reclaimed and the disk storage freed only when the reference count reaches zero. So not all rm operations will result in the underlying file being destroyed, which is yet another reason for file deletion being controlled by the parent directory.

12:24pm  |   URL: http://tmblr.co/Zn_4by2lOCTj
  
Filed under: unix files security 
October 23, 2010
Secure delete with rm on OS X

I discovered this gem in the rm man page on OS X the other day:

-P  Overwrite regular files before deleting them.  Files are
    overwritten three times, first with the byte pattern 0xff,
    then 0x00, and then 0xff again, before they are deleted.

So there you go rm -P will securely delete a file from your disk with minimum hassle (i.e. without having to through the Thrash folder). This might be one of those goodies OS X inherited from BSD. On Linux you have to use something like shred to achieve the same thing.

Addendum: santry on the HN Thread points out the same thing can done via the srm command. Several people also noted that secure delete interacts unpredictably with modern file systems. jrockway points out that full disk encryption should be used in place of secure delete for this reason.

9:02pm  |   URL: http://tmblr.co/Zn_4by1Ia1s9
  
Filed under: cli rm os x security 
June 1, 2007
Audit logs for computer security monitoring

Summer ‘05 with Ben Kuperman

During an undergraduate research fellowship at Swarthmore College I worked with Professor Kuperman on expanding a preliminary system written for Sun Solaris. We first ported it over to Debian Linux. Afterwards, I redesigned and reimplemented the log recording mechanism with easily synchronizable log entry commit semantics, and wrote a highly modular log reader/processor from scratch.

I wrote and presented a poster on this project for Sigma Xi September ‘05.

Download (PDF’s): abstract and summary or poster

5:53pm  |   URL: http://tmblr.co/Zn_4by9TdKI
Filed under: academic security 
Liked posts on Tumblr: More liked posts »