XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] 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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS