简体   繁体   中英

Why will disabling Browser Web Security (e.g. Chrome) help doing Cross-Site-Requests?

We have several internal web applications. One of those needs to access all the other applications. Problem is: Same-Orign-Policy .

Actually I did manage to get around it. First of all, the IE is quite sloppy what concerns web security. So, it actually asked me whether I want to have these requests done or not. If I clicked yes, he just executed the cross site requests.

But since most of the users won't use IE, there was the need to make it run in another browser. So, I tried to make it run in Google Chrome. And after some research I found out, that it will work when I turn of the Web Security by using the execution parameter --disable-web-security . This did the job. But unfortunately, most of the users won't be using this execution parameter. Therefore I need another solution.

Then I came across CORS . CORS seems to be implemented in Chrome, but it has one drawback (for me). I need to set headers on the server side. For reasons I won't discuss in here, this is a no go.

So what I was actually wondering about is:

Why will disabling Browser's Web Security do the job, while I need the server to allow the request when using CORS?

  1. What exactly happens inside the browser when I disable the web security?

  2. And is there another way to execute my CSR without adding headers on the server's side or disabling the security?

Thanks in advance

EDIT: JSONP is out of question either

Why will disabling Browser's Web Security do the job, while I need the server to allow the request when using CORS?

The point of the Same Origin Policy is to prevent Mallory's evil site from making Alice's browser go to Bob's site and expose Alice's data to Mallory.

Disabling security in the browser is, effectively, saying "I don't care about protecting my data on Bob's (or any other!) site". This is a dangerous thing to do if the browser is ever going to go near the open web. The option is provided to make development more convenient — I prefer a more controlled solution (such as the URL rewriting options in Charles proxy).

CORS is Bob's site saying "This URL doesn't contain any data that Mallory (or some other specific site, or everyone) shouldn't have access to, so they can access it. Bob's site can do this because it knows which parts of it contain public data and which parts contain private data.

What exactly happens inside the browser when I disable the web security?

It disables the aforementioned security feature and reduces the protection of the user's data.

And is there another way to execute my CSR without adding headers on the server's side or disabling the security?

A proxy. See Ways to circumvent the same-origin policy , specifically the Reverse Proxy method .

I guess you are using AJAX requests, here is another question Ways to circumvent the same-origin policy that has a big detailed answer.

You can use a Flash object (flash doesn't have this problem)

Also about "whats the worst could happen" http://blogs.msdn.com/b/ieinternals/archive/2009/08/28/explaining-same-origin-policy-part-1-deny-read.aspx and http://en.wikipedia.org/wiki/Cross-site_scripting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM