mailing list archives
mpack 1.6 allows eavesdropping on mails sent by other users
From: Sebastian Pipping <sebastian () pipping org>
Date: Sat, 31 Dec 2011 20:39:13 +0100
I think I have found something :-)
I recently stumbled upon a vulnerability in mpack 1.6 , a handy tool
to (1) wrap/unwrap files into/from MIME containers and (2) send files
via e-mail from the command line.
The vulnerability allows to eavesdrop on mails (or parts of them on
FreeBSD) sent by other any user on the system, including mails sent by
root. I guess "information disclosure" is the term.
To reduce the probability of telling something here that turns out wrong
later, I wrote a little tool called "mpacktrafficripper"  to
demonstrate and verify the exploit.
The FreeBSD version may allow additional damage, see details below.
So far I have superficially tested the latest editions of three major
distros. The results:
- Debian (1.6-7): vulnerable
- Gentoo (1.6-r1): vulnerable
- FreeBSD (1.6): vulnerable (part 2 and after if split,
Check  for my Git repo collecting the patches of all of these.
The original code of mpack 1.6 operates this way:
1) make a tempfile name using mktemp
2) open that file using open(..., O_CREAT|O_EXCL, 0644)
3) write to the file ^^^^
4) close it
5) re-open the file using fopen(..., "r")
6) read from it
7) close it
8) delete the file
So due to permissions 0644 everyone can read the file he opens the file
for reading before it's deleted. With an open file descriptor, there
should not even be a reason to hurry.
So a call like
# sudo mpack -s foo /etc/passwd fake () mail com
can be eavesdropped on in Debian and Gentoo.
When instructing mpack to split the file into several mails as in
# sudo mpack -s foo -m 1700 /etc/passwd fake () mail com
the tempfile names follow a pattern:
Now on FreeBSD the original use of mktemp followed by open with
O_CREAT|O_EXCL has been adjusted to this procedure, instead:
1) make a temp file using mkstemp and close returned file descriptor
2) open that file using open(..., O_CREAT|O_TRUNC, 0644)
3) to 8) as above
So mkstemp creates the first file (not open) which gets the permissions
right but all following files are created using open _without_ O_EXCL
and with 0644 permissions. So the second part and after can be
eavesdropped on FreeBSD, too. Additionally, there could be room for
symlink or hardlink attacks in that case, I have tested that.
A patch could be to change create files with 0600 permissions rather
than 0644 as done by . However, that approach affects creation of
non-temporary files too. In some cases, users may not want that
behaviour -- you tell me.
My attempts of contacting upstream failed. I wrote to
To: mpack-bugs () andrew cmu edu
CC: "John G. Myers" <jgm () cmu edu>,
"Christopher J. Newman" <chrisn () cmu edu>
and got this back:
----- The following addresses had permanent fatal errors -----
<jgm () cmu edu>
(reason: 553 5.3.0 <jgm+ () andrew cmu edu>... Unknown address.
niftytelnet () mac com
(reason: 550 5.1.1 unknown or illegal alias: niftytelnet () mac com)
(expanded from: <chrisn () cmu edu>)
----- Transcript of session follows -----
... while talking to mx1.andrew.cmu.edu.:
<<< 553 5.3.0 <jgm+ () andrew cmu edu>... Unknown address.
550 5.1.1 <jgm () cmu edu>... User unknown
<<< 503 5.0.0 Need RCPT (recipient)
... while talking to mx.mac.com.akadns.net.:
<<< 550 5.1.1 unknown or illegal alias: niftytelnet () mac com
550 5.1.1 niftytelnet () mac com User unknown
<<< 554 5.5.0 No recipients have been specified.
You tell me. Does this need a CVE number? With a dead upstream, how do
we best get this fixed in all distros ?
- mpack 1.6 allows eavesdropping on mails sent by other users Sebastian Pipping (Dec 31)