Google会像这样返回json:
throw 1; <dont be evil> { foo: bar}
Run Code Online (Sandbox Code Playgroud)
和Facebooks ajax有这样的json:
for(;;); {"error":0,"errorSummary": ""}
Run Code Online (Sandbox Code Playgroud)
作为对安全目的的回应:
如果刮刀位于另一个域上,则必须使用script标记来获取数据,因为XHR不会跨域工作.即使没有for(;;);攻击者如何获取数据?它没有分配给变量,所以它不会被垃圾收集,因为它没有引用它?
基本上,为了获得数据跨域,他们必须这样做
<script src="http://target.com/json.js"></script>
Run Code Online (Sandbox Code Playgroud)
但即使没有崩溃脚本,攻击者也不能使用任何Json数据而不将其分配给您可以全局访问的变量(在这些情况下不是这样).崩溃代码没有任何效果,因为即使没有它,他们也必须使用服务器端脚本来使用其站点上的数据.