Bugtraq mailing list archives

Exim 4.66 in conjunction with spamd Overflow issues


From: calcite () setec org
Date: 13 May 2007 05:18:59 -0000

Exim in conjuction with spamd messup 
        By calcite () setec org 

"Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to 
the Internet. It is freely available under the terms of the GNU General Public Licence. In style it is similar to Smail 
3, but its facilities are more general. There is a great deal of flexibility in the way mail can be routed, and there 
are extensive facilities for checking incoming mail. Exim can be installed in place of sendmail, although the 
configuration of exim is quite different to that of sendmail. "

There are bugs in exim "spam.c" source file for handling communication with apaches spamd daemon to help filter spam 
messages.

----Exim 4.66 Source spam.c--------
.......
int spamd_report_offset;
..................  
uschar spamd_version[8];

------------ The messup------------
  if( sscanf(CS spamd_buffer,"SPAMD/%s 0 EX_OK\r\nContent-length: %*u\r\n\r\n%lf/%lf\r\n%n",
             spamd_version,&spamd_score,&spamd_threshold,&spamd_report_offset) != 3 ) {

    /* try to fall back to pre-2.50 spamd output */
    if( sscanf(CS spamd_buffer,"SPAMD/%s 0 EX_OK\r\nSpam: %*s ; %lf / %lf\r\n\r\n%n",
               spamd_version,&spamd_score,&spamd_threshold,&spamd_report_offset) != 3 ) {
      log_write(0, LOG_MAIN|LOG_PANIC,
         "spam acl condition: cannot parse spamd output");
      return DEFER;
    };
  };
-----------------------------

due to the inproper usage of sscanf() without limiting the input with %Xs, it is possible to overflow spamd_version. 

---------BUFFER INDEX MESSUP----------------

because the author did not perform any sanitation checks on spamd_report_offset.
........
  p = &spamd_buffer[spamd_report_offset];
.......

Its used as a buffer index, a int greater than  32600

...  uschar spamd_buffer[32600];...

would cause pointer p to point jump out of the allocated buffer and into some other memory region in the stack , either 
segfaulting right away depending on the layout of the stack or corupting it later on. 

EXPLOITATION: 

Exploiting this bug would require social engineering and a fake spamd server. Obviously you will need to get an 
administrator to add your fake server to exim config.

Solution :

Run spamd locally or only add trusted spamd servers to your config ( have legitimate credentials).
Refferences----

http://www.exim.org/
http://spamassassin.apache.org/full/3.0.x/dist/spamd/PROTOCOL
http://spamassassin.apache.org/



Current thread: