“self” img-src “self” 允许来自相同的来源的内容(相同的协议,域名和端口) data: img-src data: 允许data协议(如base64编码的图片) www.guangzhul.com img-src img.guangzhul.com 允许加载指定域名下的资源 *.guangzhulcom img-src: *.guangzhul.com 允许加载guangzhul.com任何子域下面的资源 “unsafe-...
1) data 这个其实就是有些时候通过data:[<mediatype>][;base64],<data>这种格式加载资源相关的限制,CSP是白名单,所以默认没有配置data的话,肯定是不允许的,因此假设我们允许通过data插入图片,我们需要进行如下CSP配置 代码语言:javascript 代码运行次数:0 运行 AI代码解释 Content-Security-Policy:img-src data:;...
* img-src * 允许任何内容。 ‘none’ img-src ‘none’ 不允许任何内容。 ‘self’ img-src ‘self’ 允许来自相同来源的内容(相同的协议、域名和端口)。 data: img-src data: 允许 data: 协议(如 base64 编码的图片)。 www.guangzhul.com img-src img.guangzhul.com 允许加载指定域名的资源。 *.gua...
'self' script-src 'self' 同源策略,即允许同域名同端口下,同协议下的请求 * img-src * 允许任意地址的图片资源 data: img-src data: 允许将data: urls作为内容,比如base64格式的图片 http://domain.example.com img-src http://domain.example.com 允许特定域名下请求资源 *.http://example.com img-src...
data:允许 data: URI 作为内容来源。 mediastream:允许 mediastream: URI 作为内容来源。 Content-Security-Policy: default-src'self'; img-src'self'data:; media-src mediastream: 举个例子: <meta http-equiv="Content-Security-Policy"content="script-src 'self'; object-src 'none'; style-src cdn.examp...
手把手教你CSP系列之 img-src HTTP Content-Security-Policy(CSP)script-src指令为JavaScript的源指定有效来源。这不仅包括直接加载到 句法 script-src政策可以允许一个或多个来源: Content-Security-Policy: script-src <source>;Content-Security-Policy: script-src <source> <source>; ...
* img-src * 允许任何内容。 ‘none’ img-src ‘none’ 不允许任何内容。 ‘self’ img-src ‘self’ 允许来自相同来源的内容(相同的协议、域名和端口)。 data: img-src data: 允许 data: 协议(如 base64 编码的图片)。 http://www.guangzhul.comimg-srchttp://img.guangzhul.com允许加载指定域名的...
手把手教你CSP系列之script-src 手把手教你CSP系列之 img-src HTTP Content-Security-Policy(CSP)style-src指令为样式表的源指定有效来源。 句法 style-src政策可以允许一个或多个来源: Content-Security-Policy: style-src <source>;Content-Security-Policy: style-src <source> <source>; ...
'self'script-src 'self'Allows loading resources from the same origin (same scheme, host and port). data:img-src 'self' data:Allows loading resources via the data scheme (eg Base64 encoded images). domain.example.comimg-srcdomain.example.comAllows loading resources from the specified domain ...
<iframe srcdoc='<script src="data:text/javascript,alert(document.domain)"></script>'></iframe> 以上CSP配置场景绕过姿势只是对日常CSP配置中可能存在的情况进行了部分总结和说明,并不能覆盖所有的CSP配置场景,CSP配置能够对XSS攻击有一定的缓解作用,但不能仅仅依赖于CSP的防护,在日常开发过程中,仍然要在服务...