BUGTRAQ ID: 29517
CVE(CAN) ID: CVE-2008-2542
BigView是NASA开发的图形查看器,可在运行Linux的桌面PC上将图形拉伸和缩放到任意尺寸。
BigView在解析特制的PNM输入文件时存在栈溢出漏洞,攻击者可能利用此漏洞通过诱使用户处理恶意文件控制用户系统。
以下是Ppm/ppm.C文件中的漏洞代码。这里getline()函数从文件将数据读取到缓冲区:
/-----------
418 static void getline(int fin, char* lineBuf, int len)
419 {
420 bool done=false;
421 int index=0;
422 lineBuf[index]=’ ';
423 while(! done){
424 lineBuf[index] = getOneChar(fin);
425 if( lineBuf[index]==10 ) {
426 lineBuf[index]=0;
427 done=true;
428 }
429 ++index;
430 }
431 lineBuf[index]=0;
432 }
函数要求了目标缓冲区的长度,但没有内部使用。在PPM::ppmHeader()函数中使用了上述函数来读取PPM文件的头:
/-----------
56 PPM::ppmHeader(string filename, PPM::Format* format,
57 int* cpp, int* bpc,
58 int* sizeX, int* sizeY,
59 int* imageOffset)
60 {
61 std::ostringstream err;
62 char magic[3],lineBuf[512],junk;
63 int res,max;
.
.
.
115 while( junk == ‘#’ ){
116 getline(fin,lineBuf,512);
117 cout << "Comment:"<<lineBuf<<":"<<endl;
118 junk = getOneChar(fin);
119 }
栈上所分配的lineBuf缓冲区大小为512字节,如果PPM头中包含有大于512字节的行的话,就会触发栈溢出,导致拒绝服务或执行任意指令。
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
<a href=“http://opensource.arc.nasa.gov/project/bigview/” target=“_blank”>http://opensource.arc.nasa.gov/project/bigview/</a>
http://www.coresecurity.com/?action=item&id=2304