Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Vuln-Dev
[Top] [All Lists]

Exim 4.66 in conjunction with spamd Overflow issues

Subject: Exim 4.66 in conjunction with spamd Overflow issues
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/


<Prev in Thread] Current Thread [Next in Thread>