weixin_33696822 2016-05-21 13:15 采纳率: 0%
浏览 32

同源政策解决方案

I see the security risks with cross domain ajax calls,
but I think the real problem are the cookies that the browsers
automatically send to the target cross domain.

So why can't browser just not send cookies in the case of cross domain js request instead of blocking that request altogether ?

I hope my question makes sense.

EDIT:

from: https://en.wikipedia.org/wiki/Same-origin_policy

While this is true, the JavaScript has no direct access to the banking session cookie, but it could still send and receive requests to the banking site with the banking site's session cookie, essentially acting as a normal user of the banking site. Regarding the sending of new transactions, even CSRF protections by the banking site have no effect, because the script can simply do the same as the user would do

So Suppose I'm logged on facebook and meanwhile visiting a mslicious site that use cross site requests to facebook to steal information about me, I mean the only reason it could do it is because a legitimate cookie is included in the requests by the browser, am I wrong ?

  • 写回答

1条回答 默认 最新

  • weixin_33701617 2016-05-21 14:10
    关注

    You have a confusion of ideas.

    A cookie is simply a cached information that is stored on the client side. Simply put it is data that is managed by the browser and how particular browser does it is their doing. For example IE stores cookies in separate text files, Firefox uses a single file and Crome uses SQLite3 database.

    I recommend you read: Why is the same origin policy important?

    You can send cross domain Get requests and there are several ways. I have used a proxy that adds the required headers or just Jsonp. For example in .net latter requires you to add a json formatter that gets the json callback function.

    If you have 2-way communication with the web page none of this is required. You can manage the state at server side and do server side "push" request at your will. Before html5, you needed components to do that ex: java applet, flash, silverlight or ....

    I hope my answer makes sense to you.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?