内容安全策略(CSP)旨在通过为开发人员提供对允许加载页面的资源以及允许执行的脚本的细粒度控制来降低跨站点脚本攻击的风险。
我正在使用 Primevue v3.51.0。我需要过渡到 CSP,但 Primevue 的工具提示仍然存在问题。它报告内联样式。 我已将以下配置添加到我的 Vue 应用程序中: ... 常量
ckEditor 5 字体和 Ident 依赖项/模块包含内联样式并违反我的 CSP
我使用 CKEditor 5 进行自定义构建,将字体和缩进模块包含到 github 上存在的基本构建中。我的 Web 环境 CSP 不允许任何内联样式或 javascript。 ...
我尝试将 Auth0 添加到我的应用程序中,该应用程序在本地运行,但当我部署到 S3 存储桶时,出现以下错误: “拒绝连接到‘https://dev-.us.auth0.com/oauth/token’,因为......
Html 错误:拒绝加载脚本,因为它违反了以下内容安全策略指令
很棒的字体未加载,请帮忙。我需要使用很棒的字体图标,但出现此错误。 拒绝加载脚本“https://use.fontawesome.com/a780df76b3.js”,因为它违反了
直接在 iframe 中设置 src 可以按预期工作 我正在尝试在此处嵌入 Sharepoint 文档。 例如 <p>直接在 iframe 中设置 src 可以正常工作</p> <p>我正在尝试在此处嵌入 Sharepoint 文档。</p> <p>例如</p> <pre><code><iframe src="https://rocketlane123-my.sharepoint.com/personal/lokeshkannan_rocketlane123_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc={8822527b-0c56-44f9-8263-40c737db903c}&amp;action=embedview" width="476px" height="288px" /> </code></pre> <p>当我在脚本中设置 src 时,它失败了</p> <pre><code><iframe id="x" width="476px" height="288px"></iframe> <script> document.getElementById('x').src = "https://rocketlane123-my.sharepoint.com/personal/lokeshkannan_rocketlane123_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc={8822527b-0c56-44f9-8263-40c737db903c}&amp;action=embedview"; </script> </code></pre> <p><a href="https://i.stack.imgur.com/MheeO.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tL01oZWVPLnBuZw==" alt=""/></a></p> <p>SharePoint 中明显会发生这种情况。所以我想在这里了解一些事情。</p> <pre><code>1. Am I doing something wrong? 2. Is there any CSP headers which block the parent from adding via JS? 3. Is there any official way from SharePoint to allow this? 3. Is there any way to hack this? </code></pre> <p>提前致谢。</p> <p>由于这种情况发生在 chrome、safari 和 firefox 上,我认为这不是特定浏览器中的错误。</p> </question> <answer tick="false" vote="2"> <p>在 Firefox 中尝试此操作会产生以下错误消息:</p> <blockquote> <p>为了保护您的安全,login.microsoftonline.com 将不允许 如果其他站点嵌入了该页面,则 Firefox 将显示该页面。查看 此页面,您需要在新窗口中打开。</p> </blockquote> <p>打开控制台会显示以下消息:</p> <blockquote> <p>“X-Frame-Options”拒绝在框架中加载 [<em>url</em>] 指令设置为“DENY”。</p> </blockquote> <p>这是由 <pre><code>login.microsoft.com</code></pre> 设置的标头,用于禁用将链接嵌入为 iframe。</p> <p>此链接详细介绍了此设计选择:<a href="https://learn.microsoft.com/en-us/sharepoint/troubleshoot/sites/cannot-display-sharepoint-pages-in-iframe" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/sharepoint/troubleshoot/sites/cannot-display-sharepoint-pages-in-iframe</a></p> <p>该链接提到您可以通过设置“AllowFraming”来覆盖该行为,但不建议这样做,因为嵌入它可能会导致网站破坏。</p> <p>可以在<a href="https://answers.microsoft.com/en-us/msoffice/forum/all/office-365-public-site-can-not-be-viewed-in-a-page/65ba2f7b-ce94-4df4-a7d1-1496f8b67dab" rel="nofollow noreferrer">此链接</a></p>找到使用此功能的指南 </answer> <answer tick="false" vote="0"> <p>问题出在 javascript 中,而不是 & 在链接中使用 & 。</p> <pre><code><body> <iframe id="x" width="476px" height="288px"></iframe> <script> document.getElementById('x').src = "https://rocketlane123.sharepoint.com/sites/MyDocsforSP/_layouts/15/Doc.aspx?sourcedoc={6d327004-5d52-4e42-9707-c964631f8e65}&action=embedview"; </script> </body> </code></pre> </answer> </body></html>
在 wso2am-4.0.0 中添加安全标头(sts & csp & Referer 标头)
我正在尝试按照我公司安全团队的指导在所有门户中添加这两个标头。到目前为止,我已经尝试在deployment.toml 中添加一些配置。这只会将 sts 标头引入...
拒绝构建“https://www.youtube.com/”,因为它违反了以下内容安全策略指令:“frame-src 'X'
我正在尝试使用 iframe 在我的网站中嵌入 YouTube 视频,在我决定开始使用 SSL 证书之前它工作得很好,然后这些 CSP 错误开始出现。 我是...
操作系统等在主机 Ubuntu 18.04.6 LTS 上的 Virtualbox 5.2.42 内的 Lubuntu 20.04 上进行开发 我正在使用 php 在本地主机上提供一个网站: php -S 0.0.0.0:8080 -t /home/alan/DEV/ 索引.html 是 操作系统等 在主机 Ubuntu 18.04.6 LTS 上的 Virtualbox 5.2.42 内的 Lubuntu 20.04 上进行开发 我正在使用 php 在本地主机上提供一个网站: php -S 0.0.0.0:8080 -t /home/alan/DEV/ index.html 是 <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="main"></div> <script src="/main.js"></script> <script src="/script.js"></script> </body> </html> Chromium 在 localhost:8080 查看页面没有问题。直到最近,Firefox 也没有。 但是,我只是尝试在 Firefox 122.0.1 上连接。页面没有任何内容显示,并且我在浏览器控制台中收到以下错误: Content-Security-Policy: The page's settings blocked the loading of a resource at data: ("media-src"). localhost:8080 Content-Security-Policy: The page's settings blocked the loading of a resource at http://localhost:8080/main.js ("script-src-elem"). localhost:8080 Content-Security-Policy: The page's settings blocked the loading of a resource at http://localhost:8080/script.js ("script-src-elem"). localhost:8080 在 Firefox 中查看 about:config,并在 content-security 上搜索,我看到以下内容: extensions.webextensions.base-content-security-policy: script-src 'self' https://* http://localhost:* http://127.0.0.1:* moz-extension: blob: filesystem: 'unsafe-eval' 'wasm-unsafe-eval' 'unsafe-inline'; extensions.webextensions.base-content-security-policy.v3: script-src 'self' 'wasm-unsafe-eval'; extensions.webextensions.default-content-security-policy: script-src 'self' 'wasm-unsafe-eval'; extensions.webextensions.default-content-security-policy.v3: script-src 'self'; upgrade-insecure-requests; 我尝试将 <meta http-equiv="Content-Security-Policy" content="default-src 'self'"> 添加到我的 index.html 文件的头部,但这没有什么区别(除了它部分搞乱了 Chromium 上的页面布局)。 经过进一步调查,我发现主机系统上的 Firefox 113.0.2 确实 显示了我的网站。但是,在主机系统上,我必须使用 IP 地址 192.168.2.23:8080 而不是 localhost:8080。使用 IP 地址也适用于本地系统。
启用 HTTPOnly 和 CSP 时使用 XSS 窃取 Cookie:解决方法和策略
当 HTTPOnly 开启且定义了 CSP 规则时,如何窃取 cookie?假设攻击者获得了一个执行 HTTP 的输入字段,并且该输入字段容易受到 XSS 攻击: 当 HTTPOnly 开启且定义了 CSP 规则时,如何窃取 cookie?假设攻击者获得了一个执行 HTTP 的输入字段,并且该输入字段容易受到 XSS 攻击: <form action="/createThread?topic={{lcTopic}}" method="post" class=""> <h2 class="text-muted">New Thread</h2> <hr> <div class="form-group"> <label>Body</label> <textarea type="text" rows="10" class="form-control" name="body" placeholder="Type the body of your thread here..."></textarea> </div> <button type="submit" class="btn btn-primary">Create Thread</button> <button type="button" id="threadPreview" class="btn btn-default">Preview</button> </form>` 在我的服务器中,我将 CSP 规则定义为: .use( helmet.contentSecurityPolicy({ directives: { defaultSrc: ["'self'"], scriptSrc: [ "'self'", "cdnjs.cloudflare.com" ], }, }) ) 攻击者可能通过将以下代码注入文本字段来绕过 CSP: <!DOCTYPE html> <html> <head> <title>XSS Demo</title> <SCRIPT src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.7.2/prototype.js"></SCRIPT> <SCRIPT src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.8/angular.js"></SCRIPT> </head> <body ng-app ng-csp> <div> <button ng-click="$on.curry.call().alert('xss')">Click Me! </button> <div style="display:none;"> {{$on.curry.call().alert('xss')}} </div> </div> </body> </html> 现在,由于启用了 HTTPOnly,攻击者无法简单地执行“alert(document.cookie)”。考虑到 CSP 规则,他们还可以采用哪些其他方法来窃取 cookie? 我尝试了一个简单的警报(document.cookie),但由于 HTTPOnly 而不起作用: HTTP/1.1 200 OK X-Powered-By: Express Content-Security-Policy: default-src 'self';script-src 'self' cdnjs.cloudflare.com;base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests Content-Type: text/html; charset=utf-8 Content-Length: 5924 ETag: W/"1724-zhGBtITbjmwCa+un6GYhGKL+lwo" Set-Cookie: connect.sid=THE COOKIE; Path=/; HttpOnly Date: Sat, 27 Apr 2024 09:29:04 GMT Connection: close 我什至尝试这样做: {{$on.curry.call().eval("var url = '/'; fetch(url).then(response => console.log(response.headers.get('Set-Cookie')))")}} 但是自从 CSP 我得到: angular.js:5930 EvalError:拒绝将字符串评估为 JavaScript,因为“unsafe-eval”不是以下内容安全策略指令中允许的脚本源:“script-src 注意:攻击者显然不允许更改服务器代码!他只能访问输入字段! 在这种情况下,攻击者无法从cookie中获取价值。 因为,HttpOnly 已激活。 这个活动是对的。 如果你成功执行JavaScriptalert(),你应该降级Web浏览器并重新攻击。
我正在尝试更好地了解内容安全策略。我的理解是,它们是向浏览器发出的指令,指示允许从何处加载页面的某些部分 - 图像,...
Heroku 附加 Edge CDN 覆盖 Content-Security-Policy 标头
我目前通过 Heroku 提供我的 Shopify 应用程序。 由于 Shopify 应用程序是在商家后台的 iframe 中加载的,因此要求之一是正确设置 Content-Security-Policy 标题...
Stripe js 脚本违反了所有 unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' 和 'self' 指令怎么可能?
您好,我正在尝试将条纹支付集成到我的 ASP.NET 8 页项目中,尽管我允许不安全的指令,但我还是收到了此错误,缺少这些指令可能是问题的原因,但仍然...
拒绝从“blob:https://x/6a...293”创建工作线程,因为它违反了以下内容安全策略指令
我有 Blazor Web 程序集应用程序(客户端 + 服务器)并保持拒绝创建工作线程,因为它违反了以下 CSP 指令。 它可以在本地运行,但是当我尝试发布我的应用程序时......
为什么web.config中的Content-Security-Policy设置没有效果?
在一个小型 ASP.NET MVC 测试应用程序中,我将适当的 httpProtocol 代码添加到 web.config 文件中,如本文所述: 在一个小型 ASP.NET MVC 测试应用程序中,我将适当的 httpProtocol 代码添加到 web.config 文件中,如本文中所述: <system.webServer> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> <httpProtocol> <customHeaders> <add name="Content-Security-Policy" value="default-src 'self'" /> </customHeaders> </httpProtocol> </system.webServer> 但是,在应用程序的测试页面上,Vue.js 代码仍然有效,因为它是从 CDN 加载的,所以内容安全策略应该阻止它。 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Home Page2 - Meine ASP.NET-Anwendung</title> <link href="/Content/bootstrap.css" rel="stylesheet"/> <link href="/Content/site.css" rel="stylesheet"/> <script src="/Scripts/modernizr-2.6.2.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script> </head> <body> <div class="container mainMenu"> <ul> <li><a href="/">Start Page</a></li> <li><a href="/Home/About">About</a></li> <li><a href="/Home/Contact">Contact</a></li> <li><a href="/Home/Info">Info</a></li> </ul> </div> <div class="container body-content"> <hr/> <div id="app"> this is a test: <b>{{message}}</b> </div> <script> var app = new Vue({ el: '#app', data: { message: 'Vue.js ready' } }); </script> <hr/> <footer> <p>The footer</p> </footer> </div> <script src="/Scripts/jquery-1.10.2.js"></script> <script src="/Scripts/bootstrap.js"></script> <script src="/Scripts/respond.js"></script> </body> </html> 我需要做什么才能使内容安全策略在我的网站中真正生效? 附录 我可以在我的开发工具中看到,内容安全策略没有在响应标头中发送: 看到您问题中下面的配置块,让我假设您已将 <httpProtocol><customHeaders> ... 部分添加到 web.config 文件夹中的 Views 文件,而不是网站根目录中的 web.config 文件。 <system.webServer> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer>
Dojo 解析器:当不允许使用 unsafe-eval 的 CSP 时,new Function() 会抛出错误
我们使用 Dojo v1.17.3 和内容安全策略(不允许使用 unsafe-eval。 当定义 onclick 时,下面的行会给出解析器错误。 如果没有 onclick,上面的行工作正常。 错误详情 : 电子...
我们已经使用Java过滤器类实现了在Angular中添加CSP标头的代码。在角度方面,我们也实现了shared_styles_hosts.ts。现在,我们可以看到 CSP 标头,但是
在 Firefox 中我收到以下错误: 内容安全策略:页面的设置阻止加载数据处的资源:(“media-src”)。 我不确定为什么我在主持时会收到此错误...
作为 FLP 中启用“异步模块加载”准备工作的一部分,其先决条件之一是确保不会因 HTML 文档被加载而触发 eval 调用...
实现 jekyll-content-security-policy-generator —— 不生成 CSP
我正在尝试使用 jekyll-content-security-policy-generator gem 将 CSP 元标记添加到 Jekyll 站点,但它似乎不起作用。按照说明,我添加了 jekyll-content-
我正在尝试在新网站上实施内容安全政策。我可以看到 Chrome 的网络选项卡中设置了以下 HTTP 标头。 内容安全策略:默认 src 'self' https: 怎么...