Google Chrome V8 Arrow Function Scope Fixing Bug

Type packetstorm
Reporter Google Security Research
Modified 2018-04-26T00:00:00


                                            `Chrome: V8: Arrow function scope fixing bug   
When the parser parses the parameter list of an arrow function contaning destructuring assignments, it can't distinguish whether the assignments will be actually in the parameter list or just assignments until it meets a "=>" token. So it first assigns the destructuring assignments to the outer scope, and fixs the scope when it meets the "=>" token.  
Here's the methods used to fix the scope (<a href="" title="" class="" rel="nofollow"></a>).  
void RewindDestructuringAssignments(int pos) {  
void SetDestructuringAssignmentsScope(int pos, Scope* scope) {  
for (int i = pos; i < destructuring_assignments_to_rewrite_.length();  
++i) {  
Since the SetDestructuringAssignmentsScope method changes the scope from "pos" to the end of the list, it needs to call the RewindDestructuringAssignments method after fixing the scope. But the RewindDestructuringAssignments method is only called when the arrow function's body starts with a "{" token (<a href="" title="" class="" rel="nofollow"></a>).  
So it can't properly handle the following case where a destructuring assignment expression containing a single line arrow function. It will set the scope of the inner destructuring assignments to the outer arrow function's scope.  
(({a = (async ({b = {a = c} = {  
a: 0x1234  
}}) => 1)({})}, c) => 1)({});  
Received signal 10 BUS_ADRERR 12340000001f  
==== C stack trace ===============================  
[end of stack trace]  
Bus error: 10  
Found by: lokihardt