Is It Too Late To Change JSON?
haacked.com
haacked.com
As I understand it, this exploits the fact that some browsers (which?) allow one site to overload a handler that then sees data from other sites. How is that not a huge XSS hole right there? Why drag JSON into this?
{ json: [ my stuff... ]}
Isn't that sufficient? Use that when returning sensitive data, just normal arrays when not dealing with sensitive info.Every blog post advocating for petty changes to JSON completely misses the point.
Edit: Or maybe respond to earlier post, now linked at HN: http://news.ycombinator.com/item?id=675678
Furthermore, why should we worry about changing JSON? It's not amazingly difficult to construct a parser for some custom document format like this, after all. I use a subset of Ruby as a data interchange format because of the ability to use arbitrary values as hash keys, and the ability to have symbols that are distinct from strings. The parser for it is maybe 80 lines at most, and doesn't rely on Ruby internals to handle it. Because Ruby also doesn't have a Date/Time literal notation, I have a way of denoting that (datetime(...)) which the parser also handles.
There's no reason people should be talking about this, it's a non-issue. It's never too late to change JSON, or to even do something completely different that better suits your needs. Just write the parser for it!
And if the issue is "OMG interoperability! :(", it's not terribly diffuclt to provide your developers with the JavaScript lib to handle the parsing.
1. Use crumbs to protect against XSRF.
2. Responses that should not be cached by proxies should have a "Cache-Control: private" header.
The "what if there's a broken proxy" argument in the post is specious, since a proxy that's broken in this way will cause much more serious security problems than are being discussed here (e.g. John visits google.com and gets Jane's cached Google homepage from the proxy).
3. Responses that should not be cached by browsers or proxies should have a "Cache-Control: no-cache" or "Cache-Control: no-store" header.
4. If you're still concerned, wrap your JSON responses in objects yourself; there's no need to modify the format to do it for you.