安全研究

安全漏洞
VideoLAN VLC媒体播放器MP4 Demuxer远程代码执行漏洞

发布日期:2008-02-26
更新日期:2008-02-28

受影响系统:
VideoLAN VLC Media Player <= 0.8.6d
不受影响系统:
VideoLAN VLC Media Player 0.8.6e
描述:
BUGTRAQ  ID: 28007
CVE(CAN) ID: CVE-2008-0984

VLC Media Player是一款免费的媒体播放器。

VLC媒体播放器的MPEG-4文件格式解析器(MP4 demuxer)在解析特制的MP4输入文件时存在任意内存覆盖漏洞,远程攻击者可能利用此漏洞控制用户系统。

以下demux/mp4/mp4.c文件中的漏洞代码使用用户提供的数据初始化堆数组的任意索引:

/-----------

910    if( ( !(p_co64 = MP4_BoxGet( p_demux_track->p_stbl, "stco" ) )&&
911          !(p_co64 = MP4_BoxGet( p_demux_track->p_stbl, "co64" ) ) )||
912        ( !(p_stsc = MP4_BoxGet( p_demux_track->p_stbl, "stsc" ) ) ))
913    {
914        return( VLC_EGENERIC );
915    }

.. ..

943    i_last = p_demux_track->i_chunk_count; /* last chunk proceded */
944    i_index = p_stsc->data.p_stsc->i_entry_count;
945    if( !i_index )
946    {
947        msg_Warn( p_demux, "cannot read chunk table or table empty" );
948        return( VLC_EGENERIC );
949    }
950
951    while( i_index-- )
952    {
953        for( i_chunk = p_stsc->data.p_stsc->i_first_chunk[i_index] - 1;
954             i_chunk < i_last; i_chunk++ )
955        {
956            p_demux_track->chunk[i_chunk].i_sample_description_index =
957
p_stsc->data.p_stsc->i_sample_description_index[i_index];
958            p_demux_track->chunk[i_chunk].i_sample_count =
959                    p_stsc->data.p_stsc->i_samples_per_chunk[i_index];
960        }
961        i_last = p_stsc->data.p_stsc->i_first_chunk[i_index] - 1;
962    }

- -----------/

在910/912行,MP4_BoxGet()函数从文件读取数据然后返回MP4_Box_t类型结构,i_chunk_count字段是用户可控的且未经正确的检查,之后在956和958行提供数组索引的语句中使用了这个值,填充堆缓冲区。由于未经任何检查便将用户控制的i_last用作了写操作的限制,因此可以向几乎任意内存地址写入任意值。

请注意在第一个迭代中i_last不是攻击者完全可控的,在961行获得了受控字段之一“p_stsc->data.p_stsc->i_first_chunk[i_index] - 1”。

这里所说的“几乎任意内存”是由于在每次赋值中用户都可以很大程度上控制i_sample_description_index和i_sample_count字段值,因此可以在每44个字节便写入8个连续的字节。

以下是结构定义:

/-----------

/* Contain all information about a chunk */
typedef struct
{
    uint64_t     i_offset; /* absolute position of this chunk in the file */
    uint32_t     i_sample_description_index; /* index for SampleEntry to
use */
    uint32_t     i_sample_count; /* how many samples in this chunk */
    uint32_t     i_sample_first; /* index of the first sample in this
chunk */

    /* now provide way to calculate pts, dts, and offset without to
        much memory and with fast acces */

    /* with this we can calculate dts/pts without waste memory */
    uint64_t     i_first_dts;
    uint32_t     *p_sample_count_dts;
    uint32_t     *p_sample_delta_dts;   /* dts delta */

    uint32_t     *p_sample_count_pts;
    int32_t      *p_sample_offset_pts;  /* pts-dts */

    /* TODO if needed add pts
        but quickly *add* support for edts and seeking */

} mp4_chunk_t;

- -----------/

这样攻击者就可以创建包含有特制stsc和co64元素的文件,导致几乎在任意地址写入任意值。

<*来源:Felipe Manzano
        Anibal Sacco
  
  链接:http://secunia.com/advisories/29122/
        http://www.videolan.org/security/sa0802.html
        http://marc.info/?l=bugtraq&m=120414915709212&w=2
        http://security.gentoo.org/glsa/glsa-200803-13.xml
*>

测试方法:

警 告

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

http://marc.info/?l=bugtraq&m=120414915709212&w=2

建议:
厂商补丁:

Gentoo
------
Gentoo已经为此发布了一个安全公告(GLSA-200803-13)以及相应补丁:
GLSA-200803-13:VLC: Multiple vulnerabilities
链接:http://security.gentoo.org/glsa/glsa-200803-13.xml

所有VLC用户都应升级到最新版本:

    # emerge --sync
    # emerge --ask --oneshot --verbose ">=media-video/vlc-0.8.6e"

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

http://www.videolan.org/patches/vlc-0.8.6-CORE-2008-0130.patch

浏览次数:3218
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障