Earlier quoted context omitted.
OK, I see how that prevents an attack (it seems to create an endless loop), but how does this parse as regular JSON for the good guys?
I imagine they simply remove the first 8 characters from the response string. eval("(for(;;);{})"); doesn't work, but eval("(" + "for(;;);{}".substring(8, 10) + ")"); works fine where 10 is the length of the response string. EDIT: This is the correct idea. Search for shieldlen or safeResponse in the JS to see how it is implemented. There is always something interesting to be learned by digging through FB's client sid…
JSON users: Avoid CSRFs by not using top-level arrays
81–85 of 85 posts
Re: JSON users: Avoid CSRFs by not using top-level arrays
#82 * It needs an array literal (eg. []) to be constructed using the function referenced by the Array property on the global object. (This was spec ambiguity and only effects older IE and Firefox -- very old firefox, maybe only up to netscape or phoenix?)
* It needs assignments in object and array literals to call setters on the prototype chain.
Both of these issues were fixed by ES5 (the first may have been fixed in ES3.1) by saying that Array and Object literal notation both use the initial values of Array and Object (so you can't change the constructor used), and by saying that all assignments are "direct" so won't call setters on the prototype chain.This effectively makes JSON hijacking impossible, except of course for the large numbers of old browsers that are out there.
This is also a distinct issue from JSONP hijacking, for which there isn't a solution other than to not use JSONP.
Re: JSON users: Avoid CSRFs by not using top-level arrays
#83Earlier quoted context omitted.
A few days ago I asked, "Ask HN: Best Approaches to Prevent Session Hijacking?" ( http://news.ycombinator.com/item?id=2663293 ) and presented a technique I'm experimenting with that uses session timestamps as tokens to validate that each request is authentic and an attacker hasn't stolen the session key. It works by updating the token (timestamp) on the server and in the cookie on each request and they both have to m…
How much does running everything over HTTPS mitigate this cross-site stuff?
Re: JSON users: Avoid CSRFs by not using top-level arrays
#84Earlier quoted context omitted.
Apache Extended Server Side Includes? Haven't seen XSSI before. What's the I? I agree, this is not the attack I think of when somebody mentions CSRF. Well, the solution at least isn't. I would be very suspicious of anyone who claimed to solve their CSRF holes by not using arrays.
Cross Site Script Inclusion. The article touches on a lot of things (including CSRF), but the HN title refers specifically to JSON (As well as the link's '#' fragment identifier), and therefore the last section, where it shows an attack site including unprotected JSON through the tag, and unless I'm seriously mistaken, this is the definition of XSSI.
Here are a couple of resources that go a litle more into XSSI:
Google tech talk: http://www.youtube.com/watch?v=jC6Q1uCnbMo&feature=playe...
Gruyere codelab: http://google-gruyere.appspot.com/part3#3__cross_site_script...
Re: JSON users: Avoid CSRFs by not using top-level arrays
#85This is a non-issue if you use JSON-RPC.