New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 606390 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug-Security



Sign in to add a comment

Security: V8ValueConverter::ToV8Value is insecure (e.g. heap-use-after-free in MimeHandlerViewContainer::PostMessage

Project Member Reported by rob@robwu.nl, Apr 25 2016

Issue description

Chrome version: 50.0.2661.75 (and also master - 52.0.2716.0)

V8ValueConverter::ToV8Value may run arbitrary JavaScript code via setters when a base::Value is converted to a v8::Value [1]. This makes no sense and is a source of security issues.

For instance, MimeHandlerViewContainer::PostMessageFromValue uses V8ValueConverter to convert a DictionaryValue to a v8::Value, using an untrustworthy ScriptContext [2]. This allows attackers to intercept the setter of a property and trigger a use-after-free.

The attached PoC (top-with-pdf.html) does the following:
1. Load a PDF file in a frame (to activate the built-in PDF viewer that uses the vulnerable MimeHandlerViewContainer).
2. Define a property setter for the "type" key in the iframe that removes the frame ("type" because this is defined in [3]).
3. Call window.print() in the iframe to trigger the value conversion.
4. The setter from step 2 is triggered, and the frame is removed.

After step 4, Chrome with ASAN crashes the renderer because of a UAF in MimeHandlerViewContainer::PostMessage (see attached log file).

Although this specific UAF could be solved by using weak pointers, I believe that the best solution is to modify V8ValueConverter::ToV8Value to NOT trigger setters, since it makes no sense to allow it, especially because there are many other callers of V8ValueConverter::ToV8Value that are similarly vulnerable, including but not limited to cross-process postMessage on the web [4] and lots of extension code (see e.g. the attached zip file plus ASAN stack trace for a simple extension that causes a crash at [5]).


[1] https://chromium.googlesource.com/chromium/src/+/c864f52514c7e8cf9992a524e0294b1cc32c1db5/content/child/v8_value_converter_impl.cc#264
[2] https://chromium.googlesource.com/chromium/src/+/f6f806674c4f6ebbb8b20197ae5b6c7a40bba08f/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc#269
[3] https://chromium.googlesource.com/chromium/src/+/10098ae32d6cd53775282b9bcc1cfc697cd0a00c/chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc#77
[4] https://chromium.googlesource.com/chromium/src/+/91da0781306a006952e67ee4423a59a5a0da8fb6/content/renderer/render_frame_impl.cc#2083
[5] https://chromium.googlesource.com/chromium/src/+/f6f806674c4f6ebbb8b20197ae5b6c7a40bba08f/extensions/renderer/messaging_bindings.cc#304
 
top-with-pdf.html
1.4 KB View Download
asan-cr-50.0.2661.75.log
23.3 KB View Download
messaging_bindings_npe.zip
1.8 KB Download
messaging_bindings_npe-asan.log
9.1 KB View Download

Comment 1 by rob@robwu.nl, Apr 25 2016

Owner: rob@robwu.nl
Status: Started (was: Unconfirmed)
And here is a proposed patch: https://codereview.chromium.org/1918793003

Comment 2 by rob@robwu.nl, Apr 25 2016

Cc: jochen@chromium.org
+jochen for reviewing the patch.

Comment 3 by vakh@chromium.org, Apr 26 2016

Cc: haraken@chromium.org dcheng@chromium.org
Components: Blink>Bindings

Comment 4 by rsesek@chromium.org, Apr 26 2016

Labels: Security_Severity-High M-50 Security_Impact-Stable Pri-1
Tagging as M50 based on the ASan log for 50.0.2661.75.
Project Member

Comment 5 by bugdroid1@chromium.org, Apr 27 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b5bdf3778209179111c9f865af00940e74aa20e7

commit b5bdf3778209179111c9f865af00940e74aa20e7
Author: rob <rob@robwu.nl>
Date: Wed Apr 27 11:27:06 2016

V8ValueConverter::ToV8Value should not trigger setters

BUG= 606390 

Review URL: https://codereview.chromium.org/1918793003

Cr-Commit-Position: refs/heads/master@{#390045}

[modify] https://crrev.com/b5bdf3778209179111c9f865af00940e74aa20e7/content/child/v8_value_converter_impl.cc
[modify] https://crrev.com/b5bdf3778209179111c9f865af00940e74aa20e7/content/child/v8_value_converter_impl_unittest.cc

Comment 6 by rob@robwu.nl, Apr 27 2016

Status: Fixed (was: Started)
Verified fixed in 52.0.2719.0 (390054).

Chrome no longer crashes using the STR from the report.

I'll request merges later this week.
Project Member

Comment 7 by ClusterFuzz, Apr 27 2016

Labels: -Restrict-View-SecurityTeam Merge-Triage M-51 Restrict-View-SecurityNotify
Adding Merge-Triage label for tracking purposes.

Once your fix had sufficient bake time (on canary, dev as appropriate), please nominate your fix for merge by adding the Merge-Requested label.

When your merge is approved by the release manager, please start merging with higher milestone label first. Make sure to re-request merge for every milestone in the label list. You can get branch information on omahaproxy.appspot.com.

- Your friendly ClusterFuzz

Comment 8 by rob@robwu.nl, Apr 28 2016

Labels: Merge-Request-51
Requesting to merge b5bdf3778209179111c9f865af00940e74aa20e7 with M-51.

Comment 9 by tin...@google.com, Apr 28 2016

Labels: -Merge-Request-51 Merge-Approved-51 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M51 (branch: 2704)
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 28 2016

Labels: -merge-approved-51 merge-merged-2704
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dfadac5e2b85dfed5076434e4152aed9fc4c80ac

commit dfadac5e2b85dfed5076434e4152aed9fc4c80ac
Author: Rob Wu <rob@robwu.nl>
Date: Thu Apr 28 14:55:07 2016

V8ValueConverter::ToV8Value should not trigger setters

BUG= 606390 

Review URL: https://codereview.chromium.org/1918793003

Cr-Commit-Position: refs/heads/master@{#390045}
(cherry picked from commit b5bdf3778209179111c9f865af00940e74aa20e7)

Review URL: https://codereview.chromium.org/1930953002 .

Cr-Commit-Position: refs/branch-heads/2704@{#286}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/dfadac5e2b85dfed5076434e4152aed9fc4c80ac/content/child/v8_value_converter_impl.cc
[modify] https://crrev.com/dfadac5e2b85dfed5076434e4152aed9fc4c80ac/content/child/v8_value_converter_impl_unittest.cc

Comment 11 by rob@robwu.nl, Apr 28 2016

Labels: Merge-Request-50
Requesting to merge b5bdf3778209179111c9f865af00940e74aa20e7 with M-50.

The patch has been in Canary since today, and the unit test and manual tests confirm that the bug has been resolved.

The risk of merging is low because there is nothing in Chromium that expects side effects (setters to be triggered) when doing the value conversion (and that is also why this was a security bug).

Comment 12 by tin...@google.com, Apr 29 2016

Labels: -Merge-Request-50 Merge-Review-50 Hotlist-Merge-Review
[Automated comment] Request affecting a post-stable build (M50), manual review required.
Cc: tinazh@chromium.org
Labels: -Merge-Review-50 Merge-Approved-50
Approving Merge to M50 branch 2661 based on comment #11. Please merge to M50 branch 2661 ASAP. We're planning M50 Stable release next week. Thank you.
Project Member

Comment 14 by bugdroid1@chromium.org, May 6 2016

Labels: -merge-approved-50 merge-merged-2661
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6a66d73c561f07ff61f46311467cc451b5bcb86b

commit 6a66d73c561f07ff61f46311467cc451b5bcb86b
Author: Rob Wu <rob@robwu.nl>
Date: Fri May 06 10:56:46 2016

V8ValueConverter::ToV8Value should not trigger setters

BUG= 606390 

Review URL: https://codereview.chromium.org/1918793003

Cr-Commit-Position: refs/heads/master@{#390045}
(cherry picked from commit b5bdf3778209179111c9f865af00940e74aa20e7)

Review URL: https://codereview.chromium.org/1959613002 .

Cr-Commit-Position: refs/branch-heads/2661@{#659}
Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}

[modify] https://crrev.com/6a66d73c561f07ff61f46311467cc451b5bcb86b/content/child/v8_value_converter_impl.cc
[modify] https://crrev.com/6a66d73c561f07ff61f46311467cc451b5bcb86b/content/child/v8_value_converter_impl_unittest.cc

Project Member

Comment 15 by bugdroid1@chromium.org, May 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/54cc1bc318e2ca7a5dc441eba5240d9b2eac2063

commit 54cc1bc318e2ca7a5dc441eba5240d9b2eac2063
Author: Rob Wu <rob@robwu.nl>
Date: Fri May 06 18:37:15 2016

Revert change to v8_value_converter_impl_unittest.cc

To resolve compilation errors on a release branch caused by
6a66d73c561f07ff61f46311467cc451b5bcb86b.

BUG=609878, 606390 

Review URL: https://codereview.chromium.org/1959633004 .

Cr-Commit-Position: refs/branch-heads/2661@{#661}
Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}

[modify] https://crrev.com/54cc1bc318e2ca7a5dc441eba5240d9b2eac2063/content/child/v8_value_converter_impl_unittest.cc

Labels: -merge-merged-2661
-merge-merged-2661 as reverted. Please re-add when landing again.

Comment 17 by rob@robwu.nl, May 9 2016

Labels: merge-merged-2661
Adding label again - only the test case was reverted because the test used APIs that are not on stable (bug 609878). The fix itself is on M-50.
Labels: -Merge-Triage reward-topanel Release-0-M51
Labels: -reward-topanel CVE-2016-1679 reward-unpaid reward-3500
Congrats Rob - $3500 for this report ($3000 for the bug, $500 for the patch).

CVE-ID is CVE-2016-1679
Labels: -reward-unpaid reward-inprocess
Project Member

Comment 21 by sheriffbot@chromium.org, Aug 4 2016

Labels: -Restrict-View-SecurityNotify
This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 22 by sheriffbot@chromium.org, Oct 1 2016

This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 23 by sheriffbot@chromium.org, Oct 2 2016

This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: allpublic
Labels: CVE_description-submitted

Sign in to add a comment