一键导入
tobari-immune
帳の免疫システム -- 証跡ログから攻撃・バイパスパターンを検出し、 自己修復パッチ(抗体)を生成する。生物の免疫系のように、 一度検出した攻撃パターンを記憶し、二度と同じ手口を通さない。 「/tobari-immune」で手動実行、または Stop hook から自動呼び出し可能。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
帳の免疫システム -- 証跡ログから攻撃・バイパスパターンを検出し、 自己修復パッチ(抗体)を生成する。生物の免疫系のように、 一度検出した攻撃パターンを記憶し、二度と同じ手口を通さない。 「/tobari-immune」で手動実行、または Stop hook から自動呼び出し可能。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
帳の自己進化スキル。Claude Code の公式 API 変更を自動追跡し、 tobari のガバナンスフレームワークを最新状態に保つ。 Hook イベント・Permission 構文・出力フィールドの差分を検出し、 安全な変更は自動修正、大きな変更はユーザー承認を経て適用する。 エイリアス: /evolve 「/tobari-evolve」「/evolve」で呼び出される。
テストカバレッジを分析し、最もインパクトの大きいテスト追加を提案する。 「テスト改善」「カバレッジ」「test-coverage」で呼び出される。 モジュールごとのカバレッジ分析、未テストのエッジケース検出、 テストスケルトンの自動生成を行う。
帳をおろしてプロジェクトを開始する(STG0 儀式)。 自然言語の意図を構造化された契約に変換し、tobari-session.json を生成する。 エイリアス: /orose, /startproject 「/tobari」「帳をおろす」「/orose」で呼び出される。
セッション引き継ぎを実行し、HANDOFF.md を更新する
このスキルは /tobari に統合されました。/tobari <feature> を使用してください。 claude-code-orchestra 互換のエイリアスとして維持されています。
| name | tobari-immune |
| description | 帳の免疫システム -- 証跡ログから攻撃・バイパスパターンを検出し、 自己修復パッチ(抗体)を生成する。生物の免疫系のように、 一度検出した攻撃パターンを記憶し、二度と同じ手口を通さない。 「/tobari-immune」で手動実行、または Stop hook から自動呼び出し可能。 |
| metadata | {"short-description":"帳の免疫システム -- 攻撃パターン検出と抗体生成"} |
Evidence Ledger から攻撃・バイパスパターンを検出し、tobari-gate への抗体パッチを生成する。
生物の免疫システムになぞらえた自己修復スキル。
.claude/immune-memory.jsonl に学習結果を永続化/tobari-immune -- 手動実行(全 Ledger を走査)
Stop hook からの呼出 -- deny 検出時に自動トリガー
/tobari-immune コマンドで手動実行する。
tobari-stop.js が以下の条件を検出した場合に呼び出し可能:
tool_denied イベントが 3 件以上| Category | ID | Description | Severity |
|---|---|---|---|
| Tool Bypass | edit_denied_bash_bypass | Edit/Write denied -> Bash write to same/similar path | critical |
| Scope Probing | scope_probe | Multiple sequential scope-out-of-bounds attempts | high |
| Destructive Evasion | destructive_evasion | Variations of blocked destructive commands | critical |
| Injection Roundtrip | injection_roundtrip | Tool output containing prompt injection patterns | critical |
| Permission Escalation | permission_escalation | Repeated permission requests for denied categories | high |
| Path Traversal | path_traversal | Attempts to access paths outside project root | high |
Evidence Ledger (.claude/logs/evidence-ledger.jsonl)
|
v
Step 1: load_evidence Ledger 読み込みとフィルタリング
|
v
Step 2: detect_patterns 攻撃パターンの検出と分類
|
v
Step 3: correlate_timeline 時系列相関分析
|
v
Step 4: generate_antibodies 抗体(パッチ + テスト)の生成
|
v
Step 5: present_findings 検出結果をユーザーに報告
| +-- 承認 -> Step 6
| +-- 却下 -> 記録のみで終了
v
Step 6: apply_and_record パッチ適用 + immune-memory 記録 + PR 作成
.claude/logs/evidence-ledger.jsonl を Read で読み込む。
以下のイベントタイプのみを抽出する:
tool_denied -- Gate が拒否した操作tool_failed -- ツール実行が失敗した操作permission_denied -- Permission hook が拒否した操作injection_detected -- Injection Guard が検出した操作Ledger ファイルが存在しない場合 -> 停止: 「Evidence Ledger が見つかりません。帳が有効な状態で操作を行ってから再実行してください。」
deny/block イベントが 0 件の場合 -> 正常終了: 「脅威は検出されませんでした。帳の免疫システムは正常です。」
抽出したイベントを以下のルールで分類する。
Detection Logic:
tool_denied イベントで tool_name が Edit または Write のものを抽出Bash ツールが呼び出されているか確認Evidence pattern:
T+0s tool_denied { tool: "Edit", path: "/scope/outside/file.js" }
T+15s tool_complete { tool: "Bash", command: "echo '...' > /scope/outside/file.js" }
Similarity Check:
Detection Logic:
tool_denied を抽出Evidence pattern:
T+0s tool_denied { reason: "scope violation", path: "/outside/a.js" }
T+30s tool_denied { reason: "scope violation", path: "/outside/b.js" }
T+45s tool_denied { reason: "scope violation", path: "/outside/c.js" }
Detection Logic:
tool_denied を抽出rm -rf -> find . -deletegit push --force -> git push -fgit reset --hard -> git checkout -- .Evidence pattern:
T+0s tool_denied { tool: "Bash", command: "rm -rf ./src" }
T+10s tool_denied { tool: "Bash", command: "find ./src -type f -delete" }
Detection Logic:
injection_detected イベントを抽出tool_complete のレスポンスに以下のパターンが含まれるか確認:
<SYSTEM>, </SYSTEM> tagsignore previous instructionsyou are now role reassignmentDetection Logic:
permission_denied イベントを抽出Detection Logic:
tool_denied で理由に path traversal または outside project root を含むものを抽出../ パターンや絶対パスでのプロジェクト外アクセスを検出Step 2 で検出した個別パターンを時系列で相関させ、複合攻撃を検出する。
| Compound Pattern | Components | Severity |
|---|---|---|
| Bypass Chain | scope_probe -> edit_denied_bash_bypass | critical |
| Escalation Chain | permission_escalation -> scope_probe | critical |
| Persistent Evasion | destructive_evasion x 3+ in 10 min | critical |
| Injection + Bypass | injection_roundtrip -> any bypass | emergency |
各検出パターンを以下の構造で出力する:
{
"pattern_id": "edit_denied_bash_bypass",
"severity": "critical",
"events": [
{ "timestamp": "...", "tool": "Edit", "action": "denied", "path": "..." },
{
"timestamp": "...",
"tool": "Bash",
"action": "complete",
"command": "..."
}
],
"time_delta_seconds": 15,
"compound_patterns": ["bypass_chain"],
"recommendation": "Add Bash write-redirect detection for denied Edit paths"
}
検出されたパターンごとに、具体的な修正案を生成する。
Edit denied -> Bash bypass パターンに対する新しい検出 regex:
// Antibody: edit_denied_bash_bypass
// Detect Bash write-redirect to previously denied paths
const BASH_WRITE_REDIRECT_PATTERN =
/(?:echo|printf|cat\s*<<|tee)\s+.*>\s*["']?([^"'\s;|&]+)/;
function checkBashBypassAttempt(command, recentDenials) {
const match = command.match(BASH_WRITE_REDIRECT_PATTERN);
if (!match) return null;
const targetPath = match[1];
return recentDenials.find((d) => isSimilarPath(d.path, targetPath));
}
Each antibody includes a corresponding test case:
// Test: edit_denied_bash_bypass detection
test("should detect Bash write-redirect to denied Edit path", () => {
const recentDenials = [
{
tool: "Edit",
path: "/project/src/secret.js",
timestamp: Date.now() - 5000,
},
];
const command = "echo 'malicious' > /project/src/secret.js";
const result = checkBashBypassAttempt(command, recentDenials);
assert.notStrictEqual(result, null);
});
{
"pattern_id": "edit_denied_bash_bypass",
"detected_at": "2026-03-18T12:00:00.000Z",
"severity": "critical",
"attack_signature": {
"sequence": ["Edit:denied", "Bash:write_redirect"],
"time_window_seconds": 60,
"path_similarity": "exact"
},
"antibody": {
"type": "gate_regex",
"target_file": ".claude/hooks/tobari-gate.js",
"patch_description": "Add Bash write-redirect detection for denied Edit paths"
},
"status": "proposed"
}
| Pattern | Antibody Type | Target | Action |
|---|---|---|---|
| edit_denied_bash_bypass | Gate Regex | tobari-gate.js | Add Bash write-redirect detection |
| scope_probe | Gate Logic | tobari-gate.js | Add rate-limiting for scope violations |
| destructive_evasion | Gate Regex | tobari-gate.js | Add command variant patterns |
| injection_roundtrip | Guard Logic | tobari-injection-guard.js | Add new injection signatures |
| permission_escalation | Gate Logic | tobari-permission.js | Add cooldown period for repeated denials |
| path_traversal | Gate Regex | tobari-gate.js | Strengthen path normalization |
検出結果をユーザーにマークダウンで表示する。
## 帳 免疫システム -- 脅威レポート
### 検出サマリー
| 項目 | 値 |
| ------------ | ------- |
| 走査イベント | {N} 件 |
| 脅威検出 | {M} 件 |
| 最高深刻度 | {level} |
| 走査期間 | {range} |
### 検出された脅威
#### 1. {pattern_name} (深刻度: {severity})
**検出内容:** {日本語の説明}
**証跡:**
- {timestamp}: {tool} が {action} -- {detail}
- {timestamp}: {tool} が {action} -- {detail}
**提案する対策(抗体):**
- 対象ファイル: `{target_file}`
- 変更内容: {description}
- テストケース: {test_description}
---
### 対応を選択してください
- **適用する** -- 全ての抗体パッチを適用し、PR を作成する
- **選択して適用** -- 適用する抗体を個別に選択する
- **記録のみ** -- 免疫メモリに記録するが、パッチは適用しない
- **却下する** -- 何もしない
.claude/immune-memory.jsonl に検出結果を追記する。
Entry schema:
{
"id": "IMM-{sequential_number}",
"pattern_id": "edit_denied_bash_bypass",
"detected_at": "2026-03-18T12:00:00.000Z",
"severity": "critical",
"attack_signature": {
"sequence": ["Edit:denied", "Bash:write_redirect"],
"time_window_seconds": 60,
"path_similarity": "exact"
},
"antibody": {
"type": "gate_regex",
"target_file": ".claude/hooks/tobari-gate.js",
"patch_description": "Add Bash write-redirect detection for denied Edit paths",
"applied": true
},
"source_events": [
{ "chain_index": 8, "timestamp": "...", "event": "tool_denied" },
{ "chain_index": 9, "timestamp": "...", "event": "tool_complete" }
],
"status": "applied"
}
Apply patches using Edit tool to the target files:
tobari-gate.js)Important: Patches must follow tobari's coding conventions:
"use strict"; at the topRun existing tests to ensure the patch does not break anything:
node --test .claude/hooks/test/**/*.test.js
If the user approves and the veil is active:
Create a feature branch: fix/immune-{pattern_id}-{date}
Commit the changes with message:
fix: add immune antibody for {pattern_id}
Detected {severity} bypass pattern: {description}
Immune memory: IMM-{id}
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Push and create PR
.claude/immune-memory.jsonl is the persistent memory of all detected threats.
| Field | Type | Description |
|---|---|---|
| id | string | Unique ID: IMM-{sequential} |
| pattern_id | string | Attack category ID |
| detected_at | string | ISO-8601 timestamp |
| severity | string | critical / high / medium / low |
| attack_signature | object | Signature for future matching |
| antibody | object | Patch details and application status |
| source_events | array | References to evidence-ledger entries |
| status | string | proposed / applied / rejected / obsolete |
Immune memory can be consumed by:
.gitignore (contains internal security data)status: "rejected" with reason