简体   繁体   English

“style-src 'self' 'nonce-rAnd0m'” 是否比“style-src 'self' 'unsafe-inline'” 有任何安全优势?

[英]Is there any security benefit of "style-src 'self' 'nonce-rAnd0m'" over "style-src 'self' 'unsafe-inline'"?

这个页面列出了使用 nonce 比 unsafe-inline 更可取的样式,但是如果除了 style-src 之外的所有东西都使用“default-src 'self'”,那么使用 nonce 有什么好处吗?

The nonce based approach in the link you refer to is just an example, clearly you should use the nonce based approach for both styles and scripts.您引用的链接中基于随机数的方法只是一个示例,显然您应该对样式和脚本使用基于随机数的方法。

This approach is called strict CSP and the advantage with using a nonce, is that you don't need to white-list all the domains.这种方法称为严格 CSP ,使用 nonce 的优点是您不需要将所有域列入白名单。 For example, check the CSP policy for twitter.com, its huge!例如,查看 twitter.com 的 CSP 政策,它非常庞大!

The CSP for Google docs looks like this, a pretty slim policy:谷歌文档的 CSP 看起来像这样,一个非常苗条的策略:

Content-Security-Policy: 
base-uri 'self';
object-src 'none';
report-uri https://docs.google.com/document/cspreport;
script-src 'report-sample' 'nonce-Y7j7Ul3bnFVzbgVJ0-Tb7a' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval';
worker-src 'self' blob:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/”。 'unsafe-inline' 关键字,一个散列 - "style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/". Either the 'unsafe-inline' keyword, a hash 拒绝加载样式表,因为它违反了以下内容安全策略指令:“style-src 'self' 'unsafe-inline'” - Refused to load the stylesheet because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline'" CSP style-src: 'unsafe-inline' - 值得吗? - CSP style-src: 'unsafe-inline' - is it worth it? CSP-当动态放置页面元素时,如何解决style-src unsafe-inline - CSP - How to solve style-src unsafe-inline -when having dynamically positioned page elements 因为它违反了以下内容安全策略指令:“style-src'self'” - because it violates the following Content Security Policy directive: “style-src 'self'” 为什么我可以在JS中设置样式而不违反内容安全策略的style-src'self'? - Why can I set styles in JS without violating Content Security Policy's style-src 'self'? 如何在 TYPO3 10 的文件中设置安全策略指令 style-src - How to set the Security Policy directive style-src in a file for TYPO3 10 内容安全策略允许内联样式,没有不安全的内联 - Content Security Policy allow inline style without unsafe-inline 使用 Content-Security-Policy 和 JavaScript 避免 `script-src 'unsafe-inline'` - Avoiding `script-src 'unsafe-inline'` with Content-Security-Policy and JavaScript 除了在CSP策略中添加“ unsafe-inline”以添加内联样式attr之外,setAttribute()是否还有其他选择? - Is there any alternative to setAttribute() other than adding 'unsafe-inline' in CSP policy for adding inline style attr?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM