-----BEGIN PGP SIGNED MESSAGE-----

===========================================================================
              AUSCERT External Security Bulletin Redistribution
                                      
                                      
                     ESB-98.016 -- KSR[T] Advisory #007
                    Buffer overflow in the filter program
                               30 January 1998

===========================================================================

KSR[T] has released the following advisory concerning a buffer overflow
vulnerability in the filter program which is part of the elm-2.4 package.
This vulnerability may allow local and remote users to run arbitrary
commands as the user running filter, and possibly gain additional privileges
that will allow the attacker to write to the mail spool directory.

The following security bulletin is provided as a service to AUSCERT's
members.  As AUSCERT did not write this document, AUSCERT has had no
control over its content.  As such, the decision to use any or all of this
information is the responsibility of each user or organisation, and should
be done so in accordance with site policies and procedures.

NOTE: This is only the original release of the security bulletin.  It will
not be updated when the original bulletin is.  If downloading at a later
date, it is recommended that the bulletin is retrieved from the original
authors to ensure that the information is still current.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/Information/advisories.html

If you believe that your system has been compromised, contact AUSCERT or your
representative in FIRST (Forum of Incident Response and Security Teams).

Internet Email: auscert@auscert.org.au
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AUSCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for emergencies.
Facsimile:      (07) 3365 7031


- --------------------------BEGIN INCLUDED TEXT--------------------

                                                         KSR[T] Advisory #007
                                                         Date:   Jan 29, 1998
                                                         ID #:   filt-bof-007

Operating System(s): Any UNIX system running elm/filter

Affected Program:    filter ( part of the elm-2.4 package )

Problem Description: This advisory covers two vulnerabilities in the
                     filter program.  The first is in the function
                     save_embedded_address(), filter will use a while()
                     loop to copy a 5120 byte into a 512 byte automatic
                     variable.  This is the From: or in the Reply-To:
                     line in an email message.

                     The second is in the function get_filter_rules(),
                     there is a stack overrun when the function blindly
                     strcpy()s the variable filterfile( which is obtained
                     via the command line parameter '-f' ), into an
                     automatic variable.

Compromise:          The first problem could potentially be exploited
                     remotely depending upon how the victim's
                     machine's Mail Transfer Agent handles From: or
                     Reply-To: headers that are larger than 512 bytes.
                     This would allow a remote attacker to run arbitrary
                     commands as the user running filter, and possibly
                     additional privileges that will allow the attacker
                     to write to the mail spool directory.

                     Both attacks can be performed locally, however they
                     will only increase privileges if filter is running
                     set-uid or set-gid (most notably Linux machines).
                     This could allow a local user to read other users'
                     mail spools and allows write access to the mail
                     spool directory.  The latter could potentially be
                     used to interfere with the mail subsystem.

Notes:               This was not a full audit on the elm2.4 package, or
                     filter for that matter.  At a glance, there appear
                     to be numerous security problems.

                     The filter included in elm-2.4ME+37 also appears to
                     be vulnerable to the "save_embedded_address()" attack,
                     but not to the "get_filter_rules()" attack.

                     Filter will not be a part of elm 2.5, and is
                     not supported in any way at this time.  It is the
                     Elm group's recommendation that filter not be used.

Patch/Fix:

- -*- Begin elm 2.4 filter patch -*-

diff -u filter/filter.c filter.new/filter.c
- --- filter/filter.c     Tue Feb  4 09:13:02 1997
+++ filter.new/filter.c Tue Feb  4 09:17:38 1997
@@ -429,7 +429,7 @@
        **/

        static int processed_a_reply_to = 0;
- -       char address[LONG_STRING];
+       char address[MAX_LINE_LEN + 1];
        register int i, j = 0;

        /** first let's extract the address from this line.. **/
diff -u filter/parse.c filter.new/parse.c
- --- filter/parse.c      Tue Feb  4 09:13:33 1997
+++ filter.new/parse.c  Tue Feb  4 09:17:38 1997
@@ -172,7 +172,8 @@
        struct condition_rec
             *cond, *newcond;

- -       strcpy(filename,filterfile);
+       memset(filename, 0x0, SLEN );
+       strncpy(filename,filterfile,( SLEN - 1 ));

        if ((fd = fopen(filename,"r")) == NULL) {
          if (outfd != NULL)

- -*- end elm 2.4 filter patch -*-
- -*- begin elm2.4+ME filter patch -*-

- --- filter/filter.c     Tue Feb  4 09:13:02 1997
+++ filter.new/filter.c Tue Feb  4 09:17:38 1997
@@ -429,7 +429,7 @@
        **/

        static int processed_a_reply_to = 0;
- -       char address[LONG_STRING];
+       char address[MAX_LINE_LEN + 1];
        register int i, j = 0;

        /** first let's extract the address from this line.. **/
- -*- end elm2.4+ME filter patch -*-

- --------------------------END INCLUDED TEXT--------------------


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: ftp://ftp.auscert.org.au/pub/auscert/AUSCERT_PGP.key

iQCVAwUBNNGkpyh9+71yA2DNAQGWBwP/WRm3pxVEKRfHEYoAHKGzdGyjN5yrRZsg
kM6N4yM6yiI3E65mwaN7H0U4P+YGjGX0Id/D3T1utY7qxBiuYZ6PjRWi3RV1zq4D
FfivV1hHufVUI0MriudWa+G4zNHPdsUfmm2Hmq2AQR0HWA2ZBaVIzsLzfIcujVfr
+qiLlE+Fdl8=
=i+sK
-----END PGP SIGNATURE-----