diff options
Diffstat (limited to 'files/ja/web/http/headers/content-security-policy')
23 files changed, 2622 insertions, 0 deletions
diff --git a/files/ja/web/http/headers/content-security-policy/base-uri/index.html b/files/ja/web/http/headers/content-security-policy/base-uri/index.html new file mode 100644 index 0000000000..95e5a39ca6 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/base-uri/index.html @@ -0,0 +1,108 @@ +--- +title: 'CSP: base-uri' +slug: Web/HTTP/Headers/Content-Security-Policy/base-uri +tags: + - CSP + - Directive + - Document directive + - HTTP + - Security +translation_of: Web/HTTP/Headers/Content-Security-Policy/base-uri +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP {{HTTPHeader("Content-Security-Policy")}} の <strong><code>base-uri</code></strong> ディレクティブは、ドキュメントの要素 {{HTMLElement("base")}} で、使用できる URL を制限します。この値が存在しない場合は、任意の URI が許可されます。このディレクティブが存在しない場合、ユーザーエージェントは、{{HTMLElement("base")}} 要素の値を使用します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP version</th> + <td>2</td> + </tr> + <tr> + <th scope="row">Directive type</th> + <td>{{Glossary("Document directive")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} fallback</th> + <td>設定しないと、任意の URL が許可されます。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p>1 つまたは複数のソースを base-uri ポリシーに使用:</p> + +<pre class="syntaxbox">Content-Security-Policy: base-uri <source>; +Content-Security-Policy: base-uri <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>このディレクティブは他の CSP ディレクティブと同じ引数を使用しますが、キーワードの <code>'unsafe-inline'</code> や <code>'strict-dynamic'</code> などは意味がありません。</p> + +<p>{{page("ja/docs/Web/HTTP/Headers/Content-Security-Policy/default-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Meta_tag_configuration" name="Meta_tag_configuration">Meta タグの設定</h3> + +<pre class="brush: html"><meta http-equiv="Content-Security-Policy" content="base-uri 'self'"></pre> + +<h3 id="Apache_configuration" name="Apache_configuration">Apache の設定</h3> + +<pre class="brush: bash"><IfModule mod_headers.c> +Header set Content-Security-Policy "base-uri 'self'"; +</IfModule></pre> + +<h3 id="Nginx_configuration" name="Nginx_configuration">Nginx の設定</h3> + +<pre class="brush: bash">add_header Content-Security-Policy "base-uri 'self';"</pre> + +<h3 id="Violation_case" name="Violation_case">違反になる場合</h3> + +<p>ドメインが <code>example.com</code> でないので、<code>https://example.com</code> に設定された {{HTMLElement("base")}} 要素の <code>href</code> が CSP 違反になります。</p> + +<pre class="brush: html; example-bad"><meta http-equiv="Content-Security-Policy" content="base-uri 'self'"> +<base href="https://example.com/"> + +// Error: Refused to set the document's base URI to 'https://example.com/' +// because it violates the following Content Security Policy +// directive: "base-uri 'self'"</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + <tr> + <td>{{specName("CSP 3.0", "#directive-base-uri", "base-uri")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更無し</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-base-uri", "base-uri")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.headers.csp.base-uri")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPheader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("base")}}</li> + <li>{{domxref("Node.baseURI")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/block-all-mixed-content/index.html b/files/ja/web/http/headers/content-security-policy/block-all-mixed-content/index.html new file mode 100644 index 0000000000..534a71ec82 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/block-all-mixed-content/index.html @@ -0,0 +1,72 @@ +--- +title: 'CSP: block-all-mixed-content' +slug: Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Mixed Content + - Reference + - Security + - block-all-mixed-content + - セキュリティ + - ディレクティブ + - 混合コンテンツ +translation_of: Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) <code><strong>block-all-mixed-content</strong></code> ディレクティブは、ページが HTTPS を使用しているときに HTTP で資産を読み込むことを防ぎます。</p> + +<p>能動的および受動的の両方を含む、すべての<a href="/ja/docs/Web/Security/Mixed_content">混合コンテンツ</a>リソースのリクエストがブロックされます。これは {{HTMLElement("iframe")}} の文書にも適用され、ページ全体で混合コンテンツがないことを保証します。</p> + +<p class="note">{{CSP("upgrade-insecure-requests")}} ディレクティブが <code>block-all-mixed-content</code> の前に評価されます。前者が設定されていれば、後者は何もしません。どちらかのディレクティブを設定してください。 HTTP にリダイレクトした後で HTTPS を強制することができない古いブラウザーで HTTPS を強制させたくない限り、両方の効果はありません。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">Content-Security-Policy: block-all-mixed-content;</pre> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="notranslate">Content-Security-Policy: block-all-mixed-content; + +<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> +</pre> + +<p>もっと細かい水準で資産の http を禁止するには、個別のディレクティブを <code>https:</code> に設定することができます。安全ではない HTTP の画像を許可しないようにするには次のようにします。</p> + +<pre class="notranslate">Content-Security-Policy: img-src https:</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("Mixed Content", "#block-all-mixed-content", "block-all-mixed-content")}}</td> + <td>{{Spec2('Mixed Content')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.block-all-mixed-content")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{CSP("upgrade-insecure-requests")}}</li> + <li><a href="/ja/docs/Web/Security/Mixed_content">混合コンテンツ</a></li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/connect-src/index.html b/files/ja/web/http/headers/content-security-policy/connect-src/index.html new file mode 100644 index 0000000000..6557b4e671 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/connect-src/index.html @@ -0,0 +1,130 @@ +--- +title: 'CSP: connect-src' +slug: Web/HTTP/Headers/Content-Security-Policy/connect-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Reference + - Security + - connect-src + - source + - セキュリティ + - ディレクティブ +translation_of: Web/HTTP/Headers/Content-Security-Policy/connect-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>connect-src</strong></code> ディレクティブは、スクリプトインターフェイスを使用して読み込むことができる URL を制限します。以下の API が制限の対象となります。</p> + +<ul> + <li>{{HTMLElement("a")}} の {{htmlattrxref("ping", "a")}} 属性</li> + <li>{{domxref("Fetch")}}</li> + <li>{{domxref("XMLHttpRequest")}}</li> + <li>{{domxref("WebSocket")}}</li> + <li>{{domxref("EventSource")}}</li> + <li>{{domxref("Navigator.sendBeacon()")}}</li> +</ul> + +<div class="note"> +<p><strong>注:</strong> <code>connect-src 'self'</code> はすべてのブラウザーで websocket スキーマを解決するわけではありません、詳細はこちら: <a href="https://github.com/w3c/webappsec-csp/issues/7">https://github.com/w3c/webappsec-csp/issues/7</a></p> +</div> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p>connect-src ポリシーには、1 つ以上のソースが許可されています。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: connect-src <source>; +Content-Security-Policy: connect-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/default-src", "common_sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反の場合</h3> + +<p>以下の CSP ヘッダーを指定した場合、</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: connect-src https://example.com/</pre> + +<p>以下のコネクションはブロックされ、読み込まれません。</p> + +<pre class="brush: html notranslate"><a ping="https://not-example.com"> + +<script> + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'https://not-example.com/'); + xhr.send(); + + var ws = new WebSocket("https://not-example.com/"); + + var es = new EventSource("https://not-example.com/"); + + navigator.sendBeacon("https://not-example.com/", { ... }); +</script></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-connect-src", "connect-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-connect-src", "connect-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.connect-src")}}</p> + +<h2 id="Compatibility_notes" name="Compatibility_notes">互換性のメモ</h2> + +<ul> + <li>Firefox 23 以前では、<code>xhr-src</code> が <code>connect-src</code> ディレクティブの代わりに、{{domxref("XMLHttpRequest")}} を制限するだけのために使用されていました。</li> +</ul> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("a")}} の {{htmlattrxref("ping", "a")}} 属性</li> + <li>{{domxref("Fetch")}}</li> + <li>{{domxref("XMLHttpRequest")}}</li> + <li>{{domxref("WebSocket")}}</li> + <li>{{domxref("EventSource")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/default-src/index.html b/files/ja/web/http/headers/content-security-policy/default-src/index.html new file mode 100644 index 0000000000..bd529cb56d --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/default-src/index.html @@ -0,0 +1,183 @@ +--- +title: 'CSP: default-src' +slug: Web/HTTP/Headers/Content-Security-Policy/default-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Reference + - Security + - default + - default-src + - source + - コンテンツセキュリティポリシー +translation_of: Web/HTTP/Headers/Content-Security-Policy/default-src +--- +<div>{{HTTPSidebar}}</div> + +<p><span class="seoSummary">HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) <strong><code>default-src</code></strong> ディレクティブは、他の CSP {{Glossary("fetch directive", "フェッチディレクティブ")}}のフォールバックとして提供します。</span>以下のディレクティブがいずれかが存在しないと、ユーザーエージェントは <code>default-src</code> ディレクティブを探して、この値を使用します。</p> + +<ul> + <li>{{CSP("child-src")}}</li> + <li>{{CSP("connect-src")}}</li> + <li>{{CSP("font-src")}}</li> + <li>{{CSP("frame-src")}}</li> + <li>{{CSP("img-src")}}</li> + <li>{{CSP("manifest-src")}}</li> + <li>{{CSP("media-src")}}</li> + <li>{{CSP("object-src")}}</li> + <li>{{CSP("prefetch-src")}}</li> + <li>{{CSP("script-src")}}</li> + <li>{{CSP("script-src-elem")}}</li> + <li>{{CSP("script-src-attr")}}</li> + <li>{{CSP("style-src")}}</li> + <li>{{CSP("style-src-elem")}}</li> + <li>{{CSP("style-src-attr")}}</li> + <li>{{CSP("worker-src")}}</li> +</ul> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>default-src</code> ポリシーには、1つまたは複数のソースが許可されています。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: default-src <source>; +Content-Security-Policy: default-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<div id="common_sources"> +<p><source> は以下のうちの一つを取ることができます。</p> + +<dl> + <dt><host-source></dt> + <dd>ホスト名または IP アドレスによるインターネットホストで、任意で <a href="/ja/docs/URIs_and_URLs">URL スキーム</a>やポート番号を付けることができます。サイトのアドレスはワイルドカード (アスタリスク文字、<code>'*'</code>) で始めることができ、更にポート番号にワイルドカード (<code>'*'</code>) を使ってすべての有効なポート番号をソースとして示すことができます。<br> + 例: + <ul> + <li><code>http://*.example.com</code>: <code>http:</code> のスキームを使用した、example.com のすべてのサブドメインからのすべての読み込みの試行に一致します。</li> + <li><code>mail.example.com:443</code>: mail.example.com の 443番ポートへのアクセスの試行に一致します。</li> + <li><code>https://store.example.com</code>: <code>https:</code> を使用した store.example.com へのアクセスの試行に一致します。</li> + <li><code>*.example.com</code>: 現在のプロトコルを使用した example.com のすべてのサブドメインからの読み込みのすべての試行に一致します。</li> + </ul> + </dd> + <dt><scheme-source></dt> + <dd><code>http:</code> または <code>https:</code> のようなスキームです。コロンは必要です。以下の他の値とは異なり、単一引用符は使用しないでください。data スキームも指定することができます (非推奨)。 + <ul> + <li><code>data:</code> コンテンツのソースとして <a href="/ja/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"><code>data:</code> の URI</a> を使うことができるようにします。<em>これは安全ではありません。攻撃者は任意の data: URI を挿入することもできます。使用は控え、スクリプトには絶対に使用しないでください。</em></li> + <li><code>mediastream:</code> <a href="/ja/docs/Web/API/MediaStream_API"><code>mediastream:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + <li><code>blob:</code> <a href="/ja/docs/Web/API/Blob"><code>blob:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + <li><code>filesystem:</code> <a href="/ja/docs/Web/API/FileSystem"><code>filesystem:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + </ul> + </dd> + <dt><code>'self'</code></dt> + <dd>保護された文書が提供されたオリジンを、同じ URL スキームおよびポート番号で参照します。単一引用符が必要です。ブラウザーによっては source ディレクティブから <code>blob</code> および <code>filesystem</code> を独自に除外していることがあります。これらのコンテンツ種別を許可する必要があるサイトは、Data 属性を使用して指定することができます。</dd> + <dt><code>'unsafe-eval'</code></dt> + <dd>文字列からコードを生成する <code>eval()</code> および同様のメソッドの利用を許可します。単一引用符が必要です。</dd> + <dt id="unsafe-hashes"><code>'unsafe-hashes'</code></dt> + <dd>特定のインラインの<a href="/ja/docs/Web/Guide/Events/Event_handlers">イベントハンドラー</a>を許可します。インラインイベントハンドラーを許可したいが、インラインの {{HTMLElement("script")}} 要素や <code>javascript:</code> URL は不要な場合、これは <code>unsafe-inline</code> を使うよりも安全なメソッドです。</dd> + <dt><code>'unsafe-inline'</code></dt> + <dd>インラインの {{HTMLElement("script")}} 要素、<code>javascript:</code> の URL、インラインイベントハンドラー、インライン {{HTMLElement("style")}} 要素のような、インラインリソースの使用を許可します。単一引用符が必要です。</dd> + <dt><code>'none'</code></dt> + <dd>空のセットを参照します。つまり、一致する URL はありません。単一引用符が必要です。</dd> + <dt>'nonce-<base64-value>'</dt> + <dd>暗号化ノンス (一度だけ使われる数値) を使用する特定のインラインスクリプトのための許可リストです。サーバーはポリシーを転送するたびに固有のノンスを生成する必要があります。リソースのポリシーを回避することを難しくするため、推測できないノンスを提供することが重要です。例えば<a href="/ja/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script">安全でないインラインスクリプト</a>を参照してください。ノンスを指定すると、最近のブラウザーは、ノンスの対応がない古いブラウザーのために設定されている可能性がある <code>'unsafe-inline'</code> を無視するようになります。</dd> + <dt>'<hash-algorithm>-<base64-value>'</dt> + <dd>スクリプトまたはスタイルの sha256, sha384, sha512 の何れかのハッシュです。このソースは、ハッシュを生成するために使用する暗号化アルゴリズムと、スクリプトまたはスタイルのハッシュを base64 でエンコードしたものの二つの部分をダッシュで区切ったもので構成されます。ハッシュを生成するときは、<script> または <style> タグを含めないようにし、大文字・小文字の区別と、ホワイトスペースの扱い (先頭や末尾のホワイトスペースを含む) に注意してください。例えば<a href="/ja/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script">安全でないインラインスクリプト</a>を参照してください。 CSP 2.0 では、これはインラインスクリプトにのみ適用されます。 CSP 3.0 では <code>script-src</code> で外部スクリプトが指定された場合にも利用できます。</dd> +</dl> +</div> + +<div id="strict-dynamic"> +<dl> + <dt>'strict-dynamic'</dt> + <dd><code>strict-dynamic</code> ソース表現は、ノンスやハッシュを付加して、それらがルートスクリプトに読み込まれるすべてのスクリプトに伝搬することで、マークアップ内のスクリプトに明示的な信用を指定します。それと同時に、<code>'self'</code> や <code>'unsafe-inline'</code> といった、あらゆる許可リストやソース表現が無視されます。<a href="/ja/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#strict-dynamic">script-src</a> の例を見てください。</dd> +</dl> +</div> + +<div id="report-sample"> +<dl> + <dt>'report-sample'</dt> + <dd>違反レポートに入れる違反コードのサンプルを要求します。</dd> +</dl> +</div> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="No_inheritance_with_default-src" name="No_inheritance_with_default-src">default-src で継承されない</h3> + +<p>他のディレクティブが指定されている場合、<code>default-src</code> は影響しません。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: default-src 'self'; script-src https://example.com</pre> + +<p>は、下記のものと同じです。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: connect-src 'self'; + font-src 'self'; + frame-src 'self'; + img-src 'self'; + manifest-src 'self'; + media-src 'self'; + object-src 'self'; + script-src https://example.com; + style-src 'self'; + worker-src 'self'</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-default-src", "default-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>既定として <code>frame-src</code>, <code>manifest-src</code>, <code>worker-src</code> を追加。</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-default-src", "default-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、<a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.default-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>CSP directives (<a href="https://www.w3.org/TR/CSP/#csp-directives">https://www.w3.org/TR/CSP/#csp-directives</a>): + <ul> + <li>{{Glossary("Fetch directive")}}</li> + <li>{{Glossary("Document directive")}}</li> + <li>{{Glossary("Navigation directive")}}</li> + <li>{{Glossary("Reporting directive")}}</li> + <li><code><a href="/docs/Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests">upgrade-insecure-requests</a></code></li> + <li><code><a href="/docs/Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content">block-all-mixed-content</a></code></li> + <li><code><a href="/docs/Web/HTTP/Headers/Content-Security-Policy/require-sri-for">require-sri-for</a></code> {{experimental_inline}}</li> + </ul> + </li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/frame-ancestors/index.html b/files/ja/web/http/headers/content-security-policy/frame-ancestors/index.html new file mode 100644 index 0000000000..3e2dbed062 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/frame-ancestors/index.html @@ -0,0 +1,127 @@ +--- +title: 'CSP: frame-ancestors' +slug: Web/HTTP/Headers/Content-Security-Policy/frame-ancestors +tags: + - Ancestors + - CSP + - Content-Security-Policy + - Directive + - Frame + - HTTP + - Security + - frame-ancestors +translation_of: Web/HTTP/Headers/Content-Security-Policy/frame-ancestors +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) である <code><strong>frame-ancestors</strong></code> ディレクティブは {{HTMLElement("frame")}}、 {{HTMLElement("iframe")}}、 {{HTMLElement("object")}} 、 {{HTMLElement("embed")}}、 {{HTMLElement("applet")}} などを使ってページを埋め込むことのできる親を指定します。</p> + +<p>このディレクティブを <code>'none'</code> にすることは、 {{HTTPHeader("X-Frame-Options")}}<code>: deny</code> (これは古いブラウザーも同様に対応しています) を設定するのに似ています。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>2</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Navigation directive", "ナビゲーションディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>なし。設定しない場合はすべてを許可します。</td> + </tr> + <tr> + <th colspan="2" scope="row">このディレクティブは {{HTMLElement("meta")}} 要素では対応していません。</th> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>frame-ancestors</code> ポリシーをこのように一つ以上セットできます。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: frame-ancestors <source>; +Content-Security-Policy: frame-ancestors <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p><source> は以下のうちのいずれかです。</p> + +<div class="note"> +<p><code>frame-ancestors</code> ディレクティブの構文は他のソースリスト ({{CSP("default-src")}} など) のものと同様ですが、 <code>'unsafe-eval'</code> や <code>'unsafe-inline'</code> などは許可されていません。また、これは <code>default-src</code> の設定にフォールバックすることもありません。下記に示されたソースのみが許可されます。</p> +</div> + +<dl> + <dt><host-source></dt> + <dd>スペースで区切られた、<a href="/ja/docs/URIs_and_URLs">URL scheme</a>やポート番号をふくむことができるIPアドレスや名前によるインターネットホスト名です。サイトのアドレスの前にワイルドカード (アスタリスク、 <code>'*'</code>)を含めることができ、さらにすべてのポートがソースとして有効であることを示すためにポート番号としてワイルドカード (<code>'*'</code>) を使うこともできます。ホスト名をシングルクオートで囲うことはできません。<br> + 例: + <ul> + <li><code>http://*.example.com</code>: <code>http:</code> のスキームを使用した、example.com のすべてのサブドメインからのすべての読み込みの試行に一致します。</li> + <li><code>mail.example.com:443</code>: mail.example.com の 443番ポートへのアクセスの試行に一致します。</li> + <li><code>https://store.example.com</code>: <code>https:</code> を使用した store.example.com へのアクセスの試行に一致します。</li> + </ul> + + <div class="blockIndicator warning"> + <p><code>host-source</code> にURLスキームが指定されておらず、 iframe が <code>https</code> URLから読み込まれている場合、 iframe を読み込んでいるページの URL も <code>https</code> でなければなりません。 W3C 仕様書の <a href="https://w3c.github.io/webappsec-csp/2/#match-source-expression">matching source expressions</a> によるものです。</p> + </div> + </dd> + <dt><scheme-source></dt> + <dd><code>http:</code> または <code>https:</code> のようなスキームです。コロンは必要です。以下の他の値とは異なり、単一引用符は使用しないでください。data スキームも指定することができます (非推奨)。 + <ul> + <li><code>data:</code> コンテンツのソースとして <a href="/ja/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"><code>data:</code> の URI</a> を使うことができるようにします。<em>これは安全ではありません。攻撃者は任意の data: URI を挿入することもできます。使用は控え、スクリプトには絶対に使用しないでください。</em></li> + <li><code>mediastream:</code> <a href="/ja/docs/Web/API/MediaStream_API"><code>mediastream:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + <li><code>blob:</code> <a href="/ja/docs/Web/API/Blob"><code>blob:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + <li><code>filesystem:</code> <a href="/ja/docs/Web/API/FileSystem"><code>filesystem:</code> の URI</a> をコンテンツのソースとして使用することができるようにします。</li> + </ul> + </dd> + <dt><code>'self'</code></dt> + <dd>保護された文書が提供されたオリジンを、同じ URL スキームおよびポート番号で参照します。単一引用符が必要です。ブラウザーによっては source ディレクティブから <code>blob</code> および <code>filesystem</code> を独自に除外していることがあります。これらのコンテンツ種別を許可する必要があるサイトは、Data 属性を使用して指定することができます。</dd> + <dt><code>'none'</code></dt> + <dd>空のセットを参照します。つまり、一致する URL はありません。単一引用符が必要です。</dd> +</dl> + +<h2 id="例">例</h2> + +<pre class="brush: bash notranslate">Content-Security-Policy: frame-ancestors 'none'; + +Content-Security-Policy: frame-ancestors 'self' https://www.example.org;</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-frame-ancestors", "frame-ancestors")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-frame-ancestors", "frame-ancestors")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、<a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.frame-ancestors")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTTPHeader("X-Frame-Options")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/frame-src/index.html b/files/ja/web/http/headers/content-security-policy/frame-src/index.html new file mode 100644 index 0000000000..98a6061b79 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/frame-src/index.html @@ -0,0 +1,99 @@ +--- +title: 'CSP: frame-src' +slug: Web/HTTP/Headers/Content-Security-Policy/frame-src +tags: + - CSP + - Content-Security-Policy + - Directive + - Frame + - HTTP + - Reference + - Security + - frame-src + - source + - セキュリティ + - ディレクティブ + - フレーム +translation_of: Web/HTTP/Headers/Content-Security-Policy/frame-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) における <code><strong>frame-src</strong></code> ディレクティブは、 {{HTMLElement("frame")}} や {{HTMLElement("iframe")}} のような要素を使用した内部の閲覧コンテキストの読み込みに有効なソースを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">代替</th> + <td>このディレクティブがない場合、ユーザーエージェントは {{CSP("child-src")}} ディレクティブを探す (さらにこの代替は {{CSP("default-src")}} ディレクティブである)。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>frame-src</code> ポリシーには、1つ以上のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: frame-src <source>; +Content-Security-Policy: frame-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash">Content-Security-Policy: frame-src https://example.com/</pre> + +<p>以下の {{HTMLElement("iframe")}} はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><iframe src="https://not-example.com/"></iframe></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-frame-src", "frame-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td><code>frame-src</code> の非推奨化を解除</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-frame-src", "frame-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td><code>frame-src</code> を非推奨化</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.frame-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("frame")}} および {{HTMLElement("iframe")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/img-src/index.html b/files/ja/web/http/headers/content-security-policy/img-src/index.html new file mode 100644 index 0000000000..5d02035fe9 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/img-src/index.html @@ -0,0 +1,99 @@ +--- +title: 'CSP: img-src' +slug: Web/HTTP/Headers/Content-Security-Policy/img-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Image + - Reference + - Security + - img-src + - source + - セキュリティ + - ディレクティブ + - 画像 +translation_of: Web/HTTP/Headers/Content-Security-Policy/img-src +--- +<div>{{HTTPSidebar}}</div> + +<p><span class="seoSummary">HTTP の {{HTTPHeader("Content-Security-Policy")}} における <code><strong>img-src</strong></code> ディレクティブは、画像やファビコンの有効なソースを指定します。</span></p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>img-src</code> ポリシーには、1つ以上のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: img-src <source>; +Content-Security-Policy: img-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/default-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash">Content-Security-Policy: img-src https://example.com/</pre> + +<p>以下の {{HTMLElement("img")}} の各要素はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><img src="https://not-example.com/foo.jpg" alt="example picture"></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-img-src", "img-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-img-src", "img-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.img-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("img")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/index.html b/files/ja/web/http/headers/content-security-policy/index.html new file mode 100644 index 0000000000..2abcbd7d1b --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/index.html @@ -0,0 +1,262 @@ +--- +title: Content-Security-Policy +slug: Web/HTTP/Headers/Content-Security-Policy +tags: + - CSP + - HTTP + - Reference + - Security + - header + - セキュリティ +translation_of: Web/HTTP/Headers/Content-Security-Policy +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の <strong><code>Content-Security-Policy</code></strong> レスポンスヘッダーは、ウェブサイト管理者が、あるページにユーザーエージェントが読み込みを許可されたリソースを管理できるようにします。いくつかの例外を除いて、大半のポリシーにはサーバーオリジンとスクリプトエンドポイントの指定を含んでいます。これはクロスサイトスクリプティング攻撃 ({{Glossary("XSS")}}) を防ぐのに役立ちます。</p> + +<p>より詳細な情報は、 <a href="/ja/docs/Web/HTTP/CSP">Content Security Policy (CSP)</a> の入門記事を参照してください。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">ヘッダー種別</th> + <td>{{Glossary("Response header", "レスポンスヘッダー")}}</td> + </tr> + <tr> + <th scope="row">{{Glossary("Forbidden header name", "禁止ヘッダー名")}}</th> + <td>いいえ</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">Content-Security-Policy: <policy-directive>; <policy-directive> +</pre> + +<p>ここで、 <code><policy-directive></code> は次の要素で構成されます: <code><directive> <value></code> 内部の句読点なし。</p> + +<h2 id="Directives" name="Directives">ディレクティブ</h2> + +<h3 id="Fetch_directives" name="Fetch_directives">{{Glossary("Fetch directive", "フェッチディレクティブ")}}</h3> + +<p>フェッチディレクティブは、特定のリソース種別がロードされうる場所を制御します。</p> + +<h4 id="List_of_Content_Security_Policy_Fetch_directives" name="List_of_Content_Security_Policy_Fetch_directives">Content Security Policy フェッチディレクティブの一覧</h4> + +<dl> + <dt>{{CSP("child-src")}}</dt> + <dd><a href="/ja/docs/Web/API/Web_Workers_API">ウェブワーカー</a>と、 {{HTMLElement("frame")}} や {{HTMLElement("iframe")}} のような要素によってロードされる入れ子状の閲覧コンテキストに対する有効なソースを定義します。 + <div class="warning"> + <p>複合した閲覧コンテキストやワーカーを制御するには、 それぞれ {{CSP("frame-src")}} および {{CSP("worker-src")}} を <strong><code>child-src</code></strong> の代わりに使用してください。</p> + </div> + </dd> + <dt>{{CSP("connect-src")}}</dt> + <dd>script インターフェースによってロードされる URL を制限します。</dd> + <dt>{{CSP("default-src")}}</dt> + <dd>別の {{Glossary("Fetch directive", "Fetch ディレクティブ")}}に対する代替として提供します。</dd> + <dt>{{CSP("font-src")}}</dt> + <dd>{{cssxref("@font-face")}} によってロードされるフォントに対する有効なソースを指定します。</dd> + <dt>{{CSP("frame-src")}}</dt> + <dd>{{HTMLElement("frame")}} や {{HTMLElement("iframe")}} のような要素によってロードされる入れ子状のコンテンツの閲覧に対する有効なソースを指定します。</dd> + <dt>{{CSP("img-src")}}</dt> + <dd>画像や favicon に対する有効なソースを定義します。</dd> + <dt>{{CSP("manifest-src")}}</dt> + <dd>アプリケーションのマニフェストファイルに対する有効なソースを指定します。</dd> + <dt>{{CSP("media-src")}}</dt> + <dd>{{HTMLElement("audio")}}、{{HTMLElement("video")}} や {{HTMLElement("track")}} 要素によってロードするメディアに対する有効なソースを指定します。</dd> + <dt>{{CSP("object-src")}}</dt> + <dd>{{HTMLElement("object")}}、 {{HTMLElement("embed")}} や {{HTMLElement("applet")}} 要素に対する有効なソースを指定します。</dd> + <dd class="note"><code>object-src</code> で制御される要素は、おそらく古い HTML 要素に該当すると見なされ、新しい標準機能が利用できません (セキュリティ属性の <code>sandbox</code> や <code><iframe></code> の <code>allow</code> など)。従って、このフェッチディレクティブで制限を掛けることが<strong>推奨されます</strong> (例えば、可能であれば <code>object-src 'none'</code> を設定するなど)。</dd> + <dt>{{CSP("prefetch-src")}}{{experimental_inline}}</dt> + <dd>事前にフェッチされるか描画される有効なソースを指定します。</dd> + <dt>{{CSP("script-src")}}</dt> + <dd>JavaScript に対する有効なソースを指定します。</dd> + <dt>{{CSP("script-src-elem")}}{{experimental_inline}}</dt> + <dd>JavaScript の {{HTMLElement("script")}} 要素に対する有効なソースを指定します。</dd> + <dt>{{CSP("script-src-attr")}}{{experimental_inline}}</dt> + <dd>JavaScript のインラインイベントハンドラーに対する有効なソースを指定します。</dd> +</dl> + +<dl> + <dt>{{CSP("style-src")}}</dt> + <dd>スタイルシートに対する有効なソースを指定します。</dd> + <dt>{{CSP("style-src-elem")}}{{experimental_inline}}</dt> + <dd>スタイルシートの {{HTMLElement("style")}} および {{HTMLElement("link")}} 要素に <code>rel="stylesheet"</code> がついたもののに対する有効なソースを指定します。</dd> + <dt>{{CSP("style-src-attr")}}{{experimental_inline}}</dt> + <dd>個々の DOM 要素に適用されるインラインスタイルの有効なソースを指定します。</dd> + <dt>{{CSP("worker-src")}}{{experimental_inline}}</dt> + <dd>{{domxref("Worker")}}, {{domxref("SharedWorker")}}, {{domxref("ServiceWorker")}} スクリプトに対する有効なソースを指定します。</dd> +</dl> + +<h3 id="Document_directives" name="Document_directives">{{Glossary("Document directive", "文書ディレクティブ")}}</h3> + +<p>文書ディレクティブは、ポリシーが適用される文書もしくは <a href="/ja/docs/Web/API/Web_Workers_API">Worker</a> 環境のプロパティを管理します。</p> + +<h4 id="List_of_Content_Security_Policy_Document_directives" name="List_of_Content_Security_Policy_Document_directives">Content Security Policy 文書ディレクティブの一覧</h4> + +<dl> + <dt>{{CSP("base-uri")}}</dt> + <dd>文書の {{HTMLElement("base")}} 要素で使用される URL を制限します。</dd> + <dt>{{CSP("plugin-types")}}</dt> + <dd>ロードされるリソースのタイプを限定することで、文書に埋め込まれるプラグインの組を制限します。</dd> + <dt>{{CSP("sandbox")}}</dt> + <dd>{{HTMLElement("iframe")}} と {{htmlattrxref("sandbox", "iframe")}} 属性に類似した要求リソースに対してサンドボックスを有効にします。</dd> +</dl> + +<h3 id="Navigation_directives" name="Navigation_directives">{{Glossary("Navigation directive", "ナビゲーションディレクティブ")}}</h3> + +<p>ナビゲーションディレクティブは、例えばユーザーが移動する場所やフォームを送信する場所を管理します。</p> + +<h4 id="List_of_Content_Security_Policy_Navigation_directives" name="List_of_Content_Security_Policy_Navigation_directives">Content Security Policy ナビゲーションディレクティブの一覧</h4> + +<dl> + <dt>{{CSP("form-action")}}</dt> + <dd>指定のコンテキストからフォームの送信先として使用される URL を制限します。</dd> + <dt>{{CSP("frame-ancestors")}}</dt> + <dd>{{HTMLElement("frame")}}, {{HTMLElement("iframe")}}, {{HTMLElement("object")}}, {{HTMLElement("embed")}}, もしくは {{HTMLElement("applet")}} によってページに埋め込まれた有効な親を指定します。</dd> + <dt>{{CSP("navigate-to")}}{{experimental_inline}}</dt> + <dd>{{HTMLElement("form")}} ({{CSP("form-action")}} が指定されていない場合), {{HTMLElement("a")}}, {{DOMxRef("window.location")}}, {{DOMxRef("window.open")}}, など、あらゆる方法で文書からナビゲーションを行うことができる URL を制限します。</dd> +</dl> + +<h3 id="Reporting_directives" name="Reporting_directives">{{Glossary("Reporting directive", "報告ディレクティブ")}}</h3> + +<p>報告ディレクティブは CSP 違反の報告過程を制御します。 {{HTTPHeader("Content-Security-Policy-Report-Only")}} ヘッダーも参照してください。</p> + +<h4 id="List_of_Content_Security_Policy_Reporting_directives" name="List_of_Content_Security_Policy_Reporting_directives">Content Security Policy 報告ディレクティブの一覧</h4> + +<dl> + <dt>{{CSP("report-uri")}}{{deprecated_inline}}</dt> + <dd>ユーザーエージェントにコンテンツセキュリティポリシーの違反を報告するよう指示します。これらの違反の報告は、 {{Glossary("JSON")}} 文書を HTTP の <code>POST</code> リクエストで指定された URI に送信することで行われます。 + <div class="warning"> + <p>{{CSP("report-to")}} ディレクティブは非推奨の <code><strong>report-uri</strong></code> ディレクティブを置き換えることを意図していますが、 {{CSP("report-to")}} はまだ多くのブラウザーで対応されていません。そのため、ブラウザーで {{CSP("report-to")}} の対応が行われるまでは現在のブラウザーとの互換性のため、 <code><strong>report-uri</strong></code> および {{CSP("report-to")}} の両方を指定することができます。</p> + + <pre class="syntaxbox notranslate">Content-Security-Policy: ...; report-uri https://endpoint.example.com; report-to groupname</pre> + + <p>{{CSP("report-to")}} に対応したブラウザーでは、 <code><strong>report-uri</strong></code> ディレクティブは無視されます。</p> + </div> + </dd> + <dt>{{CSP("report-to")}}{{experimental_inline}}</dt> + <dd><code>SecurityPolicyViolationEvent</code> を発生させます。</dd> +</dl> + +<h3 id="Other_directives" name="Other_directives">その他のディレクティブ</h3> + +<dl> + <dt>{{CSP("block-all-mixed-content")}}</dt> + <dd>ページが HTTPS を使用して読み込まれた際に、 HTTP を使用して資産を読み込むことを防止します。</dd> + <dt>{{CSP("referrer")}}{{deprecated_inline}}{{non-standard_inline}}</dt> + <dd>ページから離れる際の Referer ヘッダー内の情報を指定するために使用されていました。代わりに {{HTTPHeader("Referrer-Policy")}} ヘッダーを使用してください。</dd> + <dt>{{CSP("require-sri-for")}}{{experimental_inline}}</dt> + <dd>ページ上のスクリプトやスタイルに {{Glossary("SRI")}} の使用を要求します。</dd> + <dt>{{CSP("require-trusted-types-for")}}{{experimental_inline}}</dt> + <dd>DOM XSS インジェクションシンクで <a href="https://w3c.github.io/webappsec-trusted-types/dist/spec/">Trusted Types</a> を強制します。</dd> +</dl> + +<dl> + <dt>{{CSP("trusted-types")}}{{experimental_inline}}</dt> + <dd><a href="https://w3c.github.io/webappsec-trusted-types/dist/spec/">Trusted Types</a> ポリシーのホワイトリストを指定するために使用します (Trusted Types は、アプリケーションが DOM XSS インジェクションシンクをロックダウンして、文字列の代わりにスプーフィング不可能な型付きの値のみを受け入れるようにします)。</dd> +</dl> + +<dl> + <dt>{{CSP("upgrade-insecure-requests")}}</dt> + <dd>安全でない URL (HTTP で提供されているもの) をすべて安全な URL (HTTPS で提供されているもの) に置き換えたかのように扱うようにユーザエージェントに指示します。このディレクティブは、書き換えが必要な安全でない古い URL が大量にあるウェブサイトを対象としています。</dd> +</dl> + +<h2 id="CSP_in_workers" name="CSP_in_workers">Worker 内の CSP</h2> + +<p><a href="/ja/docs/Web/API/Worker">Worker</a> は、一般的に文書 (もしくは親 Worker) の Content Security Policy によって管理されません。Worker に対する Content Security Policy を指定するには、Worker スクリプト自身が要求したリクエストに対して <code>Content-Security-Policy</code> レスポンスヘッダーを設定して下さい。</p> + +<p>Worker スクリプトのオリジンがグローバルで一意の識別子の場合、(例えば、URL がデータやブロブのスキーマの場合)、例外に当たります。この場合、Worker は文書もしくは作成元の Worker の Content Security Policy を継承します。</p> + +<h2 id="Multiple_content_security_policies" name="Multiple_content_security_policies">複数の CSP</h2> + +<p>CSP では、<code>Content-Security-Policy</code> ヘッダー、{{HTTPHeader("Content-Security-Policy-Report-Only")}} ヘッダーや {{HTMLElement("meta")}} 要素を経由したものを含む、リソースに対して複数のポリシーを指定することができます。</p> + +<p>以下の例のように、 <code>Content-Security-Policy</code> ヘッダーを複数回使うことができます。ここでは {{CSP("connect-src")}} ディレクティブに特に注意してください。2つ目のポリシーでは接続を許可しているにもかかわらず、1つ目のポリシーには <code>connect-src 'none'</code> が含まれています。追加のポリシーを追加すると、保護されたリソースの機能が<em>さらに制限することができる</em>だけで、接続は許可されず、最も厳密なポリシーとして <code>connect-src 'none'</code> が強制されます。</p> + +<pre class="notranslate">Content-Security-Policy: default-src 'self' http://example.com; + connect-src 'none'; +Content-Security-Policy: connect-src http://example.com/; + script-src http://example.com/</pre> + +<h2 id="Examples" name="Examples">例</h2> + +<p>例: 安全でない inline/eval を無効にし、https 経由でのリソース (画像、フォント、スクリプトなど) のロードを許します。</p> + +<pre class="notranslate">// ヘッダー +Content-Security-Policy: default-src https: + +// メタタグ +<meta http-equiv="Content-Security-Policy" content="default-src https:"> +</pre> + +<p>例: 修正のためにインラインコードを多用している既存のサイトで、https 経由でのみロードされるリソースを明確にし、プラグインを無効にします。</p> + +<pre class="notranslate">Content-Security-Policy: default-src https: 'unsafe-eval' 'unsafe-inline'; object-src 'none'</pre> + +<p>例: 上記のポリシーを実装せず、代わりに、発生するであろう違反を報告します。</p> + +<pre class="notranslate">Content-Security-Policy-Report-Only: default-src https:; report-uri /csp-violation-report-endpoint/</pre> + +<p>その他の例は、 <a href="https://infosec.mozilla.org/guidelines/web_security#Examples_5">Mozilla Web Security Guidelines</a> を参照して下さい。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0")}}</td> + <td>{{Spec2("CSP 3.0")}}</td> + <td><code>manifest-src</code>, <code>navigate-to</code>, <code>report-to</code>, <code>strict-dynamic</code>, <code>worker-src</code> を追加。 <code>frame-src</code> の非推奨を解除。 <code>report-uri</code> を <code>report-to</code> の代わりに非推奨化。</td> + </tr> + <tr> + <td>{{specName("Mixed Content")}}</td> + <td>{{Spec2("Mixed Content")}}</td> + <td><code>block-all-mixed-content</code> を追加。</td> + </tr> + <tr> + <td>{{specName("Subresource Integrity")}}</td> + <td>{{Spec2("Subresource Integrity")}}</td> + <td><code>require-sri-for</code> を追加。</td> + </tr> + <tr> + <td>{{specName("Upgrade Insecure Requests")}}</td> + <td>{{Spec2("Upgrade Insecure Requests")}}</td> + <td><code>upgrade-insecure-requests</code> を追加。</td> + </tr> + <tr> + <td>{{specName("CSP 1.1")}}</td> + <td>{{Spec2("CSP 1.1")}}</td> + <td><code>base-uri</code>, <code>child-src</code>, <code>form-action</code>, <code>frame-ancestors</code>, <code>plugin-types</code>, <code>referrer</code>, <code>report-uri</code> を追加。 <code>frame-src</code> を非推奨化。</td> + </tr> + <tr> + <td>{{specName("CSP 1.0")}}</td> + <td>{{Spec2("CSP 1.0")}}</td> + <td><code>connect-src</code>, <code>default-src</code>, <code>font-src</code>, <code>frame-src</code>, <code>img-src</code>, <code>media-src</code>, <code>object-src</code>, report-uri, <code>sandbox</code>, <code>script-src,</code>, <code>style-src</code> を定義。</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy-Report-Only")}}</li> + <li><a href="/ja/docs/Web/HTTP/CSP">コンテンツセキュリティポリシーを学ぶ</a></li> + <li><a href="/ja/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">WebExtensions のコンテンツセキュリティ</a></li> + <li><a href="https://csp.withgoogle.com/docs/strict-csp.html">Adopting a strict policy</a></li> + <li><a href="https://github.com/google/csp-evaluator">CSP Evaluator</a> - コンテンツセキュリティポリシーを評価する</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/manifest-src/index.html b/files/ja/web/http/headers/content-security-policy/manifest-src/index.html new file mode 100644 index 0000000000..e5678daf69 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/manifest-src/index.html @@ -0,0 +1,95 @@ +--- +title: 'CSP: manifest-src' +slug: Web/HTTP/Headers/Content-Security-Policy/manifest-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Manifest + - Reference + - Security + - manifest-src + - source + - セキュリティ + - ディレクティブ + - マニフェスト +translation_of: Web/HTTP/Headers/Content-Security-Policy/manifest-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}}<code>: <strong>manifest-src</strong></code> ディレクティブは、どの<a href="/ja/docs/Web/Manifest">マニフェスト</a>がリソースに適用されるかを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>3</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>manifest-src</code> ポリシーには、1つ以上のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: manifest-src <source>; +Content-Security-Policy: manifest-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash">Content-Security-Policy: manifest-src https://example.com/</pre> + +<p>以下の {{HTMLElement("link")}} の各要素はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><link rel="manifest" href="https://not-example.com/manifest"></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-manifest-src", "manifest-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.manifest-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li><a href="/ja/docs/Web/Manifest">ウェブアプリマニフェスト</a></li> + <li>{{HTMLElement("link")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/media-src/index.html b/files/ja/web/http/headers/content-security-policy/media-src/index.html new file mode 100644 index 0000000000..a3d3caf71e --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/media-src/index.html @@ -0,0 +1,103 @@ +--- +title: 'CSP: media-src' +slug: Web/HTTP/Headers/Content-Security-Policy/media-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Media + - Reference + - Security + - media-src + - source + - セキュリティ + - ディレクティブ + - メディア +translation_of: Web/HTTP/Headers/Content-Security-Policy/media-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) における <code><strong>media-src</strong></code> ディレクティブは、 {{HTMLElement("audio")}} および {{HTMLElement("video")}} 要素を使用して読み込むメディアの有効なソースを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>media-src</code> ポリシーには、1つ以上のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: media-src <source>; +Content-Security-Policy: media-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash">Content-Security-Policy: media-src https://example.com/</pre> + +<p>以下の {{HTMLElement("audio")}}, {{HTMLElement("video")}}, {{HTMLElement("track")}} の各要素はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><audio src="https://not-example.com/audio"></audio> + +<video src="https://not-example.com/video"> + <track kind="subtitles" src="https://not-example.com/subtitles"> +</video></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-media-src", "media-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-media-src", "media-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.media-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("audio")}}, {{HTMLElement("video")}}, {{HTMLElement("track")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/object-src/index.html b/files/ja/web/http/headers/content-security-policy/object-src/index.html new file mode 100644 index 0000000000..ebff246395 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/object-src/index.html @@ -0,0 +1,105 @@ +--- +title: 'CSP: object-src' +slug: Web/HTTP/Headers/Content-Security-Policy/object-src +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Object + - Reference + - Security + - object-src + - source + - セキュリティ + - ディレクティブ +translation_of: Web/HTTP/Headers/Content-Security-Policy/object-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} の <code><strong>object-src</strong></code> ディレクティブは、 {{HTMLElement("object")}}, {{HTMLElement("embed")}}, {{HTMLElement("applet")}} の各要素の妥当なソースを指定します。</p> + +<p>{{HTMLElement("object")}}, {{HTMLElement("embed")}}, {{HTMLElement("applet")}} の各要素の許可される種類を設定するには、 {{CSP("plugin-types")}} ディレクティブを使用してください。</p> + +<p class="note"><code>object-src</code> で制御される要素は、おそらく偶然にも古い HTML 要素と見なされており、新しい標準機能が搭載されていません (<code><iframe></code> の <code>sandbox</code> や <code>allow</code> などのセキュリティ属性など)。したがって、このフェッチディレクティブで制限することを<a href="https://csp.withgoogle.com/docs/strict-csp.html">推奨します</a> (例えば、可能であれば明示的に <code>object-src 'none'</code> を設定するなど)。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p>object-src ポリシーには、1つまたは複数のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: object-src <source>; +Content-Security-Policy: object-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_case" name="Violation_case">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash">Content-Security-Policy: object-src https://example.com/</pre> + +<p>以下の {{HTMLElement("object")}}, {{HTMLElement("embed")}}, {{HTMLElement("applet")}} の各要素はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><embed src="https://not-example.com/flash"></embed> +<object data="https://not-example.com/plugin"></object> +<applet archive="https://not-example.com/java"></applet></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-object-src", "object-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-object-src", "object-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.object-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("object")}}, {{HTMLElement("embed")}}, and {{HTMLElement("applet")}}</li> + <li>{{CSP("plugin-types")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/plugin-types/index.html b/files/ja/web/http/headers/content-security-policy/plugin-types/index.html new file mode 100644 index 0000000000..e0c4814eff --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/plugin-types/index.html @@ -0,0 +1,123 @@ +--- +title: 'CSP: plugin-types' +slug: Web/HTTP/Headers/Content-Security-Policy/plugin-types +tags: + - CSP + - Content-Security-Policy + - Directive + - Flash + - HTTP + - Java + - Plugin + - Plugins + - Security + - セキュリティ + - ディレクティブ + - プラグイン +translation_of: Web/HTTP/Headers/Content-Security-Policy/plugin-types +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>plugin-types</strong></code> ディレクティブは、文書に埋め込むことができるプラグインのセットを、読み込むことができるリソースの種類を制限することによって制限します。</p> + +<p>{{HTMLElement("embed")}}, {{HTMLElement("object")}}, {{HTMLElement("applet")}} の各要素のインスタンス化は、次の場合に失敗します。</p> + +<ul> + <li>要素が妥当な MIME 型を宣言していなかった場合</li> + <li>宣言された型が <code>plugin-types</code> ディレクティブで指定されたもののいずれにも一致しなかった場合</li> + <li>読み込まれたリソースが宣言された型に一致しなかった場合</li> +</ul> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>2</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Document directive", "文書ディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>なし。これを設定しないと何も許可されない。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p>1つ以上の <a href="/ja/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME 型</a>を <code>plugin-types</code> ポリシーに設定することができます。</p> + +<pre class="syntaxbox">Content-Security-Policy: plugin-types <type>/<subtype>; +Content-Security-Policy: plugin-types <type>/<subtype> <type>/<subtype>; +</pre> + +<dl> + <dt><type>/<subtype></dt> + <dd>妥当な <a href="/ja/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types">MIME 型</a>。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Disallowing_plugins" name="Disallowing_plugins">プラグインを不許可にする</h3> + +<p>全てのプラグインを不許可にするには、 {{CSP("object-src")}} ディレクティブを <code>'none'</code> に設定すればプラグインが不許可になります。 <code>plugin-types</code> ディレクティブは、 <code>object-src</code> でプラグインを許可している場合に限って使用することができます。</p> + +<pre class="brush: html"><meta http-equiv="Content-Security-Policy" content="object-src 'none'"></pre> + +<h3 id="Allowing_Flash_content" name="Allowing_Flash_content">Flash コンテンツの許可</h3> + +<p>以下のコンテンツセキュリティポリシーは、</p> + +<pre class="brush: bash">Content-Security-Policy: plugin-types application/x-shockwave-flash</pre> + +<p>次のような Flash オブジェクトの読み込みを許可します。</p> + +<pre class="brush: html"><object data="https://example.com/flash" type="application/x-shockwave-flash"></object></pre> + +<h3 id="Allowing_Java_applets" name="Allowing_Java_applets">Java アプレットの許可</h3> + +<p>{{HTMLElement("applet")}} を読み込むには、 <code>application/x-java-applet</code> を指定する必要があります。</p> + +<pre class="brush: bash">Content-Security-Policy: plugin-types application/x-java-applet</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-plugin-types", "plugin-types")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-plugin-types", "plugin-types")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.plugin-types")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}: {{CSP("object-src")}}</li> + <li>{{HTMLElement("object")}}</li> + <li>{{HTMLElement("embed")}}</li> + <li>{{HTMLElement("applet")}}</li> + <li>{{HTTPHeader("X-Content-Type-Options")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/prefetch-src/index.html b/files/ja/web/http/headers/content-security-policy/prefetch-src/index.html new file mode 100644 index 0000000000..27365cada8 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/prefetch-src/index.html @@ -0,0 +1,89 @@ +--- +title: 'CSP: prefetch-src' +slug: Web/HTTP/Headers/Content-Security-Policy/prefetch-src +tags: + - CSP + - Content Security Policy + - Directive + - HTTP + - Reference + - prefetch-src + - コンテンツセキュリティポリシー + - ディレクティブ +translation_of: Web/HTTP/Headers/Content-Security-Policy/prefetch-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) における <code><strong>prefetch-src</strong></code> ディレクティブは、事前読み込みまたは事前描画することができる有効なリソースを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>3</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} fallback</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>prefetch-src</code> ポリシーには、1つ以上のソースが許可されています。</p> + +<pre class="syntaxbox">Content-Security-Policy: prefetch-src <source>; +Content-Security-Policy: prefetch-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/default-src", "common_sources")}}</p> + +<h2 id="Example" name="Example">例</h2> + +<h3 id="Prefetch_resources_do_not_match_header" name="Prefetch_resources_do_not_match_header">ヘッダーが一致しないリソースの事前読み込み</h3> + +<p>次のコンテンツセキュリティポリシーを持つページがあったとします。</p> + +<pre>Content-Security-Policy: prefetch-src https://example.com/ +</pre> + +<p>次のコードで読み込もうとすると、指定された URL が <code>prefetch-src</code> のソース一覧にないので、ネットワークエラーになります。</p> + +<pre><link rel="prefetch" src="https://example.org/"></link> +<link rel="prerender" src="https://example.org/"></link></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#prefetch-src", "prefetch-src")}}</td> + <td>{{Spec2("CSP 3.0")}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.prefetch-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/referrer/index.html b/files/ja/web/http/headers/content-security-policy/referrer/index.html new file mode 100644 index 0000000000..faa4078d95 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/referrer/index.html @@ -0,0 +1,61 @@ +--- +title: 'CSP: referrer' +slug: Web/HTTP/Headers/Content-Security-Policy/referrer +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Obsolete + - Reference + - Security + - referrer +translation_of: Web/HTTP/Headers/Content-Security-Policy/referrer +--- +<div>{{HTTPSidebar}} {{deprecated_header}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>referrer</strong></code> ディレクティブは、ページから離れたリンクの {{HTTPHeader("Referer")}} ヘッダー (元の仕様書の綴りミスのため <code>r</code> は単一) の情報を指定するために使用されます。この API は非推奨であり、ブラウザーから削除されました。</p> + +<div class="note"> +<p>代わりに {{HTTPHeader("Referrer-Policy")}} ヘッダーを使用してください。</p> +</div> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">Content-Security-Policy: referrer <referrer-policy>;</pre> + +<p><code><referrer-policy></code> は以下のいずれかの値になります:</p> + +<dl> + <dt>"no-referrer"</dt> + <dd>{{HTTPHeader("Referer")}} ヘッダーは完全に除外されます。リファラー情報はリクエストと共に送信されません。</dd> + <dt>"none-when-downgrade"</dt> + <dd>これがポリシーが指定されていない場合のユーザーエージェントの既定の動作です。以前と同じ安全性 (HTTPS->HTTPS) の宛先にはオリジンが送信されますが、安全性の低い宛先 (HTTPS->HTTP) には送信されません。</dd> + <dt>"origin"</dt> + <dd>すべての場合で、リファラーとして文書ののオリジンのみ送信されます。<br> + <code>https://example.com/page.html</code> の文書の場合は <code>https://example.com/</code> というリファラーが送信されます。</dd> + <dt>"origin-when-cross-origin" / "origin-when-crossorigin"</dt> + <dd>同一オリジンのリクエストを実行する際は完全な URL が送信されますが、それ以外の場合は文書のオリジンのみ送信されます。</dd> + <dt>"unsafe-url"</dt> + <dd>同一オリジンまたはオリジン間のリクエストを実行する際は完全な URL (引数は除外) が送信されます。このポリシーは、 TLS で保護されたリソースから保護されていないオリジンへのオリジンとパスを漏洩させます。この設定の影響を慎重に検討してください。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="notranslate">Content-Security-Policy: referrer "none";</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<p>いずれの仕様書の一部でもありません。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p>{{Compat("http.headers.csp.referrer")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTTPHeader("Referrer-Policy")}} ヘッダー</li> + <li>{{HTTPHeader("Referer")}} ヘッダー</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/report-to/index.html b/files/ja/web/http/headers/content-security-policy/report-to/index.html new file mode 100644 index 0000000000..dc2c8d4546 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/report-to/index.html @@ -0,0 +1,83 @@ +--- +title: 'CSP: report-to' +slug: Web/HTTP/Headers/Content-Security-Policy/report-to +tags: + - CSP + - Content-Security-Policy + - HTTP + - report-to + - コンテンツセキュリティポリシー + - セキュリティ + - レスポンスヘッダー + - 報告 +translation_of: Web/HTTP/Headers/Content-Security-Policy/report-to +--- +<div>{{HTTPSidebar}}</div> + +<p><span class="seoSummary"><code>Content-Security-Policy</code> の <dfn><code>Report-To</code></dfn> は HTTP のレスポンスヘッダーフィールドで、ユーザーエージェントにオリジンの報告先のエンドポイントを保存するよう指示します。</span></p> + +<pre class="syntaxbox">Content-Security-Policy: ...; report-to groupname +</pre> + +<p>このディレクティブは単体では効果がありませんが、他のディレクティブとの組み合わせでのみ意味を持ちます。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP version</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Reporting directive", "報告ディレクティブ")}}</td> + </tr> + <tr> + <th colspan="2" scope="row">このディレクティブは {{HTMLElement("meta")}} 要素では対応していません。</th> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre>Content-Security-Policy: report-to <json-field-value>;</pre> + +<h2 id="Examples" name="Examples">例</h2> + +<p>詳しい情報や例は、 {{HTTPHeader("Content-Security-Policy-Report-Only")}} を参照してください。</p> + +<pre><a href="http://wicg.github.io/reporting/#report-to" id="ref-for-report-to①">Report-To</a>: { "<a href="http://wicg.github.io/reporting/#group" id="ref-for-group①">group</a>": "csp-endpoint", + "<a href="http://wicg.github.io/reporting/#max-age" id="ref-for-max-age①">max_age</a>": 10886400, + "<a href="http://wicg.github.io/reporting/#endpoints" id="ref-for-endpoints②">endpoints</a>": [ + { "<a href="http://wicg.github.io/reporting/#url" id="ref-for-url②">url</a>": "https://example.com/csp-reports" } + ] }, + { "<a href="http://wicg.github.io/reporting/#group" id="ref-for-group②">group</a>": "hpkp-endpoint", + "<a href="http://wicg.github.io/reporting/#max-age" id="ref-for-max-age②">max_age</a>": 10886400, + "<a href="http://wicg.github.io/reporting/#endpoints" id="ref-for-endpoints③">endpoints</a>": [ + { "<a href="http://wicg.github.io/reporting/#url" id="ref-for-url③">url</a>": "https://example.com/hpkp-reports" } + ] } +<a href="https://w3c.github.io/webappsec-csp/#content-security-policy" id="ref-for-content-security-policy①">Content-Security-Policy</a>: ...; <a href="https://w3c.github.io/webappsec-csp/#directives-reporting" id="ref-for-directives-reporting①">report-to</a> csp-endpoint +</pre> + +<pre><a href="http://wicg.github.io/reporting/#report-to" id="ref-for-report-to">Report-To</a>: { "<a href="http://wicg.github.io/reporting/#group" id="ref-for-group">group</a>": "endpoint-1", + "<a href="http://wicg.github.io/reporting/#max-age" id="ref-for-max-age">max_age</a>": 10886400, + "<a href="http://wicg.github.io/reporting/#endpoints" id="ref-for-endpoints①">endpoints</a>": [ + { "<a href="http://wicg.github.io/reporting/#url" id="ref-for-url">url</a>": "https://example.com/reports" }, + { "<a href="http://wicg.github.io/reporting/#url" id="ref-for-url①">url</a>": "https://backup.com/reports" } + ] } + +<a href="https://w3c.github.io/webappsec-csp/#content-security-policy" id="ref-for-content-security-policy">Content-Security-Policy</a>: ...; <a href="https://w3c.github.io/webappsec-csp/#directives-reporting" id="ref-for-directives-reporting">report-to</a> endpoint-1</pre> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden"> +<p>このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> +</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.report-to")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTTPHeader("Content-Security-Policy-Report-Only")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/require-sri-for/index.html b/files/ja/web/http/headers/content-security-policy/require-sri-for/index.html new file mode 100644 index 0000000000..be2bc8edd9 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/require-sri-for/index.html @@ -0,0 +1,59 @@ +--- +title: 'CSP: require-sri-for' +slug: Web/HTTP/Headers/Content-Security-Policy/require-sri-for +tags: + - CSP + - Directive + - HTTP + - Reference + - Security + - Subresource Integrity + - require-sri-for +translation_of: Web/HTTP/Headers/Content-Security-Policy/require-sri-for +--- +<div>{{Obsolete_header}}</div> + +<p><a href="/ja/docs/Web/HTTP">HTTP</a> の {{HTTPHeader("Content-Security-Policy")}} における <code><strong>require-sri-for</strong></code> ディレクティブは、クライアントにページ上でスクリプトやスタイルの<a href="/ja/docs/Web/Security/Subresource_Integrity">サブリソース完全性</a>を要求することを支持します。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate">Content-Security-Policy: require-sri-for script; +Content-Security-Policy: require-sri-for style; +Content-Security-Policy: require-sri-for script style; +</pre> + +<dl> + <dt><code>script</code></dt> + <dd>{{Glossary("SRI")}} をスクリプトに要求します。</dd> + <dt><code>style</code></dt> + <dd>{{Glossary("SRI")}} をスタイルシートに要求します。</dd> + <dt><code>script style</code></dt> + <dd>{{Glossary("SRI")}} をスクリプトとスタイルシートの両方に要求します。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<p>このディレクティブを使ってスクリプトやスタイルに SRI を要求するようにサイトを設定している場合の設定です。</p> + +<pre class="notranslate">Content-Security-Policy: require-sri-for script style</pre> + +<p>以下のような {{HTMLElement("script")}} 要素は正しい <code>integrity</code> 属性を使用している場合に限り、読み込まれます。</p> + +<pre class="brush: html; example-good notranslate"><script src="https://code.jquery.com/jquery-3.1.1.slim.js" + integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA=" + crossorigin="anonymous"></script></pre> + +<p>しかし、 <code>integrity</code> のないスクリプトは読み込まれなくなります。</p> + +<pre class="brush: html; example-bad notranslate"><script src="https://code.jquery.com/jquery-3.1.1.slim.js"></script></pre> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.require-sri-for")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li><a href="/ja/docs/Web/Security/Subresource_Integrity">サブリソース完全性</a></li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/sandbox/index.html b/files/ja/web/http/headers/content-security-policy/sandbox/index.html new file mode 100644 index 0000000000..dbb381f9d4 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/sandbox/index.html @@ -0,0 +1,113 @@ +--- +title: 'CSP: sandbox' +slug: Web/HTTP/Headers/Content-Security-Policy/sandbox +tags: + - CSP + - Content-Security-Policy + - Directive + - HTTP + - Sandbox + - Security + - サンドボックス + - セキュリティ + - ディレクティブ +translation_of: Web/HTTP/Headers/Content-Security-Policy/sandbox +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>sandbox</strong></code> ディレクティブは、 {{HTMLElement("iframe")}} の {{htmlattrxref("sandbox", "iframe")}} 属性と同様に、要求されたリソースに対してサンドボックスを有効にします。これは、ポップアップの防止、プラグインやスクリプトの実行の防止、同一オリジンポリシーの強制などを含むページ操作の制限を適用します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1.1 / 2</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Document directive", "文書ディレクティブ")}}</td> + </tr> + <tr> + <th colspan="2" scope="row">このディレクティブは {{HTMLElement("meta")}} 要素や {{HTTPHeader("Content-Security-policy-Report-Only")}} ヘッダーフィールドでは対応していません。</th> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox">Content-Security-Policy: sandbox; +Content-Security-Policy: sandbox <value>; +</pre> + +<p><code><value></code> は省略可能で、以下の値の内の一つです。</p> + +<dl> + <dt><code>allow-downloads-without-user-activation</code> {{experimental_inline}}</dt> + <dd>ユーザーによる指示のないダウンロードを許可します。</dd> +</dl> + +<dl> + <dt><code>allow-forms</code></dt> + <dd>埋め込み閲覧コンテキストが、フォームを送信することを許可します。このキーワードが使用されなかった場合、この操作は許可されません。</dd> + <dt><code>allow-modals</code></dt> + <dd>埋め込み閲覧コンテキストが、モーダルウィンドウを開くことを許可します。</dd> + <dt><code>allow-orientation-lock</code></dt> + <dd>埋め込み閲覧コンテキストが、画面の向きをロックする機能を無効化することを許可します。</dd> + <dt><code>allow-pointer-lock</code></dt> + <dd>埋め込み閲覧コンテキストが、 <a href="/ja/docs/WebAPI/Pointer_Lock">Pointer Lock API</a> を使用することを許可します。</dd> + <dt><code>allow-popups</code></dt> + <dd>ポップアップ (<code>window.open</code>, <code>target="_blank"</code>, <code>showModalDialog</code> などによるもの) を許可します。このキーワードが使用されなかった場合、この機能は暗黙に失敗します。</dd> + <dt><code>allow-popups-to-escape-sandbox</code></dt> + <dd>サンドボックス化された文書が、サンドボックスフラグを強制することなく新しいウィンドウを開くことを許可します。これによって、例えば、サードパーティの広告が安全にサンドボックス化される一方、ランディングページには同じ制限が強制されなくなります。</dd> + <dt><code>allow-presentation</code></dt> + <dd>埋め込みを行った者が、 iframe がプレゼンテーションセッションを開始できるかどうかを制御できるようになります。</dd> + <dt><code>allow-same-origin</code></dt> + <dd>コンテンツが通常のオリジンからのものとして扱われることを許可します。このキーワードが使用されなかった場合は、埋め込まれたコンテンツは独自のオリジンからのものとして扱われます。</dd> + <dt><code>allow-scripts</code></dt> + <dd>埋め込み閲覧コンテキストがスクリプトを実行することを許可します (ポップアップウィンドウの生成を除く)。このキーワードが使用されなかった場合は、この操作は許可されません。</dd> + <dt><code>allow-storage-access-by-user-activation</code> {{experimental_inline}}</dt> + <dd>リソースが親のストレージ機能に <a href="/ja/docs/Web/API/Storage_Access_API">Storage Access API</a> でアクセスを要求できるようにします。</dd> + <dt><code>allow-top-navigation</code></dt> + <dd>埋め込み閲覧コンテキストが、最上位の閲覧コンテキストを移動させる (読み込ませる) ことを許可します。このキーワードが使用されなかった場合、この操作は許可されません。</dd> + <dt><code>allow-top-navigation-by-user-activation</code></dt> + <dd>ユーザーの指示で開始された場合に限り、リソースが最上位の閲覧コンテキストを移動させます。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<pre class="brush: bash">Content-Security-Policy: sandbox allow-scripts;</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + <tr> + <td>{{specName("CSP 3.0", "#directive-sandbox", "sandbox")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-sandbox", "sandbox")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.sandbox")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("iframe")}} 要素の {{htmlattrxref("sandbox", "iframe")}} 属性</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/script-src-elem/index.html b/files/ja/web/http/headers/content-security-policy/script-src-elem/index.html new file mode 100644 index 0000000000..8dd1e35631 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/script-src-elem/index.html @@ -0,0 +1,98 @@ +--- +title: 'CSP: script-src-elem' +slug: Web/HTTP/Headers/Content-Security-Policy/script-src-elem +tags: + - CSP + - Content + - Content-Security-Policy + - Directive + - HTTP + - Reference + - Script + - Security + - script-src + - source +translation_of: Web/HTTP/Headers/Content-Security-Policy/script-src-elem +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) における <strong><code>script-src-elem</code></strong> ディレクティブは、 JavaScript の {{HTMLElement("script")}} 要素の有効なソースを指定しますが、 <code>onclick</code> のようなインラインスクリプトのイベントハンドラーは指定しません。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>3</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは {{CSP("script-src")}} ディレクティブを探し、両方ともない場合は、 <code>default-src</code> ディレクティブで代替します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>script-src-elem</code> ポリシーには、1つまたは複数のソースが許可されています。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: script-src-elem <source>; +Content-Security-Policy: script-src-elem <source> <source>; +</pre> + +<p><code>script-src-elem</code> は {{CSP("script-src")}} との組み合わせで使用することができます。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: script-src <source>; +Content-Security-Policy: script-src-elem <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/default-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Fallback_to_script-src" name="Fallback_to_script-src">script-src へのフォールバック</h3> + +<p><code>script-src-elem</code> 存在しない場合、ユーザーエージェントは {{CSP("script-src")}} ディレクティブで代替し、こちらも同様にない場合は、 {{CSP("default-src")}} で代替します。</p> + +<div class="hidden"> +<p>TODO: Add comprehensive examples.</p> +</div> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-script-src-elem", "script-src-elem")}}</td> + <td>{{Spec2("CSP 3.0")}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.script-src-elem")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("script")}}</li> + <li>{{CSP("script-src")}}</li> + <li>{{CSP("script-src-attr")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/script-src/index.html b/files/ja/web/http/headers/content-security-policy/script-src/index.html new file mode 100644 index 0000000000..f5eaee0890 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/script-src/index.html @@ -0,0 +1,176 @@ +--- +title: 'CSP: script-src' +slug: Web/HTTP/Headers/Content-Security-Policy/script-src +tags: + - CSP + - Content + - Content-Security-Policy + - Directive + - HTTP + - Reference + - Script + - Security + - script-src + - source +translation_of: Web/HTTP/Headers/Content-Security-Policy/script-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>script-src</strong></code> ディレクティブは、 JavaScript の情報なソースを指定します。これは {{HTMLElement("script")}} 要素の中に直接読み込まれる URL だけでなく、インラインのスクリプトイベントハンドラー (<code>onclick</code>) やスクリプト実行のトリガーとなりうる <a href="/ja/docs/Web/XSLT">XSLT スタイルシート</a>のようなものも含まれます。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>script-src</code> ポリシーには、1つまたは複数のソースが許可されています。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: script-src <source>; +Content-Security-Policy: script-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("Web/HTTP/Headers/Content-Security-Policy/default-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_case" name="Violation_case">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: script-src https://example.com/</pre> + +<p>以下のスクリプトはブロックされ、読み込みや実行が行われません。</p> + +<pre class="brush: html notranslate"><script src="https://not-example.com/js/library.js"></script></pre> + +<p>なお、インラインのイベントハンドラーも同様にブロックされます。</p> + +<pre class="brush: html notranslate"><button id="btn" onclick="doSomething()"></pre> + +<p>これを {{domxref("EventTarget.addEventListener", "addEventListener")}} の呼び出しに置き換えてください。</p> + +<pre class="brush: js notranslate">document.getElementById("btn").addEventListener('click', doSomething);</pre> + +<h3 id="Unsafe_inline_script" name="Unsafe_inline_script">安全ではないインラインのスクリプト</h3> + +<div class="note"> +<p><strong>注:</strong> インラインスタイルとインラインスクリプトを禁止することは、 CSP が提供する最大のセキュリティ上の利点の一つです。しかし、どうしても使用しなければならない場合は、それらを許可する仕組みがいくつかあります。</p> +</div> + +<p>インラインスクリプトとインラインのイベントハンドラーを許可するために <code>'unsafe-inline'</code> や、インラインブロックに一致するノンスソースまたはハッシュソースを指定することができます。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: script-src 'unsafe-inline'; +</pre> + +<p>上記のコンテンツセキュリティポリシーは、インラインの {{HTMLElement("script")}} 要素を許可します。</p> + +<pre class="brush: html notranslate"><script> + var inline = 1; +</script></pre> + +<p>nonce-source を使用して、特定のインラインスクリプトブロックのみ許可することができます。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: script-src 'nonce-2726c7f26c'</pre> + +<p>同じノンスを {{HTMLElement("script")}} 要素に指定する必要があります。</p> + +<pre class="brush: html notranslate"><script nonce="2726c7f26c"> + var inline = 1; +</script></pre> + +<p>他にも、インラインスクリプトからハッシュを生成することができます。 CSP では sha256, sha384, sha512 に対応しています。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: script-src 'sha256-B2yPHKaXnvFWtRChIbabYmUBFZdVfKKXHbWtWidDVF8='</pre> + +<p>ハッシュを生成するとき、 {{HTMLElement("script")}} タグを含めないようにし、大文字小文字と、ホワイトスペース、特に前後のホワイトスペースに注意してください。</p> + +<pre class="brush: html notranslate"><script>var inline = 1;</script></pre> + +<h3 id="Unsafe_eval_expressions" name="Unsafe_eval_expressions">安全ではない eval 式</h3> + +<p><code>'unsafe-eval'</code> ソース式は、文字列からコードを生成するいくつかのスクリプト実行メソッドを制御します。もし <code>'unsafe-eval'</code> が <code>script-src</code> ディレクティブで指定されていななかった場合、以下のメソッドはブロックされて何の効果も現れません。</p> + +<ul> + <li>{{jsxref("eval", "eval()")}}</li> + <li>{{jsxref("Function", "Function()")}}</li> + <li>メソッドの文字列リテラルを <code>window.setTimeout("alert(\"Hello World!\");", 500);</code> のように渡した場合 + <ul> + <li>{{domxref("window.setTimeout")}}</li> + <li>{{domxref("window.setInterval")}}</li> + <li>{{domxref("window.setImmediate")}}</li> + </ul> + </li> + <li>{{domxref("window.execScript")}} {{non-standard_inline}} (IE < 11 のみ)</li> +</ul> + +<h3 id="strict-dynamic" name="strict-dynamic">strict-dynamic</h3> + +<p><code>'strict-dynamic'</code> ソース式は、マークアップ中のスクリプトに明示的に与えられた信頼が、ノンスやハッシュを伴って、そのルートスクリプトによって読み込まれるすべてのスクリプトに伝搬されることを指定します。同時に、 <code>'self'</code> や <code>'unsafe-inline'</code> のようなホワイトリストやソース表現は無視されます。例えば、 <code>script-src 'strict-dynamic' 'nonce-R4nd0m' https://whitelisted.com/</code> のようなポリシーでは、 <code><script nonce="R4nd0m" src="https://example.com/loader.js"></code> を指定したルートスクリプトの読み込みを許可し、 <code>loader.js</code> で読み込まれたすべてのスクリプトにその信頼性を伝播させますが、 <code>https://whitelisted.com/</code> からのスクリプトの読み込みは、ノンスを伴っているか、信頼されたスクリプトから読み込まれたものでない限り、許可しません。</p> + +<pre class="brush: bash notranslate">script-src 'strict-dynamic' 'nonce-<em>someNonce</em>'</pre> + +<p><em>または</em></p> + +<pre class="brush: bash notranslate">script-src 'strict-dynamic' 'sha256-<em>base64EncodedHash</em>'</pre> + +<p>ユーザーエージェントのスニッフィングを必要とせず、後方互換性のある方法として、 <code>strict-dynamic</code> を指定することができます。.<br> + 以下のポリシー、</p> + +<pre class="brush: bash notranslate">script-src 'unsafe-inline' https: 'nonce-abcdefg' 'strict-dynamic'</pre> + +<p>は、 CSP1 に対応したブラウザーでは <code>'unsafe-inline' https:</code> のように動作し、 CSP2 に対応したブラウザーでは <code>https: 'nonce-abcdefg'</code> のように、CSP3 に対応したブラウザーでは <code>'nonce-abcdefg' 'strict-dynamic'</code> のように動作します。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-script-src", "script-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>変更なし</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-script-src", "script-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.script-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTMLElement("script")}}</li> + <li>{{CSP("script-src-elem")}}</li> + <li>{{CSP("script-src-attr")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/style-src/index.html b/files/ja/web/http/headers/content-security-policy/style-src/index.html new file mode 100644 index 0000000000..a3af102659 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/style-src/index.html @@ -0,0 +1,180 @@ +--- +title: 'CSP: style-src' +slug: Web/HTTP/Headers/Content-Security-Policy/style-src +tags: + - CSP + - Content + - Content-Security-Policy + - Directive + - HTTP + - Reference + - Security + - Style + - source + - style-src +translation_of: Web/HTTP/Headers/Content-Security-Policy/style-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <strong><code>style-src</code></strong> ディレクティブは、スタイルシートの有効なソースを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>1</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">{{CSP("default-src")}} による代替</th> + <td>あり。このディレクティブがない場合、ユーザーエージェントは <code>default-src</code> ディレクティブを探します。</td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>style-src</code> ポリシーには、1つまたは複数のソースが許可されています。</p> + +<pre class="syntaxbox notranslate">Content-Security-Policy: style-src <source>; +Content-Security-Policy: style-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("/ja/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反例</h3> + +<p>この CSP ヘッダーがある場合、</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: style-src https://example.com/</pre> + +<p>以下のスタイルシートはブロックされ、読み込まれません。</p> + +<pre class="brush: html notranslate"><link href="https://not-example.com/styles/main.css" rel="stylesheet" type="text/css" /> + +<style> +#inline-style { background: red; } +</style> + +<style> + @import url("https://not-example.com/styles/print.css") print; +</style></pre> + +<p>{{HTTPHeader("Link")}} ヘッダーで読み込まれるものも同様です。</p> + +<pre class="brush: bash notranslate">Link: <https://not-example.com/styles/stylesheet.css>;rel=stylesheet +</pre> + +<p>インラインの style 属性もブロックされます。</p> + +<pre class="brush: html notranslate"><div style="display:none">Foo</div></pre> + +<p>JavaScript で直接 <code>style</code> 属性を設定したり、 {{domxref("CSSStyleDeclaration.cssText", "cssText")}} を設定したりしたスタイルも同様です。</p> + +<pre class="brush: js notranslate">document.querySelector('div').setAttribute('style', 'display:none;'); +document.querySelector('div').style.cssText = 'display:none;';</pre> + +<p>しかし、要素の {{domxref("HTMLElement.style", "style")}} プロパティに直接設定されたスタイルプロパティはブロックされず、 JavaScript から安全にスタイルを操作することができます。</p> + +<pre class="brush: js notranslate">document.querySelector('div').style.display = 'none';</pre> + +<p>この手の操作は、 CSP の {{CSP("script-src")}} ディレクティブで JavaScript を無効にすることで防ぐことができます。</p> + +<h3 id="Unsafe_inline_styles" name="Unsafe_inline_styles">安全ではないインラインスタイル</h3> + +<div class="note"> +<p><strong>注:</strong> インラインスタイルとインラインスクリプトを禁止することは、 CSP が提供する最大のセキュリティ上の利点の一つです。しかし、どうしても使用しなければならない場合は、それらを許可する仕組みがいくつかあります。</p> +</div> + +<p>インラインスタイルを許可するために、 <code>'unsafe-inline'</code> を指定するか、インラインブロックに一致するノンスソースまたはハッシュソースを指定することができます。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: style-src 'unsafe-inline'; +</pre> + +<p>上記のコンテンツセキュリティポリシーは {{HTMLElement("style")}} 要素やあらゆる要素の <code>style</code> 属性などのインラインスタイルを許可します。</p> + +<pre class="brush: html notranslate"><style> +#inline-style { background: red; } +</style> + +<div style="display:none">Foo</div> +</pre> + +<p>ノンスソースを使用して、特定のインラインスタイルのみ許可することができます。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: style-src 'nonce-2726c7f26c'</pre> + +<p>同じノンスを {{HTMLElement("style")}} 要素にも設定する必要があります。</p> + +<pre class="brush: html notranslate"><style nonce="2726c7f26c"> +#inline-style { background: red; } +</style></pre> + +<p>他にも、インラインスタイルからハッシュを生成することができます。 CSP では sha256, sha384, sha512 に対応しています。</p> + +<pre class="brush: bash notranslate">Content-Security-Policy: style-src 'sha256-a330698cbe9dc4ef1fb12e2ee9fc06d5d14300262fa4dc5878103ab7347e158f'</pre> + +<p>ハッシュを生成するときは、 {{HTMLElement("style")}} タグを含めないようにし、大文字小文字と、ホワイトスペース、特に前後のホワイトスペースに注意してください。</p> + +<pre class="brush: html notranslate"><style>#inline-style { background: red; }</style></pre> + +<h3 id="Unsafe_style_expressions" name="Unsafe_style_expressions">安全ではない style 式</h3> + +<p><code>'unsafe-eval'</code> ソース式は、文字列からスタイル宣言を生成するいくつかのスタイルメソッドを制御します。もし <code>'unsafe-eval'</code> が <code>style-src</code> ディレクティブで指定されていななかった場合、以下のメソッドはブロックされて何の効果も現れません。</p> + +<ul> + <li>{{domxref("CSSStyleSheet.insertRule()")}}</li> + <li>{{domxref("CSSGroupingRule.insertRule()")}}</li> + <li>{{domxref("CSSStyleDeclaration.cssText")}}</li> +</ul> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-style-src", "style-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>No changes.</td> + </tr> + <tr> + <td>{{specName("CSP 1.1", "#directive-style-src", "style-src")}}</td> + <td>{{Spec2('CSP 1.1')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.style-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{CSP("style-src-elem")}}</li> + <li>{{CSP("style-src-attr")}}</li> + <li>{{HTTPHeader("Link")}} header</li> + <li>{{HTMLElement("style")}}, {{HTMLElement("link")}}</li> + <li>{{cssxref("@import")}}</li> + <li>{{domxref("CSSStyleSheet.insertRule()")}}</li> + <li>{{domxref("CSSGroupingRule.insertRule()")}}</li> + <li>{{domxref("CSSStyleDeclaration.cssText")}}</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/trusted-types/index.html b/files/ja/web/http/headers/content-security-policy/trusted-types/index.html new file mode 100644 index 0000000000..b4ec5ee180 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/trusted-types/index.html @@ -0,0 +1,70 @@ +--- +title: 'CSP: trusted-types' +slug: Web/HTTP/Headers/Content-Security-Policy/trusted-types +tags: + - CSP + - Directive + - HTTP + - Security + - ディレクティブ +translation_of: Web/HTTP/Headers/Content-Security-Policy/trusted-types +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の <code><strong>trusted-types</strong></code> {{experimental_inline}} ディレクティブは、既知の DOM XSS シンクの使用を、文字列の代わりにスプーフィング不可能な型付きの値のみを受け入れる定義済みの関数のセットに制限するようにユーザエージェントに指示します。これにより、作者は DOM への値の書き込みを守るルールを定義することができ、 DOM XSS 攻撃の対象をウェブアプリケーションのコードベースの小さな孤立した部分に減らすことができ、監視やコードレビューが容易になります。このディレクティブは、 Trusted Types API から <code>TrustedTypes.createPolicy</code> で作成された信頼できる型のポリシー名のホワイトリストを宣言します。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre>Content-Security-Policy: trusted-types; +Content-Security-Policy: trusted-types <policyName>; +Content-Security-Policy: trusted-types <policyName> <policyName> 'allow-duplicates'; +</pre> + +<dl> + <dt><DOMString></dt> + <dd>Trusted Type ポリシー名とすることができる任意の文字列です。</dd> + <dt><code>'allow-duplicates'</code></dt> + <dd>ポリシー名が既に使用されていても、生成を許可します。</dd> +</dl> + +<h2 id="Examples" name="Examples">例</h2> + +<p>TODO</p> + +<h2 id="Polyfill" name="Polyfill">ポリフィル</h2> + +<p>A <a href="https://github.com/w3c/webappsec-trusted-types#polyfill">Trusted Types のポリフィル</a>が Github 上で利用できます。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td><a href="https://w3c.github.io/webappsec-trusted-types/dist/spec/">Trusted Types</a></td> + <td>Draft</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("http.headers.csp.Content-Security-Policy.trusted-types")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li><a href="/ja/docs/Glossary/Cross-site_scripting">クロスサイトスクリプティング (XSS)</a></li> + <li><a href="https://developers.google.com/web/updates/2019/02/trusted-types">Google Developers: Intro to Trusted-Types</a></li> + <li>Trusted Types with <a href="https://github.com/cure53/DOMPurify#what-about-dompurify-and-trusted-types">DOMPurify</a> XSS sanitizer</li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/upgrade-insecure-requests/index.html b/files/ja/web/http/headers/content-security-policy/upgrade-insecure-requests/index.html new file mode 100644 index 0000000000..d8683ba580 --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/upgrade-insecure-requests/index.html @@ -0,0 +1,90 @@ +--- +title: 'CSP: upgrade-insecure-requests' +slug: Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests +tags: + - CSP + - HTTP + - セキュリティ + - ディレクティブ + - リファレンス +translation_of: Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) <code><strong>upgrade-insecure-requests</strong></code> ディレクティブは、ユーザーエージェントに、すべてのサイトの安全でないURL (HTTP経由で提供されるURL) をセキュリティで保護された URL (HTTPSを介して提供されるもの) で置き換えられたかのように処理するよう指示します。このディレクティブは、書き換えが必要な安全ではない古い URL が多数存在するウェブサイトのためのものです。</p> + +<p><code>upgrade-insecure-requests</code> ディレクティブは、 {{CSP("block-all-mixed-content")}} よりも前に処理され、もし設定されていれば後者は何もしません。どちらかのディレクティブを設定することをお勧めしますが、 HTTP にリダイレクトした後で HTTPS を強制することができない古いブラウザーで HTTPS を強制させたくない限り、両方を指定することはできません。</p> + +<p><code>upgrade-insecure-requests</code> ディレクティブは、第三者のサイトのリンクを経由してサイトにアクセスしたユーザーが最上位のナビゲーション用に HTTPS にアップグレードされることを保証しないため、 {{HTTPHeader("Strict-Transport-Security")}} ({{Glossary("HSTS")}}) ヘッダーを置換せず、ユーザーがSSLストリッピング攻撃の対象にならないように、適切な <code>max-age</code> を設定するようにしてください。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox">Content-Security-Policy: upgrade-insecure-requests;</pre> + +<h2 id="Examples" name="Examples">例</h2> + +<pre>// ヘッダー +Content-Security-Policy: upgrade-insecure-requests; + +// meta タグ +<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> +</pre> + +<p>HTTP から HTTPS への移行を望むドメイン example.com に上記のヘッダーを設定すると、ページ移動を伴わない安全ではないリソースのリクエストが自動的にアップグレードされます (第三者のリクエストが自分のものと同様に)。</p> + +<pre class="brush: html"><img src="http://example.com/image.png"> +<img src="http://not-example.com/image.png"></pre> + +<p>これらの URL は、リクエストが行われる前に書き直されます。つまり、安全でない要求がネットワークに侵入しないようにします。なお、要求されたリソースが実際に HTTPS 経由で利用可能ではない場合、リクエストは HTTP で代替されずに失敗することに注意してください。</p> + +<pre class="brush: html"><img src="https://example.com/image.png"> +<img src="https://not-example.com/image.png"></pre> + +<p>第三者のリソースへのナビゲーションをアップグレードすると、破壊の可能性が大幅に高まりますので、これらはアップグレードされません。</p> + +<pre class="brush: html"><a href="https://example.com/">Home</a> +<a href="http://not-example.com/">Home</a></pre> + +<h3 id="Finding_insecure_requests" name="Finding_insecure_requests">安全ではないリクエストの発見</h3> + +<p>{{HTTPHeader("Content-Security-Policy-Report-Only")}} ヘッダーと {{CSP("report-uri")}} ディレクティブを利用して、強制ポリシーと報告されたポリシーを次のように設定することができます。</p> + +<pre>Content-Security-Policy: upgrade-insecure-requests; default-src https: +Content-Security-Policy-Report-Only: default-src https:; report-uri /endpoint</pre> + +<p>このようにして、安全なサイト上の安全でない要求は引き続きアップグレードされますが、監視ポリシーに違反した場合だけが、安全でないリソースがエンドポイントに報告されます。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("Upgrade Insecure Requests", "#delivery", "upgrade-insecure-requests")}}</td> + <td>{{Spec2('Upgrade Insecure Requests')}}</td> + <td>初回定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力したいのであれば、 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.upgrade-insecure-requests")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{HTTPHeader("Upgrade-Insecure-Requests")}} ヘッダー</li> + <li>{{HTTPHeader("Strict-Transport-Security")}} ({{Glossary("HSTS")}}) ヘッダー</li> + <li>{{CSP("block-all-mixed-content")}}</li> + <li><a href="/ja/docs/Web/Security/Mixed_content">混合コンテンツ</a></li> +</ul> diff --git a/files/ja/web/http/headers/content-security-policy/worker-src/index.html b/files/ja/web/http/headers/content-security-policy/worker-src/index.html new file mode 100644 index 0000000000..2164488eee --- /dev/null +++ b/files/ja/web/http/headers/content-security-policy/worker-src/index.html @@ -0,0 +1,97 @@ +--- +title: 'CSP: worker-src' +slug: Web/HTTP/Headers/Content-Security-Policy/worker-src +tags: + - CSP + - HTTP + - セキュリティ + - ディレクティブ + - リファレンス +translation_of: Web/HTTP/Headers/Content-Security-Policy/worker-src +--- +<div>{{HTTPSidebar}}</div> + +<p>HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) <code><strong>worker-src</strong></code> ディレクティブは、 {{domxref("Worker")}}, {{domxref("SharedWorker")}}, {{domxref("ServiceWorker")}} スクリプトの有効なソースを指定します。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">CSP バージョン</th> + <td>3</td> + </tr> + <tr> + <th scope="row">ディレクティブ種別</th> + <td>{{Glossary("Fetch directive", "フェッチディレクティブ")}}</td> + </tr> + <tr> + <th scope="row">フォールバック</th> + <td> + <p>このディレクティブがない場合、ユーザーエージェントはワーカーの実行の管理のために、最初に {{CSP("child-src")}} ディレクティブ、次に {{CSP("script-src")}} ディレクティブ、最後に {{CSP("default-src")}} ディレクティブを探します。</p> + + <p>Chrome 59 以降は {{CSP("child-src")}} ディレクティブを飛ばします。</p> + + <p>Edge 17 は {{CSP("script-src")}} ディレクティブを飛ばします (<a href="https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/17415478/">bug</a>)。</p> + </td> + </tr> + </tbody> +</table> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<p><code>worker-src</code> ポリシーには1つ以上のソースを指定することができます。</p> + +<pre class="syntaxbox">Content-Security-Policy: worker-src <source>; +Content-Security-Policy: worker-src <source> <source>; +</pre> + +<h3 id="Sources" name="Sources">ソース</h3> + +<p>{{page("Web/HTTP/Headers/Content-Security-Policy/default-src", "Sources")}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Violation_cases" name="Violation_cases">違反の場合</h3> + +<p>この CSP ヘッダーが与えられている時、</p> + +<pre class="brush: bash">Content-Security-Policy: worker-src https://example.com/</pre> + +<p>{{domxref("Worker")}}, {{domxref("SharedWorker")}}, {{domxref("ServiceWorker")}} はブロックされ、読み込まれません。</p> + +<pre class="brush: html"><script> + var blockedWorker = new Worker("data:application/javascript,..."); + blockedWorker = new SharedWorker("https://not-example.com/"); + navigator.serviceWorker.register('https://not-example.com/sw.js'); +</script></pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">状態</th> + <th scope="col">備考</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{specName("CSP 3.0", "#directive-worker-src", "worker-src")}}</td> + <td>{{Spec2('CSP 3.0')}}</td> + <td>初回定義。</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2> + +<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力したいのであれば、 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p> + +<p>{{Compat("http.headers.csp.worker-src")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{HTTPHeader("Content-Security-Policy")}}</li> + <li>{{domxref("Worker")}}, {{domxref("SharedWorker")}}, {{domxref("ServiceWorker")}}</li> +</ul> |