热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

TechnicalAnalysisofCVE-2014-0515AdobeFlashPl

TechnicalAnalysisofCVE-2014-0515AdobeFlashPlayerExploitAttheendofApril,KasperskyreportedanITWexploitthatwasabusinganAdobeFlashPlayerzero-dayvulnerabilityatthetime(CVE-2014-0515).Thevulnerabilitywasknownto

Technical Analysis of CVE-2014-0515 Adobe Flash Player Exploit At the end of April, Kaspersky reported an ITW exploit that was abusing an Adobe Flash Player zero-day vulnerability at the time (CVE-2014-0515). The vulnerability was known to

Technical Analysis of CVE-2014-0515 Adobe Flash Player Exploit

At the end of April, Kaspersky reported an ITW exploit that was abusing an Adobe Flash Player zero-day vulnerability at the time (CVE-2014-0515). The vulnerability was known to be inside the Pixel Bender parser in Adobe Flash Player. I had time to look deeper into how the vulnerability works and how control of the code is acquired using this vulnerability.

Figure 1 shows the overall structure of the exploit sample I tested. I used the swfdump tool from swftools.? Tag 057 contains binary data that is used as Pixel Bender bytes later in ActionScript Byte Code (tag 052).

fig01.png

Figure 1 Overall structure of the exploit SWF file

Heap spray

As usual, the exploit starts with a heap spray. Similar to the exploit I discussed in my previous blog on the CVE-2014-1776 IE vulnerability, this one also uses the Vector data type to achieve fine control of memory layout and data. But there are a couple of differences to the method I described with the IE exploit.

Laying out memory

First, it sprays the heap with Vector.? with a size of 0x22 (Figure 2). Each Vector. has the following format:

Vector size (4 bytes) + extra header (4bytes)? + int (4 bytes) array of 0x22

The vector is pushed as a member of the Array data type, and the size of the array becomes 0x10000.

fig02.png

Figure 2 Allocating 0x22 size of Vector. array

Figure 3 shows the actual memory data when this heap spray occurs. Vector. members are mostly adjacent to each other and have a size of 0x90 (8 bytes header + 4*0x22 bytes of int array). ?The first 4 bytes of each member is 0x22 in DWORD, which indicates the Vector size.

fig03.png

Figure 3 Memory raw data for Vector.

Making holes

Now that the basic layout of the heap spray is done, the exploit tries to shrink the size of each Vector to 0 (Figure 4). The way the Flash internal logic works makes holes between each members. Instead of allocating a new Vector array with size 0, it just re-uses previous memory layout resetting length field to 0.

fig04.png

Figure 4 Set vector lengths to 0

The result of this length reset is shown in Figure 5. The Vector size has shrunk to 0 and each Vector member uses only 8 bytes of memory, leaving an extra 0x88 bytes free for use. The size of 0x88 is very much intentional here and it becomes important later when the actual exploit happens.

fig05.png

Figure 5 Memory raw data for Vector. after resetting length to 0

Making bigger holes

Aside from making 0x88 bytes of heap spray holes, the exploit tries to make more holes in parts of the heap spray area. (Figure 6) The whole creation works by assigning 0x100 length to some of the Vectors. This makes the existing array in the heap spray area to be freed and allocated in another place.

fig06.png

Figure 6 Increasing size of some array members

Figure 7 shows the memory layout before these holes are created. There are 0x88 bytes of freed memory.

fig07.png

Figure 7 Before increasing the array member size

When this additional hole creation happens, some parts of the heap area look like Figure 8. This makes 0x118 bytes of freed memory area in the heap spray region. I tested with the exploit and this bigger hole is essential to the exploit because during the exploit process, the code uses this empty area rather than creating new heap memory, and it is related to whether the previous smaller holes with 0x88 size are used further in the code.

fig08.png

Figure 8 After increasing the array member size

The vulnerability – Pixel Bender Parser Issue

?

First memory corruption

The vulnerability is inside the code where the Flash Player parses the Pixel Bender data from the exploit code. When I tested with a debugger, I found that the DWORD value at offset 0xEA of Pixel Bender data is responsible for triggering the vulnerability. (Figure 9)

fig09.png

Figure 9 Malformed Pixel Bender data triggers the vulnerability

To analyze how this memory region breaks Pixel Bender parsing code, I used the dpbj tool, which can be utilized to disassemble a raw Pixel Bender binary format file. The author has released the source code of the tool, aside from just the binary. I found this project very useful, particularly when there was no good public documentation on the internal format of a Pixel Bender binary available. Figure 10 shows the code where the memory area responsible is located.

fig10.png

Figure 10 Pixel Bender code triggers the vulnerability

The metadata ?of defaultValue is intended to be just 4 bytes long, but the code tries to convert all of its 16 arguments and puts them in the memory array, incurring a memory corruption error. Figure 11 shows how the sel instruction and the defaultValue metadata is saved. The original binary data is parsed and translated into a bytecode that is later used for further operations. The 2nd value from the defaultValue argument overwrites the index value inside the sel instruction’s byte code in memory.

fig11.png

Figure 11 Memory corruption

The code that overwrites this sel instruction area is shown in Figure 12. The fstp instruction saves a value to a memory location designated by its operand. In this case, the original value of 0x000B3880 is saved directly to 0x000B3880 after endian change. The instruction at 0x167EC63 shows that the memory location will be increased by 0x14. The first defaultValue member falls inside a valid memory location but the values from the 2nd argument are inside the memory of the sel instruction’s byte code area.

fig12.png

Figure 12 Code responsible for memory corruption

Second memory corruption

The first memory corruption corrupts the other instruction’s byte code. The corrupt byte code is interpreted and run. Figure 13 shows the code that interprets the byte code op code.

fig13.png

Figure 13 Switch on op code

Figure 14 shows the code where each instruction’s operand is passed to the set_array_value function.

fig14.png

Figure 14 Code setting register values

The code that actually performs additional memory corruption is shown in Figure 15. The function is called for each instruction and when the corruption happens, the arg_index value is 0x000B3880 – which is from the corrupted memory area. ?The index value is converted to an offset in the memory that is used later to save some data. From the instruction at 0x0167BC78, ecx is a pointer to a data structure on the memory and edi is an offset calculated from arg_index. The Eax value is a little bit tricky. The value is returned from a previous call to sub_1909EE0 which returns a pointer to a memory location.

fig15.png

Figure 15 Memory corruption code

An interesting thing happens here. From ecx (base pointer), edi (offset), and eax (value to overwrite), the attacker can control edi for sure. Also, as a consequence of using the previously mentioned heap spray technique, there are a lot of memory holes with size 0x88 on the heap. The data structure pointed to by ecx has a size smaller than 0x88 and there is a strong chance that the pointer will fall in one of the holes on the heap spray area. So, now the attacker can control ecx and edi somehow. But, eax can be a random (but valid) memory location on the heap. The attacker doesn’t have control of it. Here’s an interesting fact; the attacker doesn’t need to control eax. The fact that eax is always a valid pointer makes it a value bigger than some range of values (probably bigger than 0x22+1). Figure 16 shows the memory state just before this memory corruption occurs.

fig16.png

Figure 16 Base address points to one of the heap spray holes with size 0x88

Figure 17 shows the memory state when the memory corruption happened through the related instructions. You can see that the length field of a[x+1] is overwritten with a pointer value. The value can be random, but it is always bigger than 0x22+1. This makes it possible for the attacker to corrupt the next Vector’s length field.

fig17.png

Figure 17 After memory corruption, a[x+1].length will be a huge value

Exploitation

Additional Vector corruption

Now a[x+1].length becomes a huge value.? It can corrupt additional Vector elements and the exploit can have full access to process memory. It corrupts the next Vector’s length field to 0x40000001. (Figure 18)

fig18.png

Figure 18 ActionScript code to corrupt next vector’s size to 0x40000001 (corrupt_index=x+1)

Now a[x+2].length becomes 0x40000001. Figure 19 shows the state when this additional corruption happens. From a[x+2], the exploit can use arbitrary index values to access any memory locations.

fig19.png

Figure 19 Memory state after additional Vector length corruption

FileReference spraying & corruption

The exploit creates 64 FileReference objects on the heap. (Figure 20)

fig20.png

Figure 20 Spraying FileReference objects

It searches for the FileReference objects from the heap using some conditions and when it finds one, it overwrites its function pointer. If we say v = a[x+2], then it will assign a v[2] address as the function pointer. The memory area around this fake function table is constructed from ActionScript, as shown in Figure 21.

fig21.png

Figure 21 Building a fake FileReference function table and arguments

Memory permission change

The exploit can now control data for the FileReference object’s function pointers. The exploit searches for the FileReference object on the heap area by heuristic method and when it locates one, it will replace the function table pointer address to a fake address. (Figure 22)

fig22.png

Figure 22 Modifying FileReference object function table pointer

Figure 23 shows the fake function table with fake arguments. The v[7] is the pointer where the cancel method is called. Figure 24 shows the ActionScript code that calls the cancel methods.

fig23.png

Figure 23 Fake FileRefence function table

fig24.png

Figure 24 Running the cancel method from the fake FileReference function table

The code pointed to by v[7] is shown in Figure 25. This function uses an argument from the function table pointer. The eax points to v[2] location when it is called. The instructions at 0x6EB8D5D8 and 0x6EBD5DB show that two arguments from eax-8 (v[0]) and eax-4 (v[1]) are used, which are interpreted as the size and address of the target memory.

fig25.png

Figure 25 Code from Flash main binary that is used for v[7]

Further into the call to the call_virtual_protect function, it eventually calls the VirtualProtect API to give execute permission to target memory. By reusing code from the Flash binary itself, the exploit defeats DEP.

fig26.png

Figure 26 Code inside call_virtual_protect

Executing shellcode

With the exploit already defeating ASLR by full memory access and defeating DEP by reusing Flash binary code that can change permission on a designated memory location, the rest is relatively easy. The exploit builds the shellcode first (Figure 27), and modifies v[7] to a shellcode address. The v[7] is the function pointer to a cancel method. (Figure 28)

fig27.png

Figure 27 Build shellcode

fig28.png

Figure 28 Replacing the function pointer for the cancel method inside the fake FileReference object and running it

When additional cancel methods are called, the fake function table looks like Figure 29. The address pointed to by v[7] has already been made executable by previous calls to the cancel method that calls VirtualProtect API. (Figure 23)

fig29.png

Figure 29 Replaced v[7], function pointer for cancel

Summary

CVE-2014-0515 is a really interesting vulnerability with the Pixel Bender engine. The metadata parser is expecting fixed-size data, but if you supply larger data intentionally, it can overflow and overwrite the operand byte code of adjacent instructions. This memory corruption leads to further memory corruption involving byte code interpretation. Even if you can only control where to write the data, not what to write, you can still use Vector length corruption to achieve further access to lower level memory. With full access to process memory, ASLR and DEP can be easily defeated. Everything looks very similar to the CVE-2014-1776 exploit we talked about previously. But, the style of the exploit itself is quite different. The way the heap spray is laid out is quite different and the way how it finds gadget and function addresses is different. We might well see similar or variant styles of this exploit in the future.

http://h30499.www3.hp.com/t5/HP-Security-Research-Blog/Technical-Analysis-of-CVE-2014-0515-Adobe-Flash-Player-Exploit/ba-p/6482744#.U31QRlfVycY

推荐阅读
  • vue使用
    关键词: ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • Echarts图表重复加载、axis重复多次请求问题解决记录
    文章目录1.需求描述2.问题描述正常状态:问题状态:3.解决方法1.需求描述使用Echats实现了一个中国地图:通过选择查询周期&#x ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • Python字典推导式及循环列表生成字典方法
    本文介绍了Python中使用字典推导式和循环列表生成字典的方法,包括通过循环列表生成相应的字典,并给出了执行结果。详细讲解了代码实现过程。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • “你永远都不知道明天和‘公司的意外’哪个先来。”疫情期间,这是我们最战战兢兢的心情。但是显然,有些人体会不了。这份行业数据,让笔者“柠檬” ... [详细]
author-avatar
caiyingsheng852
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有