oss-sec mailing list archives

Re: Untrusted fs and invalid filenames


From: Steve Grubb <sgrubb () redhat com>
Date: Sun, 13 Mar 2011 14:55:44 -0400

On Saturday, March 12, 2011 12:03:45 pm Vasiliy Kulikov wrote:
While POSIX restricts the character set used in filenames, some Linux
filesystems (at least ext2) permit reserved filenames ".", ".." and
filenames with "/" inside.  I have a crafted flash drive with ext2 that
has such files:

I can confirm that ext3/4, xfs, cramfs, and reiserfs also allow these kinds of names. 
I'm sure that with some patience, there are more.


Guess what does "rm" with such filenames :-)

and tar

 
What I suggest is something like "-o untrusted" option to mount.  This
would mean that the system considers the input from such fs as a malicious
input.  Such mounted fs would try to consider the data on disk as
untrusted and to be as robust as possible, e.g. check against
"/"-filenames, against corrupted fs structures, etc.  I'd be happy to
hear opinions about the usefulness of this feature.

Something else I was noticing is that fsck does not also enforce the correct naming 
constraints. Maybe what can be done is fix fsck and force it to scan the file system 
before making it accessible.

-Steve


Current thread: