angular/angular.js — pull request #8984 by chirayuk (2014-09-09 02:36:29+00:00)
Title: fix($parse): disallow passing Function to Array.sort

Fix the following exploit:

```js
hasOwnProperty.constructor.prototype.toString = toString.call;
["a", "alert(1)"].sort(hasOwnProperty.constructor);
```

The exploit:
• 1. Array.sort takes a comparison function and passes it 2 parameters to compare.
2. The result of the comparison is then converted to a string.
• The Function object conveniently accepts two string arguments so we can use this
to construct a function. However, this doesn't do much unless we can execute it.
• We set the toString function on Function.prototype to Function.prototype.call.
This causes the function that we constructed to be executed when sort calls
.toString() on the result of the comparison.

The fix is in two parts.
• Disallow passing unsafe objects to function calls as parameters.
• Do not traverse the Function object when setting a path.