Error in Linux Filesystemen Endangers Postfix

Aug 14, 2008

Wietse Venema, the developer of Postfix, points in an advisory to a security problem in connection with the Linux and Solaris filesystems. As more recent versions of these operating systems no longer comply with the POSIX standard for links, local attackers may be able to attach files to other users' Postfix mailboxes.

The problem exists for all newer Linux and Solaris variants according to Venema, but not on BSD derivatives, AIX, Mac OS X, HP-UX, and other systems that either keep to the POSIX or X/Open standards.

Affected systems create hard links which in turn point to symlinks, not as hard links, but by creating a symbolic link without notifying the user of the fact. A local attacker can exploit this to attach data files for which the owner has not assigned write privileges, for example, the Postfix server mailbox.

Suse's Sebastian Krahmer discovered this behavior. It can be demonstrated on current Linux distributions (for example, Ubuntu 8.04 and Opensuse 11) with just a few steps:

$ PATH=/bin:/usr/bin:$PATH
$ mkdir test
$ cd test
$ touch src
$ ln -s src dst1
$ ln dst1 dst2
$ ls -l

Systems affected by the vulnerability create two symlinks in the directory despite entering Ln without the "-s" option:

$ ls -l
lrwxrwxrwx 2 user users 3 Mmm dd hh:mm dst1 -> src
lrwxrwxrwx 2 user users 3 Mmm dd hh:mm dst2 -> src
-rw-r--r-- 1 user users 0 Mmm dd hh:mm src

It would be correct, and POSIX-compliant to create a genuine hard link, says Venema:

$ ls -l
lrwxrwxrwx 2 user users 3 Mmm dd hh:mm dst1 -> src
-rw-r--r-- 2 user users 0 Mmm dd hh:mm dst2
-rw-r--r-- 1 user users 0 Mmm dd hh:mm src

In the case of the Postfix mail server, a local attacker could talk Postfix into attaching data to another user's file, including the mailbox, for example. If the server is running with root privileges, this might provide an attack vector for a local user independently of Postfix. If Postfix encounters a hard link on delivery, the mail server outputs an error message refuses to deliver; in contrast to this symlinks are permitted.

Users should thus apply the patch posted on the German Postfix page run by Patrick Koetter and Ralf Hildebrandt, and follow the instructions, especially if they use the Mailbox format with Local Delivery Agent, or Virtual Delivery Agent. Postfix mail servers running Maildir, or a local IMAP server like Cyrus or Dovecot, are not affected.

Venema uses a Perl script to ensure that the spooler directory is owned by root, and that each user already has a Mailbox file. As an alternative, mail server admins can patch the source code provided to their version of Postfix.

As a global countermeasure, which will work beyond the bounds of Postfix, Venema recommends preventing non-root users from creating hard links for other users' objects. This behavior is configurable on many systems.

Related content

  • Multithreaded Mail Carrier: Postfix 2.6.0

    Mail transfer agent (MTA) Postfix is now available in version 2.6.0. Managing multiple Postfix instances on a single host is now possible for the first time.

  • Free Software Awards for Creative Commons and Wietse Venema

    The Free Software Foundation (FSF) has announced the winners of its annual free software awards, with Richard Stallman as the presenter.

  • Charly's Column

    The Postfix Policyd plugin fights spam using techniques such as greylisting, source detection, volume measurements, blacklisting, and HELO rotation detection.

  • Greylisting with Postgrey

    Vendors continue to develop new defenses against spam, one of the Internet’s most notorious pests. In this article, we integrate Postgrey with the Postfix mail server for a greylisting and whitelisting solution.

  • Email Encryption with Zeyple

    IT specialists often rely on automatic notification for status messages and logfiles by email. A Python script named Zeyple uses GPG to protect potentially sensitive messages against unauthorized viewing.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More