> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ja/hacking-tools/exploitation/csp-bypass.md).

# CSP 回避

CSP回避は、承認されたテスト中の Content Security Policy の弱点、危険な許可リスト、およびブラウザ固有の挙動を確認するための研究リソースです。

[CSPバイパス](https://cspbypass.com/) Content Security Policy の制御を評価するための調査を収集します。自分が所有している、またはテストする許可を得ているシステムでポリシーを検証するために使用してください。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F9jMcNmkKNQCChy8feUL9%2Fimage.png?alt=media&amp;token=6bce4466-7795-4ce4-8319-d2c1e4b4e8bb" alt=""><figcaption></figcaption></figure>

### 確認すべき項目

* すべてを記録する `Content-Security-Policy` ヘッダーとポリシー `meta` タグ。
* 確認する `script-src`, `object-src`, `base-uri`、および `frame-ancestors` まず。
* nonce、ハッシュ、 `strict-dynamic`、ワイルドカード、そして第三者ソースを記録します。

### 検証ワークフロー

1. ブラウザの開発者ツールまたはインターセプト用プロキシを使ってポリシーを取得します。
2. 注入ポイントと、その利用可能な実行コンテキストを特定します。
3. 許可されたソースを、CSPバイパス調査およびブラウザの挙動と照合します。
4. ポリシーの弱点を示す、最小限で制御された証明を使用します。
5. ポリシー、ブラウザのバージョン、前提条件、および観測された影響を文書化します。

### 高リスクのポリシーパターン

| パターン              | 重要な理由                                                 |
| ----------------- | ----------------------------------------------------- |
| `script-src *`    | 任意の HTTPS スクリプトのオリジンが実行可能になる可能性があります。                 |
| `'unsafe-inline'` | インラインスクリプトの注入によって、意図した制限を回避できる場合があります。                |
| 広範なワイルドカード        | サブドメインの乗っ取りや忘れられたホストが実行経路を作る可能性があります。                 |
| 古い第三者ホスト          | 信頼されたオリジンが JSONP、リダイレクト、または攻撃者制御のコンテンツを公開している場合があります。 |
| 欠落 `object-src`   | レガシーなプラグインコンテンツが引き続き許可されている可能性があります。                  |

### 強化のベースライン

まずは厳格なポリシーを出発点として使用します。ソースリストはアプリケーション要件に合わせて調整してください。

```http
Content-Security-Policy: default-src 'none'; script-src 'nonce-<random-per-response>' 'strict-dynamic'; style-src 'self'; img-src 'self' data:; connect-src 'self'; font-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'
```

* 各レスポンスごとに一意の nonce を生成します。
* 未使用の第三者スクリプトソースを削除します。
* 適用前に、レポートのみモードでポリシー変更を展開します。

### 報告チェックリスト

影響を受ける URL、完全なポリシー、および脆弱なディレクティブを含めます。必要な注入プリミティブとテストしたブラウザを記述します。最小限の再現可能な影響を明記します。問題を解消する、最も範囲の狭いポリシー変更を推奨します。

### 参考資料

* [CSPバイパス](https://cspbypass.com/)
* [MDN: Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)
* [CSP Evaluator](https://csp-evaluator.withgoogle.com/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/hacking-tools/exploitation/csp-bypass.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
