gpt4 book ai didi

web - 为什么同源策略会阻止读取 GET 响应?

转载 作者:行者123 更新时间:2023-12-04 15:31:17 27 4
gpt4 key购买 nike

我在网上做了一些研究,并搜索了一些关于 SOP 及其减轻的滥用类型的问题,但大多数答案都集中在防止凭据被盗上。这对我来说很有意义。

对我来说没有意义的是为什么遵循 SOP 规则的浏览器会完全阻止响应,而不是阻止 cookie 和本地存储访问。

换句话说,如果 cookie 和本地存储不存在,是否仍然需要阻止读取 GET 响应?大概这已经在某种程度上发生在 <img> 上。 , <script> , 和 <iframe> .

最佳答案

根据 Mozilla Developer Network :

The same-origin policy restricts how a document or script loaded from one origin can interact with a resource from another origin. It is a critical security mechanism for isolating potentially malicious documents.


根据 RFC 6454 :

Although user agents group URIs into origins, not every resource inan origin carries the same authority (in the security sense of theword "authority", not in the [RFC3986] sense). For example, an imageis passive content and, therefore, carries no authority, meaning theimage has no access to the objects and resources available to itsorigin. By contrast, an HTML document carries the full authority ofits origin, and scripts within (or imported into) the document canaccess every resource in its origin.


为了回答您的问题,即使 cookie 和本地存储不存在,在文档上下文中执行未知脚本仍然是危险的。这些脚本可能会使用与授权脚本相同的 IP 发出 XHR 请求,并且表现不佳。

关于web - 为什么同源策略会阻止读取 GET 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41192058/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com