[英]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.