Content Security Policy: 数据: 是否应用于img-src源列表中的所有项目?

huangapple go评论49阅读模式
英文:

Content Security Policy: Is data: applied to all items in the img-src source list?

问题

我正在尝试确定我的内容安全策略是否可以允许数据图像,例如base64编码的PNG(CSS代码),只允许 'self',还是必须适用于列表中的所有来源。我找不到任何告诉我data:适用于什么的文档。我假设它适用于整个源列表。有人能确认吗?

img-src 'self' https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://ajax.googleapis.com https://www.google-analytics.com https://www.googletagmanager.com data:;

我也在尝试确定这个img-src是否存在安全问题。感谢任何评论。

英文:

I've got a content security policy and I'm trying to determine if I can allow data images, such as base 64 encoded PNG's (CSS code), to just 'self' or if it must apply to all sources in the list. I can't find any documentation that tells me what data: is applied to. I assume then it's applied to the entire source list. Can anyone confirm?

img-src 'self' https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://ajax.googleapis.com https://www.google-analytics.com https://www.googletagmanager.com data:;

I'm also trying to determine if there is any security concerns with this img-src. Thank you for any comments.

答案1

得分: 1

'self'data: 都是。它们彼此不适用,都适用于指令(在这种情况下是 img-src)。

英文:

'self' and data: are both values. Neither apply to each other. Both apply to directives (in this case img-src).

答案2

得分: 1

Images are typically not a security threat by themselves, particularly when they are loaded as data: in an allowlisted CSS file. It could be a way to smuggle a script, but images don't carry the same risk.

Images could potentially carry malicious content, but the main reason to restrict img-src would be to prevent data exfiltration in image URLs. This would not apply to the data scheme.

英文:

Images are typically not a security threat by themselves, particularly when they are loaded as data: in an allowlisted CSS file. It could be a way to smuggle a script, but images don't carry the same risk.

Images could potentially carry malicious content, but the main reason to restrict img-src would be to prevent data exfiltration in image URLs. This would not apply to the data scheme.

huangapple
  • 本文由 发表于 2023年5月23日 00:09:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308077.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定