开发者

"Same origin policy" and scripts loaded from google - a vulnerable solution?

开发者 https://www.devze.com 2022-12-17 00:56 出处:网络
I read the question here in SO \"jQuery Linking vs. Download\" and I somehow don\'t get it. What happens if you host a page on http://yourserver.com, but 开发者_如何学JAVAload jQuery library from htt

I read the question here in SO "jQuery Linking vs. Download" and I somehow don't get it.

What happens if you host a page on http://yourserver.com, but 开发者_如何学JAVAload jQuery library from http://ajax.googleapis.com and then use the functions defined in jQuery script?

Does "same origin policy" not count in this case? I mean, can you make AJAX calls back to http://yourserver.com?

Is the JavaScript being executed considered as coming from yourserver.com?

My point here is, you do not know what the user has downloaded from some third party server (sorry, Google), and still the code executing on his computer is as good as the one he would download from your server?

EDIT: Does it mean _that if I use a web statistics counter from a 3rd party I don't know very well, they might "inject" some code and call into my web services as if their code was part of mine?


The owner of site http://yourserver.com/ should trust the content it references from other servers (in this case, Google's). The same origin policy doesn't apply to "script" tags.

Of course, the scripts of the foreign servers (once loaded) have access to the whole DOM: so, if the foreign content is compromised, there can be security exposures.

As with many things in the web world, it comes down to trust and continuous management.

Edit:

Does it mean _that if I use a web statistics counter from a 3rd party I don't know very well, they might "inject" some code and call into my web services as if their code was part of mine?

Yes.


Answering the Edit comment: Yes. Unless the counter was wrapped in an iframe tag, it is as if it was a part of your web site and can call into your web services, access your cookies, etc.


Yes, the policy doesn't apply to <script> tags.

If someone was able to hack google's script store, it would affect every page served from every domain, that uses google.com as their host for scripts.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号