symbi 1.8.0

AI-native agent framework for building autonomous, policy-aware agents that can safely collaborate with humans, other agents, and large language models
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
---
layout: default
title: セキュリティモデル
description: "Symbiontのセキュリティアーキテクチャと実装"
nav_exclude: true
---

# セキュリティモデル
{: .no_toc }

AIエージェントに対してゼロトラスト、ポリシー駆動型保護を確保する包括的なセキュリティアーキテクチャ。
{: .fs-6 .fw-300 }

## 🌐 他の言語
{: .no_toc}

[English]security-model.md | [中文简体]security-model.zh-cn.md | [Español]security-model.es.md | [Português]security-model.pt.md | **日本語** | [Deutsch]security-model.de.md

---

## 目次
{: .no_toc .text-delta }

1. TOC
{:toc}

---

## 概要

Symbiontは、規制された高保証環境向けに設計されたセキュリティファーストアーキテクチャを実装しています。セキュリティモデルは、包括的なポリシー実行、マルチティアサンドボックス、暗号学的監査可能性を備えたゼロトラスト原則に基づいて構築されています。

### セキュリティ原則

- **ゼロトラスト**: すべてのコンポーネントと通信が検証される
- **多層防御**: 単一障害点のない複数のセキュリティ層
- **ポリシー駆動型**: 実行時に適用される宣言的セキュリティポリシー
- **完全監査可能性**: 暗号学的整合性を持つすべての操作ログ
- **最小権限**: 操作に必要な最小限の権限

---

## マルチティアサンドボックス

ランタイムは、リスク評価に基づいて2つの分離ティアを実装します:

```mermaid
graph TB
    A[Risk Assessment Engine] --> B{Risk Level}

    B -->|Low Risk| C[Tier 1: Docker]
    B -->|Medium/High Risk| D[Tier 2: gVisor]

    subgraph "Tier 1: Container Isolation"
        C1[Container Runtime]
        C2[Resource Limits]
        C3[Network Isolation]
        C4[Read-only Filesystem]
    end

    subgraph "Tier 2: User-space Kernel"
        D1[System Call Interception]
        D2[Memory Protection]
        D3[I/O Virtualization]
        D4[Enhanced Isolation]
    end

    C --> C1
    D --> D1
```

> **注意**: ハードウェア仮想化を使用した追加の分離ティアはEnterpriseエディションで利用可能です。

### ティア1:Docker分離

**使用例:**
- 信頼できる開発タスク
- 低感度データ処理
- 内部ツール操作

**セキュリティ機能:**
```yaml
docker_security:
  memory_limit: "512MB"
  cpu_limit: "0.5"
  network_mode: "none"
  read_only_root: true
  security_opts:
    - "no-new-privileges:true"
    - "seccomp:default"
  capabilities:
    drop: ["ALL"]
    add: ["SETUID", "SETGID"]
```

**脅威保護:**
- ホストからのプロセス分離
- リソース枯渇防止
- ネットワークアクセス制御
- ファイルシステム保護

### ティア2:gVisor分離

**使用例:**
- 標準本番ワークロード
- 機密データ処理
- 外部ツール統合

**セキュリティ機能:**
- ユーザー空間カーネル実装
- システムコールフィルタリングと変換
- メモリ保護境界
- I/Oリクエスト検証

**設定:**
```yaml
gvisor_security:
  runtime: "runsc"
  platform: "ptrace"
  network: "sandbox"
  file_access: "exclusive"
  debug: false
  strace: false
```

**高度な保護:**
- カーネル脆弱性分離
- システムコール傍受
- メモリ破損防止
- サイドチャネル攻撃緩和

> **Enterprise機能**: 最大セキュリティ要件のためのハードウェア仮想化(Firecracker)による高度な分離はEnterpriseエディションで利用可能です。

### リスク評価アルゴリズム

> **計画中の機能** — このAPIはセキュリティロードマップの一部であり、現在のリリースではまだ利用できません。

```rust
pub struct RiskAssessment {
    data_sensitivity: f32,      // 0.0 = public, 1.0 = top secret
    code_trust_level: f32,      // 0.0 = untrusted, 1.0 = verified
    network_access: bool,       // Requires external network
    filesystem_access: bool,    // Requires filesystem write
    external_apis: bool,        // Uses external services
}

pub fn calculate_risk_score(assessment: RiskAssessment) -> f32 {
    let base_score = assessment.data_sensitivity * 0.4
        + (1.0 - assessment.code_trust_level) * 0.3;

    let access_penalty = if assessment.network_access { 0.1 } else { 0.0 }
        + if assessment.filesystem_access { 0.1 } else { 0.0 }
        + if assessment.external_apis { 0.1 } else { 0.0 };

    (base_score + access_penalty).min(1.0)
}
```

---

## ポリシーエンジン

### ポリシーアーキテクチャ

ポリシーエンジンは、実行時適用による宣言的セキュリティ制御を提供します:

```mermaid
graph TB
    A[Policy Definition] --> B[Policy Parser]
    B --> C[Policy Store]
    C --> D[Policy Engine]
    D --> E[Enforcement Points]

    E --> F[Agent Creation]
    E --> G[Resource Access]
    E --> H[Message Routing]
    E --> I[Tool Invocation]
    E --> J[Data Operations]
    E --> CPG[Inter-Agent Policy]

    K[Audit Logger] --> L[Policy Violations]
    E --> K
```

### ポリシータイプ

#### アクセス制御ポリシー

どの条件下で誰がどのリソースにアクセスできるかを定義します:

```rust
policy secure_data_access {
    allow: read(sensitive_data) if (
        user.clearance >= "secret" &&
        user.need_to_know.contains(data.classification) &&
        session.mfa_verified == true
    )

    deny: export(data) if data.contains_pii == true

    require: [
        user.background_check.current,
        session.secure_connection,
        audit_trail = "detailed"
    ]
}
```

#### データフローポリシー

システム内でのデータの移動方法を制御します:

```rust
policy data_flow_control {
    allow: transform(data) if (
        source.classification <= target.classification &&
        user.transform_permissions.contains(operation.type)
    )

    deny: aggregate(datasets) if (
        any(datasets, |d| d.privacy_level > operation.privacy_budget)
    )

    require: differential_privacy for statistical_operations
}
```

#### リソース使用ポリシー

計算リソース割り当てを管理します:

```rust
policy resource_governance {
    allow: allocate(resources) if (
        user.resource_quota.remaining >= resources.total &&
        operation.priority <= user.max_priority
    )

    deny: long_running_operations if system.maintenance_mode

    require: supervisor_approval for high_memory_operations
}
```

### ポリシー評価エンジン

```rust
pub trait PolicyEngine {
    async fn evaluate_policy(
        &self,
        context: PolicyContext,
        action: Action
    ) -> PolicyDecision;

    async fn register_policy(&self, policy: Policy) -> Result<PolicyId>;
    async fn update_policy(&self, policy_id: PolicyId, policy: Policy) -> Result<()>;
}

pub enum PolicyDecision {
    Allow,
    Deny { reason: String },
    AllowWithConditions { conditions: Vec<PolicyCondition> },
    RequireApproval { approver: String },
}
```

### パフォーマンス最適化

**ポリシーキャッシュ:**
- パフォーマンスのためのコンパイル済みポリシー評価
- 頻繁な決定のためのLRUキャッシュ
- 一括操作のためのバッチ評価
- サブミリ秒評価時間

**増分更新:**
- 再起動なしのリアルタイムポリシー更新
- バージョン管理されたポリシーデプロイメント
- ポリシーエラーのロールバック機能

### Cedarポリシーエンジン(`cedar` feature)

Symbiontは正式認可のために[Cedarポリシー言語](https://www.cedarpolicy.com/)を統合しています。Cedarは、推論ループのポリシーゲートで評価される、きめ細かで監査可能なアクセス制御ポリシーを可能にします。

```bash
cargo build --features cedar
```

**主要な機能:**
- **正式検証**: Cedarポリシーは正確性について静的に分析可能
- **きめ細かな認可**: 階層的権限を持つエンティティベースのアクセス制御
- **推論ループ統合**: `CedarPolicyGate``ReasoningPolicyGate` トレイトを実装し、実行前にCedarポリシーに対して各提案アクションを評価
- **監査証跡**: すべてのCedarポリシー決定が完全なコンテキストとともにログに記録

```rust
use symbi_runtime::reasoning::cedar_gate::CedarPolicyGate;

// デフォルト拒否のスタンスでCedarポリシーゲートを作成
let cedar_gate = CedarPolicyGate::deny_by_default();
let runner = ReasoningLoopRunner::builder()
    .provider(provider)
    .executor(executor)
    .policy_gate(Arc::new(cedar_gate))
    .build();
```

### エージェント間通信ポリシー

`CommunicationPolicyGate` はすべてのエージェント間通信に対する認可ルールを実行します。`ask`、`delegate`、`send_to`、`parallel`、`race` を通じたすべての呼び出しは、実行前にポリシールールに対して評価されます。

**ルール構造:**
- **条件**: `SenderIs(agent)``RecipientIs(agent)``Always`、複合 `All`/`Any`
- **効果**: `Allow` または `Deny { reason }`
- **優先度**: ルールは優先度の高い順に評価され、最初にマッチしたものが適用
- **デフォルト**: Allow(後方互換性 -- 既存のプロジェクトはそのまま動作)

**ポリシー拒否はハードフェイル** -- 呼び出し元のエージェントはORGAループを通じてエラーを受け取り、それについて推論できます。すべてのエージェント間メッセージはEd25519で暗号署名され、AES-256-GCMで暗号化されます。

ワーカーエージェントが他のエージェントに委任することを禁止するポリシーの例:
```cedar
forbid(
    principal == Agent::"worker",
    action == Action::"delegate",
    resource
);
```

---

## 暗号学的セキュリティ

### デジタル署名

すべてのセキュリティ関連操作は暗号学的に署名されます:

**署名アルゴリズム:** Ed25519(RFC 8032)
- **キーサイズ:** 256ビット秘密鍵、256ビット公開鍵
- **署名サイズ:** 512ビット(64バイト)
- **パフォーマンス:** 70,000+ 署名/秒、25,000+ 検証/秒

```rust
pub struct MessageSignature {
    pub signature: Vec<u8>,
    pub algorithm: SignatureAlgorithm,
    pub public_key: Vec<u8>,
}

impl AuditEvent {
    pub fn sign(&mut self, private_key: &PrivateKey) -> Result<()> {
        let message = self.serialize_for_signing()?;
        self.signature = private_key.sign(&message);
        Ok(())
    }

    pub fn verify(&self, public_key: &PublicKey) -> bool {
        let message = self.serialize_for_signing().unwrap();
        public_key.verify(&message, &self.signature)
    }
}
```

### キー管理

**キー保存:**
- ハードウェアセキュリティモジュール(HSM)統合
- キー保護のためのセキュアエンクレーブサポート
- 設定可能な間隔でのキーローテーション
- 分散キーバックアップと復旧

**キー階層:**
- システム操作のためのルート署名キー
- 操作署名のためのエージェント別キー
- セッション暗号化のための一時キー
- ツール検証のための外部キー

> **計画中の機能** — 以下の `KeyManager` APIはセキュリティロードマップの一部であり、現在のリリースではまだ利用できません。現在の実装は `crypto.rs``KeyUtils` を通じてキーユーティリティを提供しています。

```rust
pub struct KeyManager {
    hsm: HardwareSecurityModule,
    key_store: SecureKeyStore,
    rotation_policy: KeyRotationPolicy,
}

impl KeyManager {
    pub async fn generate_agent_keys(&self, agent_id: AgentId) -> Result<KeyPair>;
    pub async fn rotate_keys(&self, key_id: KeyId) -> Result<KeyPair>;
    pub async fn revoke_key(&self, key_id: KeyId) -> Result<()>;
}
```

### 暗号化標準

**対称暗号化:** AES-256-GCM
- 認証付き暗号化を持つ256ビットキー
- 各暗号化操作のユニークナンス
- コンテキストバインディングのための関連データ

**非対称暗号化:** X25519 + ChaCha20-Poly1305
- 楕円曲線キー交換
- 認証付き暗号化を持つストリーム暗号
- 完全前方秘匿性

**メッセージ暗号化:**
```rust
pub fn encrypt_message(
    plaintext: &[u8],
    recipient_public_key: &PublicKey,
    sender_private_key: &PrivateKey
) -> Result<EncryptedMessage> {
    let shared_secret = sender_private_key.diffie_hellman(recipient_public_key);
    let nonce = generate_random_nonce();
    let ciphertext = ChaCha20Poly1305::new(&shared_secret)
        .encrypt(&nonce, plaintext)?;

    Ok(EncryptedMessage {
        nonce,
        ciphertext,
        sender_public_key: sender_private_key.public_key(),
    })
}
```

---

## 監査とコンプライアンス

### 暗号学的監査証跡

すべてのセキュリティ関連操作は不変の監査イベントを生成します:

```rust
pub struct AuditEvent {
    pub event_id: Uuid,
    pub timestamp: SystemTime,
    pub agent_id: AgentId,
    pub event_type: AuditEventType,
    pub details: serde_json::Value,
    pub signature: Ed25519Signature,
    pub previous_hash: Hash,
    pub event_hash: Hash,
}
```

**監査イベントタイプ:**
- エージェントライフサイクルイベント(作成、終了)
- ポリシー評価決定
- リソース割り当てと使用
- メッセージ送信とルーティング
- 外部ツール呼び出し
- セキュリティ違反とアラート

### ハッシュチェーン

イベントは不変チェーンでリンクされます:

```rust
impl AuditChain {
    pub fn append_event(&mut self, mut event: AuditEvent) -> Result<()> {
        event.previous_hash = self.last_hash;
        event.event_hash = self.calculate_event_hash(&event);
        event.sign(&self.signing_key)?;

        self.events.push(event.clone());
        self.last_hash = event.event_hash;

        self.verify_chain_integrity()?;
        Ok(())
    }

    pub fn verify_integrity(&self) -> Result<bool> {
        for (i, event) in self.events.iter().enumerate() {
            // Verify signature
            if !event.verify(&self.public_key) {
                return Ok(false);
            }

            // Verify hash chain
            if i > 0 && event.previous_hash != self.events[i-1].event_hash {
                return Ok(false);
            }
        }
        Ok(true)
    }
}
```

### コンプライアンス機能

**規制サポート:**

**HIPAA(ヘルスケア):**
- ユーザー識別を含むPHIアクセスログ
- データ最小化適用
- 侵害検出と通知
- 6年間の監査証跡保持

**GDPR(プライバシー):**
- 個人データ処理ログ
- 同意検証追跡
- データ主体権利適用
- データ保持ポリシーコンプライアンス

**SOX(金融):**
- 内部統制文書化
- 変更管理追跡
- アクセス制御検証
- 金融データ保護

**カスタムコンプライアンス:**

> **計画中の機能** — 以下の `ComplianceFramework` APIはセキュリティロードマップの一部であり、現在のリリースではまだ利用できません。

```rust
pub struct ComplianceFramework {
    pub name: String,
    pub audit_requirements: Vec<AuditRequirement>,
    pub retention_policy: RetentionPolicy,
    pub access_controls: Vec<AccessControl>,
    pub data_protection: DataProtectionRules,
}

impl ComplianceFramework {
    pub fn validate_compliance(&self, audit_trail: &AuditChain) -> ComplianceReport;
    pub fn generate_compliance_report(&self, period: TimePeriod) -> Report;
}
```

---

## SchemaPinによるツールセキュリティ

### ツール検証プロセス

外部ツールは暗号署名を使用して検証されます:

```mermaid
sequenceDiagram
    participant Tool as Tool Provider
    participant SP as SchemaPin
    participant AI as AI Reviewer
    participant Runtime as Symbiont Runtime
    participant Agent as Agent

    Tool->>SP: Submit Tool Schema
    SP->>AI: Security Analysis
    AI-->>SP: Analysis Results
    SP->>SP: Human Review (if needed)
    SP->>SP: Sign Schema
    SP-->>Tool: Signed Schema

    Agent->>Runtime: Request Tool Use
    Runtime->>SP: Verify Tool Schema
    SP-->>Runtime: Verification Result
    Runtime-->>Agent: Allow/Deny Tool Use
```

### 初回使用時信頼(TOFU)

**キーピニングプロセス:**
1. ツールプロバイダーとの初回接触
2. 外部チャネルを通じてプロバイダーの公開鍵を検証
3. ローカル信頼ストアに公開鍵をピン留め
4. 将来のすべての検証にピン留めされたキーを使用

> **計画中の機能** — 以下の `TOFUKeyStore` APIはセキュリティロードマップの一部であり、現在のリリースではまだ利用できません。

```rust
pub struct TOFUKeyStore {
    pinned_keys: HashMap<ProviderId, PinnedKey>,
    trust_policies: Vec<TrustPolicy>,
}

impl TOFUKeyStore {
    pub async fn pin_key(&mut self, provider: ProviderId, key: PublicKey) -> Result<()> {
        if self.pinned_keys.contains_key(&provider) {
            return Err("Key already pinned for provider");
        }

        self.pinned_keys.insert(provider, PinnedKey {
            public_key: key,
            pinned_at: SystemTime::now(),
            trust_level: TrustLevel::Unverified,
        });

        Ok(())
    }

    pub fn verify_tool(&self, tool: &MCPTool) -> VerificationResult {
        if let Some(pinned_key) = self.pinned_keys.get(&tool.provider_id) {
            if pinned_key.public_key.verify(&tool.schema_hash, &tool.signature) {
                VerificationResult::Trusted
            } else {
                VerificationResult::SignatureInvalid
            }
        } else {
            VerificationResult::UnknownProvider
        }
    }
}
```

### AI駆動ツールレビュー

ツール承認前の自動セキュリティ分析:

**分析コンポーネント:**
- **脆弱性検出**: 既知の脆弱性シグネチャに対するパターンマッチング
- **悪意のあるコード検出**: MLベースの悪意のある動作識別
- **リソース使用分析**: 計算リソース要件の評価
- **プライバシー影響評価**: データ処理とプライバシーへの影響

> **計画中の機能** — 以下の `SecurityAnalyzer` APIはセキュリティロードマップの一部であり、現在のリリースではまだ利用できません。

```rust
pub struct SecurityAnalyzer {
    vulnerability_patterns: VulnerabilityDatabase,
    ml_detector: MaliciousCodeDetector,
    resource_analyzer: ResourceAnalyzer,
    privacy_assessor: PrivacyAssessor,
}

impl SecurityAnalyzer {
    pub async fn analyze_tool(&self, tool: &MCPTool) -> SecurityAnalysis {
        let mut findings = Vec::new();

        // Vulnerability pattern matching
        findings.extend(self.vulnerability_patterns.scan(&tool.schema));

        // ML-based detection
        let ml_result = self.ml_detector.analyze(&tool.schema).await?;
        findings.extend(ml_result.findings);

        // Resource usage analysis
        let resource_risk = self.resource_analyzer.assess(&tool.schema);

        // Privacy impact assessment
        let privacy_impact = self.privacy_assessor.evaluate(&tool.schema);

        SecurityAnalysis {
            tool_id: tool.id.clone(),
            risk_score: calculate_risk_score(&findings),
            findings,
            resource_requirements: resource_risk,
            privacy_impact,
            recommendation: self.generate_recommendation(&findings),
        }
    }
}
```

---

## ClawHavocスキルスキャナー

ClawHavocスキャナーはエージェントスキルのコンテンツレベル防御を提供します。すべてのスキルファイルはロード前に行単位でスキャンされ、CriticalまたはHigh重大度の検出結果はスキルの実行をブロックします。

### 重大度モデル

| レベル | アクション | 説明 |
|--------|----------|------|
| **Critical** | スキャン失敗 | アクティブな悪用パターン(リバースシェル、コードインジェクション) |
| **High** | スキャン失敗 | 認証情報窃取、権限昇格、プロセスインジェクション |
| **Medium** | 警告 | 疑わしいが潜在的に正当(ダウンローダー、シンボリックリンク) |
| **Warning** | 警告 | 低リスク指標(envファイル参照、chmod) |
| **Info** | ログ | 情報的な検出結果 |

### 検出カテゴリ(40ルール)

**オリジナル防御ルール(10)**
- `pipe-to-shell``wget-pipe-to-shell` -- パイプされたダウンロードによるリモートコード実行
- `eval-with-fetch``fetch-with-eval` -- eval + ネットワークによるコードインジェクション
- `base64-decode-exec` -- base64デコードによる難読化実行
- `soul-md-modification``memory-md-modification` -- アイデンティティ改ざん
- `rm-rf-pattern` -- 破壊的ファイルシステム操作
- `env-file-reference``chmod-777` -- 機密ファイルアクセス、ワールドライタブル権限

**リバースシェル(7)** -- Critical重大度
- `reverse-shell-bash``reverse-shell-nc``reverse-shell-ncat``reverse-shell-mkfifo``reverse-shell-python``reverse-shell-perl``reverse-shell-ruby`

**認証情報ハーベスティング(6)** -- High重大度
- `credential-ssh-keys``credential-aws``credential-cloud-config``credential-browser-cookies``credential-keychain``credential-etc-shadow`

**ネットワーク窃取(3)** -- High重大度
- `exfil-dns-tunnel``exfil-dev-tcp``exfil-nc-outbound`

**プロセスインジェクション(4)** -- Critical重大度
- `injection-ptrace``injection-ld-preload``injection-proc-mem``injection-gdb-attach`

**権限昇格(5)** -- High重大度
- `privesc-sudo``privesc-setuid``privesc-setcap``privesc-chown-root``privesc-nsenter`

**シンボリックリンク / パストラバーサル(2)** -- Medium重大度
- `symlink-escape``path-traversal-deep`

**ダウンローダーチェーン(3)** -- Medium重大度
- `downloader-curl-save``downloader-wget-save``downloader-chmod-exec`

### 実行可能ファイルホワイトリスト

`AllowedExecutablesOnly` ルールタイプは、エージェントスキルが呼び出せる実行可能ファイルを制限します:

```rust
// これらの実行可能ファイルのみ許可 -- それ以外はすべてブロック
ScanRule::AllowedExecutablesOnly(vec![
    "python3".into(),
    "node".into(),
    "cargo".into(),
])
```

### カスタムルール

ドメイン固有のパターンをClawHavocデフォルトと並行して追加できます:

```rust
let mut scanner = SkillScanner::new();
scanner.add_custom_rule(
    "block-internal-api",
    r"internal\.corp\.example\.com",
    ScanSeverity::High,
    "References to internal API endpoints are not allowed in skills",
);
```

---

## ネットワークセキュリティ

### セキュア通信

**トランスポート層セキュリティ:**
- すべての外部通信にTLS 1.3
- サービス間通信のための相互TLS(mTLS)
- 既知のサービスの証明書ピニング
- 完全前方秘匿性

**メッセージレベルセキュリティ:**
- エージェントメッセージのエンドツーエンド暗号化
- メッセージ認証コード(MAC)
- タイムスタンプによるリプレイ攻撃防止
- メッセージ順序保証

```rust
pub struct SecureChannel {
    encryption_key: [u8; 32],
    mac_key: [u8; 32],
    send_counter: AtomicU64,
    recv_counter: AtomicU64,
}

impl SecureChannel {
    pub fn encrypt_message(&self, plaintext: &[u8]) -> Result<Vec<u8>> {
        let counter = self.send_counter.fetch_add(1, Ordering::SeqCst);
        let nonce = self.generate_nonce(counter);

        let ciphertext = ChaCha20Poly1305::new(&self.encryption_key)
            .encrypt(&nonce, plaintext)?;

        let mac = Hmac::<Sha256>::new_from_slice(&self.mac_key)?
            .chain_update(&ciphertext)
            .chain_update(&counter.to_le_bytes())
            .finalize()
            .into_bytes();

        Ok([ciphertext, mac.to_vec()].concat())
    }
}
```

### ネットワーク分離

**サンドボックスネットワーク制御:**
- デフォルトでネットワークアクセスなし
- 外部接続の明示的許可リスト
- トラフィック監視と異常検出
- DNSフィルタリングと検証

**ネットワークポリシー:**
```yaml
network_policy:
  default_action: "deny"
  allowed_destinations:
    - domain: "api.openai.com"
      ports: [443]
      protocol: "https"
    - ip_range: "10.0.0.0/8"
      ports: [6333]  # Qdrant (only needed if using optional Qdrant backend)
      protocol: "http"

  monitoring:
    log_all_connections: true
    detect_anomalies: true
    rate_limiting: true
```

---

## インシデント対応

### セキュリティイベント検出

**自動検出:**
- ポリシー違反監視
- 異常行動検出
- リソース使用異常
- 認証失敗追跡

**アラート分類:**
```rust
pub enum ViolationSeverity {
    Info,       // Normal security events
    Warning,    // Minor policy violations
    Error,      // Confirmed security issues
    Critical,   // Active security breaches
}

pub struct SecurityEvent {
    pub id: Uuid,
    pub timestamp: SystemTime,
    pub severity: ViolationSeverity,
    pub category: SecurityEventCategory,
    pub description: String,
    pub affected_components: Vec<ComponentId>,
    pub recommended_actions: Vec<String>,
}
```

### インシデント対応ワークフロー

```mermaid
graph TB
    A[Security Event] --> B[Event Classification]
    B --> C{Severity Level}

    C -->|Info/Low| D[Log Event]
    C -->|Medium| E[Alert Security Team]
    C -->|High| F[Automatic Mitigation]
    C -->|Critical| G[Emergency Response]

    F --> H[Isolate Affected Components]
    F --> I[Revoke Compromised Credentials]
    F --> J[Preserve Evidence]

    G --> H
    G --> K[Notify Leadership]
    G --> L[External Incident Response]
```

### 復旧手順

**自動復旧:**
- クリーンな状態でのエージェント再起動
- 侵害された認証情報のキーローテーション
- 再発防止のためのポリシー更新
- システムヘルス検証

**手動復旧:**
- セキュリティイベントのフォレンジック分析
- 根本原因分析と修復
- セキュリティ制御更新
- インシデント文書化と教訓

---

## セキュリティベストプラクティス

### 開発ガイドライン

1. **デフォルトでセキュア**: すべてのセキュリティ機能をデフォルトで有効化
2. **最小権限の原則**: すべての操作に最小限の権限
3. **多層防御**: 冗長性を持つ複数のセキュリティ層
4. **セキュアな失敗**: セキュリティ失敗はアクセスを許可ではなく拒否すべき
5. **すべてを監査**: セキュリティ関連操作の完全ログ

### デプロイメントセキュリティ

**環境ハードニング:**
```bash
# Disable unnecessary services
systemctl disable cups bluetooth

# Kernel hardening
echo "kernel.dmesg_restrict=1" >> /etc/sysctl.conf
echo "kernel.kptr_restrict=2" >> /etc/sysctl.conf

# File system security
mount -o remount,nodev,nosuid,noexec /tmp
```

**コンテナセキュリティ:**
```dockerfile
# Use minimal base image
FROM scratch
COPY --from=builder /app/symbiont /bin/symbiont

# Run as non-root user
USER 1000:1000

# Set security options
LABEL security.no-new-privileges=true
```

### 運用セキュリティ

**監視チェックリスト:**
- [ ] リアルタイムセキュリティイベント監視
- [ ] ポリシー違反追跡
- [ ] リソース使用異常検出
- [ ] 認証失敗監視
- [ ] 証明書有効期限追跡

**メンテナンス手順:**
- 定期的なセキュリティ更新とパッチ
- スケジュールされたキーローテーション
- ポリシーレビューと更新
- セキュリティ監査と侵入テスト
- インシデント対応計画テスト

---

## セキュリティ設定

### 環境変数

```bash
# Cryptographic settings
export SYMBIONT_CRYPTO_PROVIDER=ring
export SYMBIONT_KEY_STORE_TYPE=hsm
export SYMBIONT_HSM_CONFIG_PATH=/etc/symbiont/hsm.conf

# Audit settings
export SYMBIONT_AUDIT_ENABLED=true
export SYMBIONT_AUDIT_STORAGE=/var/audit/symbiont
export SYMBIONT_AUDIT_RETENTION_DAYS=2555  # 7 years

# Security policies
export SYMBIONT_POLICY_ENFORCEMENT=strict
export SYMBIONT_DEFAULT_SANDBOX_TIER=gvisor
export SYMBIONT_TOFU_ENABLED=true
```

### セキュリティ設定ファイル

```toml
[security]
# Cryptographic settings
crypto_provider = "ring"
signature_algorithm = "ed25519"
encryption_algorithm = "chacha20_poly1305"

# Key management
key_rotation_interval_days = 90
hsm_enabled = true
hsm_config_path = "/etc/symbiont/hsm.conf"

# Audit settings
audit_enabled = true
audit_storage_path = "/var/audit/symbiont"
audit_retention_days = 2555
audit_compression = true

# Sandbox security
default_sandbox_tier = "gvisor"
sandbox_escape_detection = true
resource_limit_enforcement = "strict"

# Network security
tls_min_version = "1.3"
certificate_pinning = true
network_isolation = true

# Policy enforcement
policy_enforcement_mode = "strict"
policy_violation_action = "deny_and_alert"
emergency_override_enabled = false

[tofu]
enabled = true
key_verification_required = true
trust_on_first_use_timeout_hours = 24
automatic_key_pinning = false
```

---

## セキュリティメトリクス

### 主要パフォーマンス指標

**セキュリティ操作:**
- ポリシー評価レイテンシ:平均 <1ms
- 監査イベント生成率:10,000+ イベント/秒
- セキュリティインシデント応答時間:<5分
- 暗号操作スループット:70,000+ 操作/秒

**コンプライアンスメトリクス:**
- ポリシーコンプライアンス率:>99.9%
- 監査証跡整合性:100%
- セキュリティイベント偽陽性率:<1%
- インシデント解決時間:<24時間

**リスク評価:**
- 脆弱性パッチ適用時間:<48時間
- セキュリティ制御有効性:>95%
- 脅威検出精度:>99%
- 復旧時間目標:<1時間

---

## 将来の改良

### 高度な暗号学

**ポスト量子暗号:**
- NIST承認のポスト量子アルゴリズム
- 古典/ポスト量子ハイブリッドスキーム
- 量子脅威の移行計画

**準同型暗号:**
- 暗号化データでのプライバシー保護計算
- 近似算術のためのCKKSスキーム
- 機械学習ワークフローとの統合

**ゼロ知識証明:**
- 計算検証のためのzk-SNARKs
- プライバシー保護認証
- コンプライアンス証明生成

### AI強化セキュリティ

**行動分析:**
- 異常検出のための機械学習
- 予測的セキュリティ分析
- 適応的脅威対応

**自動応答:**
- 自己修復セキュリティ制御
- 動的ポリシー生成
- インテリジェントインシデント分類

---

## 次のステップ

- **[コントリビューション]/contributing** - セキュリティ開発ガイドライン
- **[ランタイムアーキテクチャ]/runtime-architecture** - 技術実装詳細
- **[APIリファレンス]/api-reference** - セキュリティAPIドキュメント
- **[コンプライアンスガイド]/compliance** - 規制コンプライアンス情報

Symbiontセキュリティモデルは、規制産業と高保証環境に適したエンタープライズグレードの保護を提供します。その階層アプローチは、運用効率を維持しながら進化する脅威に対する堅牢な保護を確保します。