Content Security Policy
コンテンツセキュリティポリシー
コンテンツセキュリティポリシー(CSP)は、ブラウザコンテンツのためのHTTPルールです。どのファイルが読み込まれ、どのスクリプトが実行されるかを制限します。
もう一つの例
銀行のSPAは最初に`Content-Security-Policy-Report-Only`を使用し、インラインハンドラーを削除します。その後、`script-src 'nonce-r4…' 'strict-dynamic'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`を強制します。すべてのレスポンスには、新しく推測しにくいnonceが付与されます。サンプリングされた違反レポートには、顧客のURLは記録されません。
主な部分
- 01ポリシー配信
- 02指示の取得と文書化
- 03違反報告とロールアウト
以下の場合に使用します
テスト済みの厳格なCSPを追加の防御策として使用してください。できればnonceやハッシュを使用してください。変更されたポリシーを完全に有効にする前にレポートを確認してください。
以下の場合は使用しないでください
幅広い `*` または `unsafe-inline` ルールを強力なセキュリティとして扱ったり、推測可能な nonce を再利用したりしないでください。CSP は通常の XSS 防止に代わるものではありません。
コードで使用する名前
Content-Security-Policy response header with nonces/hashes and restrictive directives 出荷前に
Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback.
Outcome:Complete the task with コンテンツセキュリティポリシー (Content Security Policy)。 User context:銀行のSPAは最初に`Content-Security-Policy-Report-Only`を使用し、インラインハンドラーを削除します。その後、`script-src 'nonce-r4…' 'strict-dynamic'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'`を強制します。すべてのレスポンスには、新しく推測しにくいnonceが付与されます。サンプリングされた違反レポートには、顧客のURLは記録されません。 Technical concept or control:コンテンツセキュリティポリシー (Content Security Policy)。 Why it fits:テスト済みの厳格なCSPを追加の防御策として使用してください。できればnonceやハッシュを使用してください。変更されたポリシーを完全に有効にする前にレポートを確認してください。 Do not use it when:幅広い `*` または `unsafe-inline` ルールを強力なセキュリティとして扱ったり、推測可能な nonce を再利用したりしないでください。CSP は通常の XSS 防止に代わるものではありません。 Engineering requirements: Define inputs, outputs, contracts, and rules that must always hold. Set authorization and input checks. Define failures, timeouts, retries, one-time effects, data moves, and compatibility limits. Operations: Add useful signals and logs that hide sensitive data. Set capacity limits and write an operator guide. Test recovery and rollback. Acceptance criteria: Contract and failure-path tests pass. Data and authorization rules still hold during retries and partial failures. Check performance limits, monitoring, recovery, and rollback. Evidence and limits (evidence boundary):きちんとした書類でも、まだドラフトやリリース候補、あるいは最終版かもしれません。ステータスや、ブラウザやプラットフォームの対応状況を確認しましょう。 Unknowns to confirm: Where the code runs, data stores, traffic shape, consistency needs, and the security boundary. Also confirm the compatibility period, service goals, and rollback limits.
このリクエストを確認する
Review how コンテンツセキュリティポリシー (Content Security Policy) is used now. Definition: コンテンツセキュリティポリシー(CSP)は、ブラウザコンテンツのためのHTTPルールです。どのファイルが読み込まれ、どのスクリプトが実行されるかを制限します。 Release checks: Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.