we are looking at using the unparseable curft approach to our json as an extra level of security.
In looking at the approaches, I've come across google's while(1);
and facebook's for(;;)
; and then another mention of {}&&
I've seen comments surrounding the while(1);
that say the 1 being numeric can get clobbered, so my approach was going to be the for(;;);
.
Then I came across the {}&&
, which renders the json as invalid yet it can still be parsed/eval'ed. See this article for reference: http://www.sitepen.com/blog/2008/09/25/security-in-ajax/
What are your approaches? and what do your functions look like for making the ajax call with the unparseable curft?
eval
, then the burden of fixing the approach is entirely on them... also, the article date from 2008 when proper JSON parsing was not as prevalent on browsers. Today it is either standardJSON.parse
or readily available as a shim. I would not go for such "security" measures. – Christoeval
. It's a defense against third-party sites using<script src>
. Second, if the script doesn't parse, the array can't be constructed, so JSON hijacking will fail. – Wivern