never stop questioning

qpopper.fgets.txt

qpopper.fgets.txt
Posted Apr 27, 2000

fgets() is unsafely used in qpopper version 2.53.

tags | exploit
MD5 | d8c98f6f77bed4579d8a40dcbe530673

qpopper.fgets.txt

Change Mirror Download
Topic:                  unsafe fgets() using in qpopper

Software affected: qpopper 3.0 fc2, qpopper 2.53 and probably
others

Description: malicious user can remotely post message
with spoofed or incorrect headers (including
"Received:" one) and in some cases bypass
virus checking. This can be used for sending
trojans or to attack vulnerabilities in MUA.

Status: Vendor contacted, bug scheduled to be patched
in next release, FreeBSD port patched.

Background:

In most unix systems e-mail delivered to user is usually stored in his
mailbox, which has predefined format (so-called "unix mailbox" or
"berkley mailbox"). This mailbox holds messages in plain format
separated by empty line ("\n") and specially formed "From " header.
The pattern of the next message in mailbox is "\n\nForm ".

Then local mail programs (f.e. mail.local) delivers message to user's
mailbox it searches for this pattern and if message contains one
"From " will be commented out by '>' and additional '\n' will be
added to message if necessary. This assumes mailbox integrity and
protects from e-mail spoofing.

Problem description:

qpopper has vulnerability which allows for malicious user to generate
his own "From " with followed email headers and text. The problem is
in the way qpopper reads data from mailbox. Qpopper uses fgets() or
fgets()-like routine, mfgets(), which reads data from mailbox into the
fixed 1024 byte buffer and returns string in case either '\n'
character received or 1023 bytes read. Malicious user can put text
like (without leading spaces):

AAAA...AAA(string of 1023 symbols)\n
From user Wed Dec 2 05:53 -0700 1992

In this case fgets() will return 3 strings:
"AAAA...AAA(string of 1023)symbols", without '\n',
"\n",
"From user Wed Dec 2 05:53 -0700 1992"
and this will be recognized as a beginning of the new message in the
mailbox.

Text after "From " string will be recognized as a headers and text of
the next message, allowing to generate any headers and text.
Additionally, this "internal" messages will be treated by any software
as a plain text inside message, without any MIME attachments. This
allows to bypass virus checking in case antiviral tools scans only
attached files.

Possible temporary fix for qpopper 3.0 fc2 (not tested):

--- pop_dropcopy.c Sat Mar 18 02:31:11 2000
+++ pop_dropcopy.c Wed Apr 12 18:11:11 2000
@@ -205,6 +205,8 @@


int newline = 1;
+int isbreaked = 0;
+int wasbreaked = 0;

/*
* 0 for not a from line
@@ -229,6 +231,14 @@

/* If the previous line was not a newline then just return */
/* From message separators are preceeded by a newline */
+ if (isbreaked) {
+ wasbreaked = 1;
+ return ( 0 );
+ }
+ if (wasbreaked) {
+ wasbreaked = 0;
+ return ( 0 );
+ }
if ( *cp == '\n' ) {
newline = 1;
return ( 0 );
@@ -1593,9 +1603,13 @@
if( size <= 0 ) {
return NULL;
}
+ isbreaked = 1;
while( --size && ((c = getc(stream)) != EOF) ) {
if( (*p = (char)c) == '\0' ) *p = ' ';
- if( *p++ == '\n' ) break;
+ if( *p++ == '\n' ) {
+ isbreaked = 0;
+ break;
+ }
}
if( p == s ) return NULL;
*p = '\0';


Additional Info:

mail.local also uses fgets() for reading input message, but default
buffer size is 2048, so "From " will not be commented and problem can
be exploited. If another local mailer is used with same behavior and
buffer size 1024 or mailer splits strings of 1024 bytes this problem
couldn't be exploited.


http://www.security.nnov.ru
/\_/\
{ . . } |\
+--oQQo->{ ^ }<-----+ \
| 3APA3A U 3APA3A }
+-------------o66o--+ /
|/
You know my name - look up my number (The Beatles)

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close