1. <tfoot id='cEDIU'></tfoot>

      1. <i id='cEDIU'><tr id='cEDIU'><dt id='cEDIU'><q id='cEDIU'><span id='cEDIU'><b id='cEDIU'><form id='cEDIU'><ins id='cEDIU'></ins><ul id='cEDIU'></ul><sub id='cEDIU'></sub></form><legend id='cEDIU'></legend><bdo id='cEDIU'><pre id='cEDIU'><center id='cEDIU'></center></pre></bdo></b><th id='cEDIU'></th></span></q></dt></tr></i><div id='cEDIU'><tfoot id='cEDIU'></tfoot><dl id='cEDIU'><fieldset id='cEDIU'></fieldset></dl></div>

          <bdo id='cEDIU'></bdo><ul id='cEDIU'></ul>

        <small id='cEDIU'></small><noframes id='cEDIU'>

      2. <legend id='cEDIU'><style id='cEDIU'><dir id='cEDIU'><q id='cEDIU'></q></dir></style></legend>

        设置 Access-Control-Allow-Origin 接受所有域存在哪些安

        时间:2023-09-03

          <tbody id='AdwcX'></tbody>
      3. <legend id='AdwcX'><style id='AdwcX'><dir id='AdwcX'><q id='AdwcX'></q></dir></style></legend>

      4. <tfoot id='AdwcX'></tfoot>

            1. <i id='AdwcX'><tr id='AdwcX'><dt id='AdwcX'><q id='AdwcX'><span id='AdwcX'><b id='AdwcX'><form id='AdwcX'><ins id='AdwcX'></ins><ul id='AdwcX'></ul><sub id='AdwcX'></sub></form><legend id='AdwcX'></legend><bdo id='AdwcX'><pre id='AdwcX'><center id='AdwcX'></center></pre></bdo></b><th id='AdwcX'></th></span></q></dt></tr></i><div id='AdwcX'><tfoot id='AdwcX'></tfoot><dl id='AdwcX'><fieldset id='AdwcX'></fieldset></dl></div>

                <small id='AdwcX'></small><noframes id='AdwcX'>

                  <bdo id='AdwcX'></bdo><ul id='AdwcX'></ul>
                • 本文介绍了设置 Access-Control-Allow-Origin 接受所有域存在哪些安全风险?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我最近不得不将 Access-Control-Allow-Origin 设置为 * 以便能够进行跨子域 AJAX 调用.我觉得这可能是一个安全问题.如果我保留该设置,我会面临哪些风险?

                  I recently had to set Access-Control-Allow-Origin to * in order to be able to make cross-subdomain AJAX calls. I feel like this might be a security problem. What risks am I exposing myself to if I keep the setting?

                  推荐答案

                  Access-Control-Allow-Origin: * 可以完全安全地添加到任何资源中,除非该资源包含受标准凭据以外的东西保护的私有数据.标准凭据是 cookie、HTTP 基本身份验证和 TLS 客户端证书.

                  Access-Control-Allow-Origin: * is totally safe to add to any resource, unless that resource contains private data protected by something other than standard credentials. Standard credentials are cookies, HTTP basic auth, and TLS client certificates.

                  想象一下https://example.com/users-private-data,这可能会根据用户的登录状态暴露私人数据.此状态使用会话 cookie.将 Access-Control-Allow-Origin: * 添加到此资源是安全,因为此标头仅允许在没有 cookie 的请求和 cookie 的情况下访问响应需要获取私有数据.因此,不会泄露任何私人数据.

                  Imagine https://example.com/users-private-data, which may expose private data depending on the user's logged in state. This state uses a session cookie. It's safe to add Access-Control-Allow-Origin: * to this resource, as this header only allows access to the response if the request is made without cookies, and cookies are required to get the private data. As a result, no private data is leaked.

                  想象一下 https://intranet.example.com/company-private-data,它会公开公司的私人数据,但只有在公司的 wifi 网络上才能访问.将 Access-Control-Allow-Origin: * 添加到此资源是不安全,因为它使用标准凭据以外的其他方式进行保护.否则,错误的脚本可能会将您用作通往 Intranet 的隧道.

                  Imagine https://intranet.example.com/company-private-data, which exposes private company data, but this can only be accessed if you're on the company's wifi network. It's not safe to add Access-Control-Allow-Origin: * to this resource, as it's protected using something other than standard credentials. Otherwise, a bad script could use you as a tunnel to the intranet.

                  想象一下,如果用户在隐身窗口中访问资源,他们会看到什么.如果您对看到此内容的所有人(包括浏览器收到的源代码)感到满意,则可以安全地添加 Access-Control-Allow-Origin: *.

                  Imagine what a user would see if they accessed the resource in an incognito window. If you're happy with everyone seeing this content (including the source code the browser received), it's safe to add Access-Control-Allow-Origin: *.

                  这篇关于设置 Access-Control-Allow-Origin 接受所有域存在哪些安全风险?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:CORS POST 请求可以使用纯 JavaScript,但为什么不使 下一篇:跨域读阻塞 (CORB)

                  相关文章

                  最新文章

                  <small id='xHqGg'></small><noframes id='xHqGg'>

                  <i id='xHqGg'><tr id='xHqGg'><dt id='xHqGg'><q id='xHqGg'><span id='xHqGg'><b id='xHqGg'><form id='xHqGg'><ins id='xHqGg'></ins><ul id='xHqGg'></ul><sub id='xHqGg'></sub></form><legend id='xHqGg'></legend><bdo id='xHqGg'><pre id='xHqGg'><center id='xHqGg'></center></pre></bdo></b><th id='xHqGg'></th></span></q></dt></tr></i><div id='xHqGg'><tfoot id='xHqGg'></tfoot><dl id='xHqGg'><fieldset id='xHqGg'></fieldset></dl></div>
                    <bdo id='xHqGg'></bdo><ul id='xHqGg'></ul>

                    1. <legend id='xHqGg'><style id='xHqGg'><dir id='xHqGg'><q id='xHqGg'></q></dir></style></legend>

                    2. <tfoot id='xHqGg'></tfoot>