[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Cross-domain loading of XML

  • From: Henri Sivonen <hsivonen@iki.fi>
  • To: "xml-dev@lists.xml.org List" <xml-dev@lists.xml.org>
  • Date: Thu, 9 Dec 2010 17:17:06 +0200

Re:  Cross-domain loading of XML
On Dec 8, 2010, at 16:21, Mike Sokolov wrote:

> However there is a workaround for JSON (they call it JSONP) that uses the ability to load javascript dynamically from another domain.  Essentially, it seems you can bypass the cross-domain restriction by this trick:
> 
> var script = document.createElement('script');
> script.setAttribute('src', url);
> 
> Apparently in this instance url doesn't have to be a url on the same domain.

This has two problems. I noticed only one of them mentioned in the article.

If you are the site using someone else's JSON-P data source, that someone else gets to execute code with the privileges of your origin. They might be serving you code that calls the callback you want with the JSON data you want today, but tomorrow they might serve you something else that gets run in your origin. Thus, if you use someone else's JSON-P service, you have to trust them enough to give them the technical opportunity to do with your users' data anything that your own front end code could do.

The second problem relates to private data. That is, data that you wouldn't serve without login credentials. The Same-Origin Policy is there to protect private data. If you use JSON-P to bypass the Same-Origin Policy, you don't get the protection. Thus, if you serve private data as JSON-P when the request is authorized by HTTP authentication or by a cookie, if the user visits a rogue site while being logged into your site, the rogue site can access the private data offered by you as JSON-P by including the JSON-P file as a script to the rogue site.

It's an accident of history that scripts, plug-in content and images from a different origin are allowed by default. If it were possible to plug this hole without Breaking the Web, it would probably have been plugged already.

> I don't see why this couldn't be used to insert any sort of data at all, but it does rely on javascript.

Indeed, if you could transfer an XML document
<bar/>
as a file that says
foo("<bar/>");
and call it XML-P. It would have the same in-security properties as JSON-P.

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.