Jump to content
Nytro

Google Chrome pdfium shading drawing integer overflow lead to RCE

Recommended Posts

Posted

Google Chrome pdfium shading drawing  integer overflow lead to RCE

Vulnerability Credit

Zhou Aiting(@zhouat1) of Qihoo 360 Vulcan Team

1. Vulnerability Description

CVE:CVE-2018-6120

Affected versions:Chrome Version < 66.0.3359.170

2. Vulnerability analysis

2.1 Vulnerability type

Run poc file, get the ASAN crash dump:

a1.jpg

Figure 1

2.2 Vulnerability root cause

1) The code corresponding to the crash point is shown in Figure 2:

7B77F29606EAD5C63BF03E1A89B6505E.jpg

Figure 2 crash point code

Since the value of m_nOrigOutputs is outside the scope of the array request space, an out-of-bounds write will occur at line #55 of Figure 2.

2) Array declaration and the size of the allocation:

The source code corresponding to the ASAN crash dump stack:

58C11C7A4D9B73A29424CE832942E635.jpg

Figure 3 The source code around ASAN crash dump

With the help of the ASAN crash dump, we can locate the following source code: The size of the array is determined by the return value of the following function.

9BDC6E9D2D07763EFC906648D43B9BDB.jpg

Figure 4 Calculation of the required space of the array

In Figure 4, set breakpoint at code line #100, after running multiple times, we can see that the value of total overflows when parsing the poc file.

3. Vulnerability exploit

Since the variables (m_nOrigOutputs, m_Exponent) can be precisely controlled in the pdf file by controlling the corresponding fields, we can simplify the assignment action . Control m_Exponent = 0, then FXSYS_pow(input ,m_Exponent) will always be 1.

a2.jpg

Figure 5

The contents of m_pEndValues array come from the pdf file and are fully controllable, so it’s very simple to exploit this vulnerability.

D379D9D759F58F51E6D216FF01E1C9BA.jpg

Figure 6 The contents of the overflow array are fully controllable

4. Demo

40982BF8AF25A184ECAAF25676E4FC3D.jpg

Figure 7 hijacking instruction register

5. Vulnerability Patch

The Chrome team fixed the vulnerability quickly:

CAF4CE0DBC9DC0FA21FAEF557DC57BE5.jpg

Figure 8 Google Fixed the vulnerability

0EA8A2FF9EC8A93ED20E6465BEAB28DF.jpg

Figure 9 Fixing code _1

Using FX_SAFE_UINT32 replace previous uint32_t, the representation in memory : the upper four bytes are the value of unsigned int, and the lower four bytes hold the data overflow identifier.

a3.jpg

Figure 10

Since the operator is overloaded, the overflow is automatically checked when doing a numerical calculation of this type, ensuring that overflow and underflow do not occur. The specific check method is to use the compiler’s built-in overflow detection function __builtin_add_overflow. After the overflow occurs, the function where the result_array is located returns directly. (See Figure 10)

D759A92B97D90451A222D9DBB28A5A81.jpg

Figure 11 Fixing code _2

6. Attack again

Affected versions: Chrome Version < 67.0.3396.99

After the official fix of CVE-2018-6120 was out, we noticed such data type:

CFX_FixedBufGrow<float, 16>, its constructor is shown in Figure 12:

9EB533FA6003C984A3B909C4D5FB7C3E.jpg

Figure 12. Constructor for CFX_FixedBufGrow

CFX_FixedBufGrow<float, 16> result_array(total_results) meaning :

(1) When the required space is not greater than 16, the stack space of 16 float types is returned;

(2) Otherwise use the parameter (total_results) to request a piece of memory on the heap.

The problem is that the argument passed in here is unsigned int, while the formal parameter is int.

CVE-2018-6120 out of bound write vulnerability can be triggered again :)

For the latest stable version, the new vulnerability described in this section is no longer exploitable, so we decided to disclose the details here.

7. Fixed by non-security update

More than three years of functional discussion once again accidentally killed the bug.

A non-security update from Chrome last month unexpectedly fixed this vulnerability in section #6. The reason is:

after a series of performance tests passed, Chrome removed the CFX_FixedBufGrow type and replaced it with std::vector. For more information, please refer to link .

nice work, Google Chrome Team :)

027A0BBB068E3C551C0F0087C7DCED0F.jpg

Figure 13

8. Vulnerability Reporting Timeline

2018-04-17 submit bug issue

2018-04-18 issue fixed

2018-04-19 issue closed

2018-05-10 Google credited to Qihoo 360 Vulcan Team

Ref:

[1] https://www.chromium.org/Home/chromium-security/pdfium-security

[2] https://bugs.chromium.org/p/pdfium/issues/detail?id=177

[3] https://bugs.chromium.org/p/chromium/issues/detail?id=833721

[4] https://chromereleases.googleblog.com/2018/05/stable-channel-update-for-desktop.html

本文链接:http://blogs.360.cn/post/google-chrome-pdfium-shading-drawing-integer-overflow-lead-to-rce.html

-- EOF --

作者 admin001 发表于 2018-07-16 09:40:16 ,添加在分类 Browser Security Vulnerability Analysis 下 ,最后修改于 2018-08-24 08:36:43

 

Sursa: http://blogs.360.cn/post/google-chrome-pdfium-shading-drawing-integer-overflow-lead-to-rce.html

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...