CSP: child-src

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2016.

HTTP の Content-Security-Policy (CSP) における child-src ディレクティブは、ウェブワーカー<frame><iframe> などの要素を使用して読み込んだネストした閲覧コンテキストに対して有効なソースを定義しています。ワーカーでは、準拠しないリクエストは、ユーザーエージェントによって致命的なネットワークエラーとして扱われます。

CSP バージョン 2
ディレクティブ種別 フェッチディレクティブ
default-src の代替 あり。このディレクティブがない場合、ユーザーエージェントは default-src ディレクティブを探していきます。

構文

child-src ポリシーでは、1 つまたは複数のソースを許可することができます。

http
Content-Security-Policy: child-src <source>;
Content-Security-Policy: child-src <source> <source>;

ソース

<source> は、 CSP ソース値にあるいずれかの値を取ることができます。

なお、この同じ値のセットはすべてのフェッチディレクティブ(と他の多くのディレクティブ)で使用できます。

違反している場合

この CSP ヘッダーがあったとします。

http
Content-Security-Policy: child-src https://example.com/

この <iframe> とワーカーはブロックされ、読み込まれません。

html
<iframe src="https://not-example.com"></iframe>

<script>
  const blockedWorker = new Worker("data:application/javascript,…");
</script>

仕様書

Specification
Content Security Policy Level 3
# directive-child-src

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
child-src

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報