我想开始在一个网站上介绍一个CSP。首先,我只添加一个报告CSP,并且只报告混合内容,例如,当一个图像从HTTP而不是HTTPS加载时。
我已经厌倦了以下三个方面:
<meta http_equiv="Content-Security-Policy-Report-Only" content="upgrade-insecure-requests; report-uri https://example.report-uri.com/r/d/csp/reportOnly"/>
<meta http_equiv="Content-Security-Policy-Report-Only" content="img-src https:; report-uri https://example.report-uri.com/r/d/csp/reportOnly">
<meta http_equiv="Content-Security-Policy-Report-Only" content="block-all-mixed-content; report-uri https://example.report-uri.com/r/d/csp/reportOnly">但是,所有这些都没有向report报告CSP违规行为。
如何创建一个CSP,仅报告从HTTP加载的内容(图像)?
发布于 2022-08-31 05:48:27
不能在HTML中添加报表-uri。您必须将报头作为http协议的一部分发送!
请参阅https://datatracker.ietf.org/doc/html/draft-gondrom-websec-csp-header#section-4
服务器应尽可能使用HTTP响应报头机制,因为在使用元元素机制时,用户代理开始处理文档时与用户代理在文档不受策略保护时遇到元元素之间有一段时间。
https://security.stackexchange.com/questions/193705
复制相似问题