> ## Documentation Index
> Fetch the complete documentation index at: https://ccsafetynet.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# セキュリティモデル

> CC Safety Net の trust model：AI から shell への境界、各 safety level の保証、configuration recovery boundary、開示分類。

CC Safety Net は、AI コーディングエージェントなどの信頼できない command source と execution environment の間にあります。このページでは、trust boundary、safety-level guarantee、configuration failure handling、secret protection、attack surface を説明します。脆弱性の報告は[セキュリティポリシー](/docs/ja/security)を参照してください。

CC Safety Net は、対応するコーディングエージェントのツール呼び出しに対する best-effort の静的な実行前ポリシーゲートです。OS sandbox、privilege boundary、インストール済み連携を回避する command に対する保護ではありません。

## Trust boundary

### 主境界：command source から execution environment

中心的な trust boundary は、AI コーディングエージェントと host shell の間にあります。CC Safety Net が gatekeeper です。

* **信頼できない側**：AI エージェントが生成する command string。エージェントは prompt injection、混乱した context、敵対的 instruction によって破壊的コマンドを生成する可能性があるため、潜在的に hostile として扱います。
* **実行側**：command を実行する host shell。

対応 platform の shell tool に到達する各 command は、実行を許可する前に analysis engine を通ります。analysis が block reason を返すと、command を拒否します。

境界は、対応する tool name と shape で終わります。adapter が command-execution capability を与えるのは、連携ごとに定めた正確な tool name だけです。unknown tool は保守的な policy-file、Git-metadata、sensitive-path inspection を受けますが、その text を shell command として扱いません。インストール済み連携を完全に回避する command は境界外です。

### 副境界

4 つの副境界は、外部 source から CC Safety Net 内に入ります。各 source は analysis に影響する前に validate します。

| 境界                   | Source                                                                   | 検証方法                                                                                                                                                             |
| -------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ユーザー設定               | disk 上の `policy.json` と rule configuration                               | parse と schema validation を実行。拒否された candidate は適用せず、runtime は通常作業を拒否せずに fallback する（下記の [Configuration recovery boundary](#configuration-recovery-boundary) を参照） |
| Rulebook source      | GitHub または local directory から取得する rulebook                               | remote rulebook は lockfile の SHA-256 digest で integrity check。検証できない source は rule を提供しない                                                                        |
| Hook input JSON      | 各エージェントが stdin に送る JSON payload                                          | 防御的に parse。malformed または oversized input は deny になる                                                                                                              |
| Environment variable | level と capability flag、および path override（`CC_SAFETY_NET_*`、`TMPDIR` など） | 明示的に読み取り。security-critical value は信頼しない                                                                                                                          |

## 各 safety level の保証

Standard、strict、paranoid は、`fail_closed`、`paranoid_rm`、`paranoid_interpreters` の 3 capability に default を与える preset です。保証は level ごとに異なります。

| Level                                             | 保証                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Standard](/docs/ja/configuration/modes#既定モード)         | 認識可能な destructive command に対する **best-effort** protection。dynamic executable、substitution で組み立てた command structure、検証不能な recursive-delete target、組み込み sensitive path の独立した metadata-only check を意図的に許可する。安全に見える unparseable text は通し、destructive に見える text は conservative heuristic で検出する |
| [Strict](/docs/ja/configuration/modes#strict-mode)     | fail-closed capability を追加。unparseable input は通さず拒否し、`rm -rf "$target"` などの検証不能な destructive target と metadata-only sensitive-path discovery を block する                                                                                                                                   |
| [Paranoid](/docs/ja/configuration/modes#paranoid-mode) | Strict に 2 つの制限を追加。現在の working directory 内でも temp 以外の[再帰的な強制削除](/docs/ja/configuration/modes#paranoid-rm-check)を block し、内容に関係なく[すべての interpreter one-liner](/docs/ja/configuration/modes#paranoid-interpreters)を block する                                                                          |

<Warning>
  Standard mode は **adversarial-grade ではありません**。dynamic `rm -rf` target は standard で一律に block されません。`rm -rf "$target"` は standard では allow され、strict または paranoid だけで block されます。command が prompt injection または他の adversarial context から来る可能性がある場合、strict または paranoid が必要です。
</Warning>

secret protection が有効な間、safety level は一致した sensitive **content** access または user-configured deny path とその子孫を緩和しません。Catastrophic protection は常に適用します。root または user home directory の recursive deletion、protected Git metadata の destructive change、canonical user `policy.json` の destructive change が含まれます。

<span id="configuration-recovery-boundary" />

## Configuration recovery boundary

Configuration は trust boundary であり kill switch ではありません。無効な configuration は 2 つの runtime state のいずれかになり、**無効であることだけを理由に通常作業を拒否しません**。

* **`ready`**：すべての active source を validate 済み。
* **`degraded`**：candidate source を拒否し、代わりに安全なものを適用。検証不能な rule source は drop されて rule を提供しない。drift したか無効な local rulebook は digest-verified cache を維持する。duplicate rulebook name は最初の claim を維持する。読み取れない policy file は salvage した policy または built-in protective default に fallback する。

拒否した candidate を active として扱うことはありません。source を drop すると、その source が提供した denial がなくなります。これは設定した policy と比べて実際の enforcement reduction であり、security-neutral とせず、すべての surface で報告します。ただし drop で built-in rule を弱めることはできません。rulebook は blocking rule だけを提供し、読み取れない `rule.json` を無視すると、その `overrides` が無効にした built-in が復元されます。1 つの例外は scope が限定され、文書化されています。`transparent_wrappers` は `rule.json` にあるため、読み取れない `rule.json` は、その scope で built-in analysis が展開する wrapped command を減らします。設定できないことを理由に何も deny しないため、代わりに command または path を allowlist することはありません。

Policy-file protection と Git-metadata protection は configuration snapshot の読み込み**前**に評価するため、両 state に同じように適用され、configuration metadata を持ちません。

すべての failure row、それが生成する fallback、recovery command という完全な contract は[設定の復旧](/docs/ja/configuration/recovery)にあります。

## Fail-closed enforcement

Fail-closed は、analysis 自身を完了できない場合の**その 1 回のツール呼び出し**に適用します。予期しない analyzer failure、parse できない input、resource limit 到達が該当します。無効な configuration の動作を示すものではありません。

<Steps>
  <Step title="Hook の entry point">
    hook adapter は analysis call を try/catch で囲みます。analysis が throw すると、command を続行させず、"failed closed" reason の deny decision を出力します。これはすべての stdin-based hook agent（Antigravity CLI、Claude Code、Cursor、Gemini CLI、GitHub Copilot CLI、Kimi Code）に適用します。
  </Step>

  <Step title="Plugin と extension の entry point">
    Amp Code、OpenCode、OpenClaw、Pi の process 内連携は同じ pattern を使います。analysis error を捕捉し、block message として再表示するため、platform は denied command として扱います。Codex は plugin として install されますが、共有 stdin hook entry point を実行するため、上の step に含まれます。Hermes Agent は両方を重ねます。管理対象 Python plugin が同じ stdin hook（`cc-safety-net hook --hermes-agent`）を呼び出し、analysis を完了できない場合は plugin 自身が call を block します。missing `npx`、解決できない working directory または Hermes session record、spawn failure、30 秒の timeout、non-zero analyzer exit、読み取れない output が対象です。各 agent の model は[連携アーキテクチャ](/docs/ja/guides/integration-architecture)を参照してください。
  </Step>

  <Step title="形式が不正または大きすぎる tool input">
    信頼できない recursive tool input は、64 object level、10,000 visited value、10,000 own key、string ごとに 1 MiB、aggregate string data 4 MiB に制限します。hook stdin は raw byte 8 MiB が上限です。いずれかの boundary を超えると call を deny します。
  </Step>

  <Step title="Parser resource の枯渇">
    131,072 UTF-16 code unit を超える input、16,384 を超える word、64 level を超える nesting は、不完全に解析せず deny します。別の 16,384 derived token budget は、initial parse 後に nested / embedded command が追加する作業を制限します。[Parser と runtime dependency surface](/docs/ja/guides/architecture#parsers-and-the-runtime-dependency-surface)を参照してください。どちらも standard を含む**すべての** safety level に適用します。
  </Step>

  <Step title="Strict mode の動作">
    [Strict mode](/docs/ja/configuration/modes#strict-mode)は、shell parser が安全に tokenize できない command まで fail-closed を拡張します。このため unparseable input を通さず block します。Standard mode は安全に見える unparseable text を許可します。
  </Step>
</Steps>

<Note>
  無効な configuration は意図的にこの一覧に含めません。拒否した rule source は drop し、読み取れない policy file は protective default に fallback するため、通常作業を続行できます。上記の [Configuration recovery boundary](#configuration-recovery-boundary) を参照してください。
</Note>

理由は[設計原則](/docs/ja/guides/design-principles#解析を完了できない場合は-fail-closed)を参照してください。

## Secret redaction

command または segment text は、audit log への書き込みまたはエージェントへの返却前に、自動 secret redaction を通ります。redactor は PEM private key、database URL environment variable、一般的な secret-bearing env assignment、一般的な secret HTTP header、URL credential、presigned-URL signature query parameter（`x-amz-signature`、`x-goog-signature`、`sig`、`signature`）、既知の provider token prefix（GitHub、Slack、npm、Stripe、PyPI）、JWT、AWS access key ID を削除します。一致した各 value は `<redacted>` に置き換えます。

Redaction は保守的な pattern-based 処理です。command argument に現れた secret の漏えい risk を減らしますが、**認識済み credential shape に限定**されます。absolute filesystem path、project / directory name、hostname、IP address、username、pattern list にない形式の credential はそのまま保持します。新しい secret format は定期的に現れるため、エージェントが実行する command に実際の credential を pipe しないでください。完全な redaction scope は[監査ログのリファレンス](/docs/ja/reference/audit-log#シークレットの編集)を参照してください。

同じ制限が `cc-safety-net explain` にも適用されます。実際の trace は、指定した command text、parsed token、home directory を含む absolute path を保持します。貼り付ける前に trace を確認してください。[Explain trace](/docs/ja/reference/explain-trace)を参照してください。

## Attack surface

threat model は、主な attack surface と mitigation を列挙します。

| Attack surface                        | 攻撃者の試み                                                                                                               | Mitigation                                                                                                                                                                                                                                           |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Shell command parser**              | parser edge case（通常でない quoting、nested substitution、operator ambiguity）を使う command string を作り、destructive payload を隠す | unclosed-quote guard は raw string を 1 segment として返す。dynamic substitution を検出できるよう variable reference を展開せず保持する。strict mode は unparseable command を block。parser error は fail-closed を発生させる                                                           |
| **Wrapper と interpreter の stripping** | `sudo`、`env`、`bash -c`、interpreter one-liner の背後に destructive command を隠す                                            | wrapper を反復して削除（iteration cap あり）。shell wrapper と interpreter code を最大 10 level まで再帰的に再解析。`transparent_wrappers` で宣言した command は、解析前に見える child まで展開                                                                                                  |
| **Sensitive-file access**             | command、path、search、patch shape を使い、`.env`、`~/.ssh/id_*`、`~/.aws/credentials` などの credential を読み取るか発見する              | Sensitive-path protection は、対応する command、path、search、patch shape と unknown-tool fallback inspection を対象にする。user-configured deny path とその子孫は最初に一致し、緩和しない。strict と paranoid では metadata-only discovery も block。一般的な read boundary ではなく上限付き pattern set |
| **rm analysis の path traversal**      | symlink または path trick で危険な `rm -rf` target を classification から通過させる                                                 | target を canonical path に解決。既知の temp dir 外を指す `$TMPDIR` override を検出。residual TOCTOU window は残る（[既知の制限](/docs/ja/guides/known-limitations#symlink-toctou-risk)を参照）                                                                                        |
| **Rulebook supply chain**             | GitHub source から malicious rulebook を提供する                                                                            | remote rulebook は lockfile に対して SHA-256 verification と schema validation を受ける。malicious rulebook は rule を追加できるが built-in blocking を削除できない                                                                                                            |
| **Audit log での secret leakage**       | disk 上の audit log に secret を書き込ませる                                                                                   | log write 前に `redactSecrets` を実行。pattern list を段階的に保守                                                                                                                                                                                                |
| **Hook input parsing**                | malformed JSON で hook を crash させる                                                                                    | `JSON.parse` failure は crash ではなく deny を発生。platform adapter が追加 validation を実行                                                                                                                                                                       |
| **Audit log path traversal**          | logs directory 外に書き込む session ID を作る                                                                                 | session ID を filesystem-safe form に sanitize し、length cap を適用して `.` と `..` を拒否                                                                                                                                                                       |

network-level attack と agent platform 自身への attack は範囲外です。CC Safety Net は command analysis 中に network request を行わず、network layer を持ちません。resource exhaustion は containment ではなく bound で処理します。parser または tool-input limit を超える input は、不完全に解析せず deny します。

## 開示分類

[セキュリティポリシー](/docs/ja/security)に完全な報告手順があります。次の表で report type を選択します。

| Class                                                          | 例                                                                                                                                                                                                                                                                                                                                            | Channel         |
| -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| **Bug**：CC Safety Net が destructive command を阻止できなかった          | coverage gap（rule がまだ block しない command shape）、parser / tokenizer / wrapper-analysis edge case、command を通過させる analysis error、安全な command を block する false positive                                                                                                                                                                           | 公開 GitHub issue |
| **Vulnerability**：CC Safety Net が実行すべきでない harmful action を実行した | block message、audit log、diagnostics、debug output、false-positive report prefill からの secret leakage（redaction bypass を含む）。crafted input が intended directory 外に書き込む audit logging / configuration handling の path traversal または filesystem issue。rulebook integrity を含む公開 npm package または plugin distribution の supply-chain / packaging issue | 非公開開示           |

coverage gap では command shape だけを報告してください。すぐに貼り付けて使える weaponized prompt-injection payload を含めないでください。両 submission channel は[セキュリティポリシー](/docs/ja/security)を参照してください。

## 関連ページ

* [セキュリティポリシー](/docs/ja/security)：bug または vulnerability の報告方法。
* [設定の復旧](/docs/ja/configuration/recovery)：完全な `ready` / `degraded` contract。
* [設計原則](/docs/ja/guides/design-principles)：fail-closed と semantic analysis の理由。
* [既知の制限](/docs/ja/guides/known-limitations)：symlink TOCTOU window などの residual risk。
* [監査ログ](/docs/ja/reference/audit-log)：redacted command record の書き込み場所。
