By default, browsers don't allow cross-site AJAX requests.
I understand that a badly envisioned cross-domain request can be a security risk. If I take the html or the javascript of an external site and just "render" it into my website, that's a problem. That external code could be used for lots of bad things - like getting access to the current user's session data.
But if I only request JSON or XML data, and I use a proper library to parse the JSON (not just using eval) I can't imagine how that would be a security risk. The worse that can happen is that the content coming from that site doesn't render correctly.
Am I missing anything? Is it possible to compromise a page that reads json/xml simply by sending it some kind of malicious data?
The risk isn't to the site making the request.
For example:
In a nutshell — it prevents attackers from reading private data from any site that Alice has credentials for (and ones that are behind a firewall, e.g. Alice's corporate Intranet).
Note that this won't prevent attacks which don't depend on being able to read data form the site (CSRF), but without the Same Origin Policy the standard defence against CSRF would be easily defeatable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With