Skip to content

img-src

img-src specifies valid sources for images and favicons.

It is usually the noisiest fetch directive on a real site, because images come from everywhere: a CMS, a CDN, an avatar service, an analytics pixel, and data: URIs inlined by a build step.

Content-Security-Policy: img-src 'none';
Content-Security-Policy: img-src <source-expression-list>;
  • <img>, and image requests made by the document generally, including favicons.

If img-src is absent, the browser consults default-src. The full chain is img-srcdefault-src.

Content-Security-Policy: img-src 'self' data:
  • data: has to be listed explicitly - it is not covered by 'self', and inlined SVGs and build-time image placeholders are the usual reason a strict img-src breaks a page.
  • Resist img-src https:, which allows every image host on the web. It is a common shortcut and it removes most of the directive’s value; an allowlist of the four hosts you actually use is not much longer.

An inlined placeholder, under img-src 'self' data::

<img src="data:image/svg+xml;base64,PHN2ZyB…" alt="" />

Under img-src 'self', a third-party pixel:

<img src="https://pixel.analytics.example/p.gif?id=42" width="1" height="1" />
  • Widely available across browsers since August 2016.
Field Value
violatedDirective img-src
effectiveDirective img-src
blockedUri https://pixel.analytics.example/p.gif, data
Issue title img-src blocking pixel.analytics.example
  • blockedUri: "data" is one issue for the whole site: HeaderHawk groups every data: violation under one signature per directive, because they are one decision - list data: or do not.
  • A long tail of one-off image hosts on this directive is usually user-generated content, not an attack. The noise classifier tags browser-extension origins, but a CMS embedding arbitrary hosts looks like real traffic because it is.

Point your policy’s report-uri at your site’s HeaderHawk endpoint and the violations above arrive in the dashboard, grouped as described. The Quick Start sets that up in five minutes, and the integration guides cover the header syntax for each platform.