--- 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 ---
HTTP の {{HTTPHeader("Content-Security-Policy")}} (CSP) の sandbox ディレクティブは、 {{HTMLElement("iframe")}} の {{htmlattrxref("sandbox", "iframe")}} 属性と同様に、要求されたリソースに対してサンドボックスを有効にします。これは、ポップアップの防止、プラグインやスクリプトの実行の防止、同一オリジンポリシーの強制などを含むページ操作の制限を適用します。
| CSP バージョン | 1.1 / 2 |
|---|---|
| ディレクティブ種別 | {{Glossary("Document directive", "文書ディレクティブ")}} |
| このディレクティブは {{HTMLElement("meta")}} 要素や {{HTTPHeader("Content-Security-policy-Report-Only")}} ヘッダーフィールドでは対応していません。 | |
Content-Security-Policy: sandbox; Content-Security-Policy: sandbox <value>;
<value> は省略可能で、以下の値の内の一つです。
allow-downloads-without-user-activation {{experimental_inline}}allow-formsallow-modalsallow-orientation-lockallow-pointer-lockallow-popupswindow.open, target="_blank", showModalDialog などによるもの) を許可します。このキーワードが使用されなかった場合、この機能は暗黙に失敗します。allow-popups-to-escape-sandboxallow-presentationallow-same-originallow-scriptsallow-storage-access-by-user-activation {{experimental_inline}}allow-top-navigationallow-top-navigation-by-user-activationContent-Security-Policy: sandbox allow-scripts;
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{specName("CSP 3.0", "#directive-sandbox", "sandbox")}} | {{Spec2('CSP 3.0')}} | 変更なし |
| {{specName("CSP 1.1", "#directive-sandbox", "sandbox")}} | {{Spec2('CSP 1.1')}} | 初回定義 |
{{Compat("http.headers.csp.Content-Security-Policy.sandbox")}}