xfocus logo xfocus title
首页 焦点原创 安全文摘 安全工具 安全漏洞 焦点项目 焦点论坛 关于我们
English Version

qpoper的fgets()函数存在安全漏洞


发布时间:2000-04-21
更新时间:2000-04-21
严重程度:
威胁程度:欺骗
错误类型:设计错误
利用方式:服务器模式

受影响系统
Misc
qpoper 3.0 fc2,qpoper 2.53
详细描述
qpoper允许恶意用户能生成自己的"From"MAIL头和文本,问题是在qpoper在从MAILBOX读数据时产生,qpoper 使用fgets()或mfgets()从MAILBOX读数据到定长为 1024字节的缓冲并在接受到'\n'或者读到1023字节时返回字符串。如果一个用户可以放置如下的文本 AAAA...AAA(string of 1023 symbols)\n From user Wed Dec 2 05:53 -0700 1992 在这种情况下,fgets()会返回三个字符串“ "AAAA...AAA(string of 1023)symbols", without '\n', "\n", "From user Wed Dec 2 05:53 -0700 1992" 在From之后的字符串的文本将被认为是MAIL HEADER和下个信息的正文,允许生成任意的HEADER和正文。另外,这个“内部”信息在任何软件会被作为文本来看待,所以将允许通过任何反病毒软件的过滤。

测试代码
见描述

解决方案
临时用于qpoper 3.0 fc2的补丁:
--- 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';

相关信息