3月10日,Adobe发布了一个紧急频外(out-of-band, OOB)更新来修补一个被攻击利用的零日(zero-day)漏洞。此漏洞被记录为CVE-2016-1010。为了分析此漏洞,我检测了Flash Player的一个较早的版本(Flash32_19_0_0_185.ocx file on Windows 7)来对该漏洞进行根本原因分析(Root Cause Analysis, RCA)。
根本原因分析
在ActionScript 3.0中,BitmapData 类中有一个公共函数 copyPixels定义如下:
public function copyPixels(sourceBitmapData:BitmapData, sourceRect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, mergeAlpha:Boolean = false):void
当Flash运行这个函数时,它会使用sourceRect(一个长方形函数),定义如下所示:
public function Rectangle(x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0)
这是为了创建一个叫做BitmapData的临时数据结构。在Flash 19.0.0.185中,这可能会有如下结构:
0x08: height // the height of the Bitmap
0x0c: width // the weight of the Bitmap
0x20: pBitmapData // the pointer to the Bitmap Data array
0x24: bytesize // the byte size of each line in Bitmap, byt
为了计算字节大小,Flash使用shl操作,如下图所示。如果width>= 0x40000000, “shl ecx,2” 就会触发一个整数溢出。下一进程的函数使用bytesize*height 来计算分配给pBitmapData的内存大小。如果bytesize溢出,被分配的内存就会低于所需要的大小。
攻击者可以利用此溢出来读或写任意的内存地址,就能有效的执行任意代码。
图1:修复之前的函数
伪代码如下所示:
pBitmapData->width = width;
pBitmapData->height = height;
pBitmapData-> bytesize = 4*width; //trigger integer overflow when width>0x40000000
int allocSize = pBitmapData->bytesize*height;
allocMemory = allocMemory( allocSize);
pBitmapData-> pBitmapData = allocMemory;
修复漏洞
Flash Player 21.0.0.182中的该漏洞已经被修复了,Adobe是怎么做到的?
原先的shl操作被imul替代了。另外, (edx,eax) 指令记录了width*4的值。如果edx的值非零,它就代表溢出的width。如果这一点可以知道,就可以修改代码解决这个问题了。
图2:修复后的函数
整数溢出漏洞在Flash Player中很常见。在APSB16-08 中,3个整数溢出漏洞(CVE-2016-0963, CVE-2016-0993 和CVE-2016-1010) 已经修补了。在编译过程中加入整数漏洞检测功能可以减少溢出漏洞的数量。
对于终端用户,我们强烈建议持续进行Adobe Flash Player的更新。通过默认设置就能进行自动更新,虽然一些用户可能更习惯于手动更新安装最新的版本。
我们的终端产品中有拥有Browser Exploit Prevention功能的,例如Trend Micro™ Security, Smart Protection Suites, 还有 Worry-Free Business Security ,只要用户访问装有浏览器漏洞利用防护插件的URL。Browser Exploit Prevention还能保护防止目标浏览器或相关的插件上的漏洞被利用。
使用脚本分析器引擎的沙盒(Sandbox)是Trend Micro™ Deep Discovery的一部分,它能够不断地检测这些威胁,并且不许要任何引擎或模式的更新。 Deep Security 和 Vulnerability Protection 能通过以下的DPI规则保护用户的系统免受威胁:
· 1007519 – Adobe Flash Player Integer Overflow Vulnerability (CVE-2016-1010)
还没有评论,来说两句吧...