Re: security warning

Chris Wedgwood (chris@f00f.org)
Wed, 17 Dec 1997 14:34:55 +1300


Date: Tue, 16 Dec 1997 12:31:52 -0800 (PST)
From: Linus Torvalds <torvalds@transmeta.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
cc: Kevin Buhr <buhr@stat.wisc.edu>, linux-kernel@vger.rutgers.edu,
schoebel@informatik.uni-stuttgart.de
Subject: Re: security warning
In-Reply-To: <m0xi3gI-0005FsC@lightning.swansea.linux.org.uk>
Message-ID: <Pine.LNX.3.95.971216122857.23081A-100000@penguin.transmeta.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Orcpt: rfc822;linux-kernel@vger.rutgers.edu
Sender: owner-linux-kernel@vger.rutgers.edu

[...]

I think Linux currently allows following a symlink for just about
anything (mkdir(), link()) etc, which is partly just because it's so
easy to do with the new dentry scheme, and it is consistent. Most other
unixes seem to allow symlink following for some things (creat) but not
others (mkdir).

IMO the way linux does things at the moment is good, I even have a few
(poorly written?) scripts that depend upon this. I'm not sure if following
links for directory creation is a bad thing when we also do so for file
creation. Surely if one is bad, then the other only makes the problem
marginally worse?

As Alan said - fix the applications. Programs that create temporary files
should perhaps lstat them first? (Although lstat isn't posix...)

I checked with SunOS and Solaris (If its worth anything). The script I used
is below if anyone wants to try this elsewhere.

-------------------------------------

[me:3] caffeine:~$ cat symtest.sh
#!/bin/sh

mkdir test 2>/dev/null || exit 1

cd test
uname -a

ln -s dir1 dir0
mkdir dir0 2>/dev/null
rmdir dir1 2>/dev/null && (
echo "Directory creation follows sym-links"
) || (
echo "Directory creation does not follow sym-links"
)
rm -f dir0

ln -s file1 file0
touch file0
rm file1 2>/dev/null && (
echo "File creation follows sym-links"
) || (
echo "File creation does not follow sym-links"
)
rm -f file0

cd .. && rmdir test

-------------------------------------

Linux caffeine 2.1.72 #15 Thu Dec 11 17:05:52 NZDT 1997 i686
Directory creation follows sym-links
File creation follows sym-links

SunOS x 5.5.1 Generic sun4m sparc SUNW,SPARCstation-5
Directory creation does not follow sym-links
File creation follows sym-links

SunOS x 4.1.3_U1 2 sun4m
Directory creation does not follow sym-links
File creation follows sym-links

-Chris