Users login

Create an account »


Users login

Home » Security Advisories» FreeBSD » Unauthorized mail reading via comsat

Unauthorized mail reading via comsat

The comsat daemon does not properly set privileges before attempting to read mail files for display on a user terminal.

  • Vendor: FreeBSD
  • Vendor ID: SA-96:13
  • Date: June 05, 1996


FreeBSD-SA-96:13 Security Advisory
FreeBSD, Inc.

Topic: unauthorized mail reading via comsat

Category: core
Module: comsat
Announced: 1996-06-05
Affects: All FreeBSD versions
Corrected: 2.1-stable and 2.2-current as of 1996-06-04
FreeBSD only: yes



I. Background

FreeBSD made an extension to the comsat daemon to support
e-mail in alternate locations. A bug was found in this
extension which allows an unprivileged local user to read
portions of other users' mail.

This problem is present in all source code and binary
distributions of FreeBSD released before 1996-06-03.

II. Problem Description

The comsat daemon does not properly set privileges before
attempting to read mail files for display on a user terminal.

III. Impact

The comsat daemon may be used to read portions of files
in /var/mail that would not normally be accessible to a
particular user. This ability is limited to the /var/mail
directory hierarchy.

This vulnerability can only be exploited by users with a valid
account on the local system.

IV. Workaround

One may simply disable the comsat daemon in /etc/inetd.conf.
This will disable asynchronous notification of received mail
(biff messages). This workaround will suffice for
all versions of FreeBSD affected by this problem.

As root, edit the file /etc/inetd.conf and change the line

comsat dgram udp wait root /usr/libexec/comsat comsat

to read

#comsat dgram udp wait root /usr/libexec/comsat comsat

and then reboot the system or restart the inetd daemon and kill
off any active comsat daemons.

V. Solution

The following patch fixes the permissions problem. It should
apply cleanly to all FreeBSD 2.x systems. It has not been tested
with FreeBSD 1.x but this change, if applied by hand, should work.

--- comsat.c Mon Jun 3 09:07:49 1996
+++ comsat.c Mon Jun 3 09:17:11 1996
@@ -73,7 +73,7 @@
time_t lastmsgtime;
int nutmp, uf;

-void jkfprintf __P((FILE *, char[], off_t));
+void jkfprintf __P((FILE *, char[], char[], off_t));
void mailfor __P((char *));
void notify __P((struct utmp *, char[], off_t, int));
void onalrm __P((int));
@@ -238,15 +238,16 @@
cr, name, (int)sizeof(hostname), hostname,
folder ? cr : "", folder ? "to " : "", folder ? file : "",
cr, cr);
- jkfprintf(tp, file, offset);
+ jkfprintf(tp, name, file, offset);

-jkfprintf(tp, name, offset)
+jkfprintf(tp, user, file, offset)
register FILE *tp;
- char name[];
+ char user[];
+ char file[];
off_t offset;
register char *cp, ch;
@@ -256,10 +257,10 @@
char line[BUFSIZ];

/* Set effective uid to user in case mail drop is on nfs */
- if ((p = getpwnam(name)) != NULL)
+ if ((p = getpwnam(user)) != NULL)
(void) setuid(p->pw_uid);

- if ((fi = fopen(name, "r")) == NULL)
+ if ((fi = fopen(file, "r")) == NULL)

(void)fseek(fi, offset, L_SET);

FreeBSD, Inc.

Web Site:
Confidential contacts: [email protected]
PGP Key:
Security notifications: [email protected]
Security public discussion: [email protected]

Notice: Any patches in this document may not apply cleanly due to
modifications caused by digital signature or mailer software.
Please reference the URL listed at the top of this document
for original copies of all patches if necessary.

Version: 2.6.2


Newsletter signup

Signup to our monthly newsletter and stay in touch with IT news!

Free E-books

We've got ebooks! But they're not online. :( Please give us a few days to bring downloads back.


Have something to say or just wanna drop us a line? Please keep this in mind: to spam, we reply with spam.

Contact us »