Re:JSON users: Avoid CSRFs by not using top-level arrays
by kkaefer on Saturday June 18, 2011 @12:19PM
(#2668896)
Array() doesn't seem to be called when defining an array with [] in Chrome 12 and Firefox 3.6+
[ Parent
| on HN ]
Re:JSON users: Avoid CSRFs by not using top-level arrays
by locci on Saturday June 18, 2011 @01:41PM
(#2669082)
Because [] is not syntactic sugar for new Array.
The code the article wrote about doesn't work in any implementation that I know of.
I think the ESv3 spec wasn't very clear:
"Create a new array as if by the expression new Array()."
But the implementations (always?) did the right thing, and the ESv5 spec is more clear:
it adds "where Array is the standard built-in constructor with that name."
Re:JSON users: Avoid CSRFs by not using top-level arrays
by gruseom on Saturday June 18, 2011 @02:05PM
(#2669133)
This comment and the GP suggest that the article is wrong. Is it? Can anyone confirm a JS implementation that manifests the described behavior (the Array constructor being called when parsing top-level [] in JSON)?
It obviously worked this way at some point (http://news.ycombinator.com/item?id=2668888), so I'm guessing the older IEs, at least, still have this flaw.
Re:JSON users: Avoid CSRFs by not using top-level arrays
by the_mitsuhiko on Saturday June 18, 2011 @04:14PM
(#2669424)
> Because [] is not syntactic sugar for new Array
In Firefox 4 and other new browsers this is no longer the case. But right now it's still an issue as many people are using older browsers.