有没有办法安全地了解托管 AJAX 调用的原始服务器?

发布于 2024-10-02 20:42:08 字数 764 浏览 1 评论 0原文

让我们想象一下,站点 A 使用指向服务器 B 的标准脚本标记嵌入了一个 javascript 文件。接下来站点 A 向服务器 B 上的资源发出 JSONP 或 AJAX 请求。服务器 B 是否可以明确知道特定 JSONP 请求源自站点 A 上的用户,而不是其他站点上的用户欺骗其 HTTP REFERRER。

我认为存在任何可能性的唯一原因是站点 A 开始与其嵌入服务器 B 的 javascript 进行通信。在某种程度上,这种原始通信不能充当安全握手的角色,从而允许后续呼叫安全地通过。但是,由于握手是通过不安全的方式进行的,因此并不妨碍它充当安全握手。

关于如何完成这项任务有什么想法吗?我能想到的每一个解决方案都被 AJAX 调用的每个元素都可以伪造的概念所打破。

我读了 http://www.codinghorror。 com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html在 PHP 中检测 Ajax 并确保请求来自我自己的网站,但据我所知,他们专注于确保请求的准确性用户,而不是推荐人的真实性。

Lets imagine that site A embeds a javascript file using a standard script tag pointing to server B. Next Site A makes a JSONP or AJAX request to a resource on server B. Is there anyway for Server B to definitively know that specific JSONP request originated from a user on Site A, and not a user on another site spoofing their HTTP REFERRER.

The only reason I think there is any realm of possibility is because site A started the communication with it's embedding of server B's javascript. In a way, couldn't this original communication act as a security handshake, allowing subsequent calls to pass through securely. But because the handshake was made through insecure means doesn't that prevent it from acting as a security handshake.

Any ideas of how this task can be accomplished? Every solution I can think up is broken by the notion that every element of an AJAX call can be faked.

I read http://www.codinghorror.com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html and Detecting Ajax in PHP and making sure request was from my own website but as far as I could tell they focused on ensuring the veracity of the user and not the veracity of the referrer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

塔塔猫 2024-10-09 20:42:08

如果您希望将服务器配置为需要相互身份验证,则可以通过 https 使用 Ajax。

Ajax over https you could if you wanted configure your server to require mutual authentication.

仅此而已 2024-10-09 20:42:08

您可以使用 Hash_chain 来验证来源。

页面加载时,随机生成 X 次哈希值,并使用初始请求(脚本标签)发送最后一个哈希值,例如 Hash[100]。每个下一个请求都使用 Hash[Last-1] 发送。

在服务器 B 上检查 hash(resieved_hash) 是否与上一个相同。

You could use Hash_chain to verify origin.

On page load generate X times hash from random and send last hash with initial request (script tag) e.g. Hash[100]. every next request send with Hash[Last-1].

On server B check whether hash(resieved_hash) is same as last one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文