host/domain 缺少 protocol/scheme 内容安全策略,它安全吗?

content security policy missing protocol/scheme for host/domain, is it secure?

我得到了这个 CSP:

Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline' fonts.googleapis.com; frame-src 'self'; font-src data: fonts.gstatic.com 'self'; frame-ancestors 'self';

例如,fonts.googleapis.com 没有方案或协议(https:不存在)。它是否自动意味着它已超过安全 HTTP(如果当前 page/source 是)?它会容易受到 MiTM 攻击吗?我认为文档对我来说不清楚(Google 的 CSP 评估器说 'Good')

Does it automatically mean that it is over secure HTTPs (if the current page/source is)?

是的,无方案主机源意味着浏览器将遵循同源策略来恢复实际方案。
因此,如果通过 HTTPS 加载页面 - CSP 中的所有无方案主机源都获得 https:// 方案。
在 HTTP 页面上,CSP 中的所有无方案主机源都获得 http:// 方案,所有细节都是 here.

And would it be vulnerable to MiTM attacks?

它只在 HTTP 页面上容易受到攻击。任何 HTTP 页面都容易受到 MiTM 的攻击,许多俄罗斯 ISP still injects their Ads 使用 HTTP 上的 MiTM 进入客户访问的页面。

您为什么不担心 'self' 使用情况? 'self' 在 HTTP 页面上表示 http://example.com,在 HTTPS 页面上表示 https://example.com。所以它和无计划的fonts.googleapis.com用法一样容易受到攻击。

顺便说一句为什么在2021年从Google的CDN加载字体?这会减慢网站速度:1, 2 and do not cached by browsers. Use https://google-webfonts-helper.herokuapp.com/fonts 提取字体并将其存储在本地,然后使用 <link rel="preload" as="font" ... 预加载。