Difference between “)]}',\n” and “{} &&” in avoiding json hijacking

后端 未结 1 1839
逝去的感伤
逝去的感伤 2021-01-02 02:50

In reading about how to avoid json hijacking I\'ve come across various methods including POSTing everything or prepending responses so they are not valid JavaScript.

1条回答
  •  粉色の甜心
    2021-01-02 03:30

    Anything that stops the JSON response being parsed as a JavaScript object or array will prevent this method of JSON Hijacking.

    See this post for some methods of making your JSON secure.

    However, as this answer states, it is not really an issue since Firefox 3.

    Google uses an "unparseable [cruft]" to defend its self against this type of attack. It should be noted that this vulnerability has been fixed in firefox 3, and this vulnerability arises from how browsers impalement the json specification.

    At the time of writing Google appear to prepend )]}' to their responses from Gmail.

    0 讨论(0)
提交回复
热议问题