Is JSON.parse() really safer than eval() when web page and ajax call come from same server?

后端 未结 4 1185
无人及你
无人及你 2021-02-05 14:43

I get that JSON.parse() prevents an attacker from injecting javascript into the response since a JSON parser is just a text parser, not a script parser so please don\'t close th

4条回答
  •  长发绾君心
    2021-02-05 15:17

    Well, if they're able to inject into your AJAX responses they've probably already successfully man-in-the-middle'd you in one way or another (ARP, DNS or something else).

    See http://en.wikipedia.org/wiki/Man-in-the-middle_attack for more details on these types of attack.

    You are correct in that, if they can inject into your AJAX response, they can inject whole pages as well. Really, anything you receive OR send via networking is now vulnerable in a MitM unless something like HTTPS\SSL is being used.

提交回复
热议问题