--- 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-forms
allow-modals
allow-orientation-lock
allow-pointer-lock
allow-popups
window.open
, target="_blank"
, showModalDialog
などによるもの) を許可します。このキーワードが使用されなかった場合、この機能は暗黙に失敗します。allow-popups-to-escape-sandbox
allow-presentation
allow-same-origin
allow-scripts
allow-storage-access-by-user-activation
{{experimental_inline}}allow-top-navigation
allow-top-navigation-by-user-activation
Content-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')}} | 初回定義 |
このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 https://github.com/mdn/browser-compat-data をチェックアウトしてプルリクエストを送信してください。
{{Compat("http.headers.csp.Content-Security-Policy.sandbox")}}