Skip to content

Commit 9d6212e

Browse files
Merge pull request #212 from CyberStrategyInstitute/CyberStrategy1-patch-54600
Add files via upload
2 parents 5ced2c2 + 7434679 commit 9d6212e

3 files changed

Lines changed: 1801 additions & 568 deletions

File tree

Lines changed: 165 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,165 @@
1-
# AI SAFE² Control Gateway Configuration
2-
# Version: 2.1
3-
4-
gateway:
5-
# Network binding (SECURITY: Use 127.0.0.1 for localhost only)
6-
bind_host: "127.0.0.1" # localhost only (NOT 0.0.0.0)
7-
bind_port: 8888
8-
9-
# Tool policy
10-
allow_high_risk_tools: false # Block exec, browser, cron, etc.
11-
12-
# Risk threshold (0-10)
13-
# Requests with risk score >= threshold are blocked
14-
risk_threshold: 7.0
15-
16-
# Rate limiting
17-
max_requests_per_minute: 60
18-
max_requests_per_hour: 1000
19-
20-
anthropic:
21-
# API key (use environment variable for security)
22-
# Set with: export ANTHROPIC_API_KEY=sk-ant-...
23-
api_key: "${ANTHROPIC_API_KEY}"
24-
25-
# Model defaults
26-
default_model: "claude-sonnet-4-20250514"
27-
max_tokens: 4096
28-
29-
logging:
30-
# Audit log file path
31-
audit_log: "gateway_audit.log"
32-
33-
# Redact secrets in logs
34-
redact_secrets: true
35-
36-
# Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
37-
log_level: "INFO"
38-
39-
# Retention (days)
40-
retention_days: 90
41-
42-
# Tool allowlist (if using fine-grained control)
43-
# Only these tools will be allowed even if high_risk_tools is true
44-
tool_allowlist:
45-
- "read"
46-
- "search"
47-
- "retrieve"
48-
49-
# Blocked patterns (additional to built-in list)
50-
custom_blocked_patterns:
51-
- "sudo"
52-
- "rm -rf"
53-
- "DROP DATABASE"
54-
- "DELETE FROM users"
55-
56-
# Trusted sources (bypass some checks)
57-
trusted_users:
58-
# Add user IDs that should have elevated privileges
59-
60-
61-
# Alerting (optional - requires additional setup)
62-
alerts:
63-
enabled: false
64-
# webhook_url: "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
65-
# email: "[email protected]"
66-
67-
# Alert on these events
68-
alert_on_blocked_request: true
69-
alert_on_high_risk: true
70-
alert_on_injection_attempt: true
1+
# AI SAFE² Control Gateway — OpenClaw Configuration
2+
# Version: 3.0
3+
# ─────────────────────────────────────────────────────────────────────────────
4+
# SECURITY RULES:
5+
# 1. NEVER commit real API keys. Use environment variables.
6+
# 2. AUDIT_CHAIN_KEY must be set via: export AUDIT_CHAIN_KEY=$(openssl rand -hex 32)
7+
# 3. OPERATOR_DEACTIVATION_KEY must be set for safe mode recovery.
8+
# 4. bind_host MUST be 127.0.0.1 in production unless using reverse proxy.
9+
# ─────────────────────────────────────────────────────────────────────────────
10+
11+
gateway:
12+
# Network binding
13+
# SECURITY: 127.0.0.1 = localhost only. Never 0.0.0.0 without a reverse proxy.
14+
bind_host: "127.0.0.1"
15+
bind_port: 8888
16+
17+
# ── HITL Circuit Breaker Tier Thresholds ──────────────────────────────────
18+
# Risk score boundaries for Human-in-the-Loop tier escalation.
19+
# All scores are on a 0–10 scale from the 3-vector composite formula.
20+
#
21+
# Tier Score Range Required Action
22+
# AUTO 0–3.0 Automatic approval, log only
23+
# MEDIUM 3.1–6.0 X-HITL-Token header (issued on first attempt)
24+
# HIGH 6.1–8.0 X-HITL-Token + X-HITL-Reason (≥20 chars)
25+
# CRITICAL 8.1–10.0 Out-of-band 2FA challenge-response
26+
hitl_thresholds:
27+
auto_max: 3.0
28+
medium_max: 6.0
29+
high_max: 8.0
30+
# Score > high_max → CRITICAL (2FA)
31+
32+
# ── 3-Vector Risk Scoring Weights ─────────────────────────────────────────
33+
# Weights must sum to 1.0
34+
# action_type: read=0, write=5, delete/exec=10
35+
# target_sensitivity: public=0, personal=5, system/key=10
36+
# historical_context: frequent=0, rare=5, never-seen=10
37+
risk_weights:
38+
action_type: 0.40
39+
target_sensitivity: 0.35
40+
historical_context: 0.25
41+
42+
# Score modifiers (added to composite before cap at 10.0)
43+
risk_modifiers:
44+
injection_detected: +5.0
45+
a2a_impersonation: +3.0
46+
47+
# ── Rate Limiting ─────────────────────────────────────────────────────────
48+
max_requests_per_minute: 60
49+
max_requests_per_hour: 1000
50+
51+
# ── Historical Context ────────────────────────────────────────────────────
52+
# Path for per-user action frequency database (JSON)
53+
history_db: "data/action_history.json"
54+
55+
# ── Tool Policy ───────────────────────────────────────────────────────────
56+
# Explicit allow-list takes precedence over risk score for low-risk tools.
57+
# High-risk tools (exec, cron, browser, delete, gateway) are ALWAYS scored.
58+
tool_allowlist:
59+
- "read"
60+
- "search"
61+
- "retrieve"
62+
- "list"
63+
- "describe"
64+
65+
# Custom patterns added to the built-in injection detection list
66+
custom_blocked_patterns:
67+
- "sudo"
68+
- "rm -rf"
69+
- "DROP DATABASE"
70+
- "DELETE FROM users"
71+
- "chmod 777"
72+
- "curl | bash"
73+
- "wget | sh"
74+
75+
# ── Anthropic API ──────────────────────────────────────────────────────────
76+
anthropic:
77+
# Set via environment: export ANTHROPIC_API_KEY=sk-ant-...
78+
api_key: "${ANTHROPIC_API_KEY}"
79+
default_model: "claude-sonnet-4-20250514"
80+
max_tokens: 4096
81+
timeout_seconds: 60
82+
83+
# ── Heartbeat Monitor ─────────────────────────────────────────────────────
84+
# Bug #11766 mitigation: the gateway NEVER auto-creates HEARTBEAT.md.
85+
# A missing/empty/stale file triggers safe mode, not silent failure.
86+
heartbeat:
87+
path: "HEARTBEAT.md"
88+
89+
# Maximum age before the heartbeat is considered stale (seconds)
90+
# Should be 2–3× the write_interval_seconds value
91+
max_staleness_seconds: 120
92+
93+
# How often the background thread writes a new heartbeat (seconds)
94+
write_interval_seconds: 30
95+
96+
# Background jobs must call validate() before executing.
97+
# If validate() returns False, the job MUST abort and alert.
98+
require_valid_for_background_jobs: true
99+
100+
# ── Audit Logging ──────────────────────────────────────────────────────────
101+
logging:
102+
# HMAC-chained immutable JSONL audit log
103+
# AUDIT_CHAIN_KEY env var must be set for chain integrity
104+
audit_log: "logs/gateway_audit.jsonl"
105+
106+
# Operational (non-audit) log
107+
operational_log: "logs/gateway.log"
108+
109+
# Redact API keys and secrets from all log entries
110+
redact_secrets: true
111+
112+
# Log level for operational log (DEBUG, INFO, WARNING, ERROR, CRITICAL)
113+
log_level: "INFO"
114+
115+
# Audit log retention (informational — implement via logrotate or cron)
116+
retention_days: 90
117+
118+
# ── Audit Governance ──────────────────────────────────────────────────────
119+
# "Who governs the governor?" — AI SAFE² Evolve & Educate pillar
120+
audit_governance:
121+
# Run chain verification on startup
122+
verify_chain_on_startup: true
123+
124+
# Scanner runs nightly. See scanner.py.
125+
scanner:
126+
enabled: true
127+
script: "scanner.py"
128+
schedule: "0 2 * * *" # 2 AM nightly (cron format)
129+
alert_on_failure: true
130+
131+
# Red-team drill schedule (operator reminder — not automated)
132+
red_team:
133+
quarterly_drill_reminder: true
134+
last_drill_date: "" # Update after each drill: YYYY-MM-DD
135+
next_due_date: "" # Set to 90 days after last_drill_date
136+
137+
# A2A impersonation drill schedule
138+
a2a_test:
139+
semi_annual_reminder: true
140+
last_test_date: ""
141+
next_due_date: ""
142+
143+
# ── Alerting ──────────────────────────────────────────────────────────────
144+
alerts:
145+
enabled: false # Set to true when webhook is configured
146+
147+
# Slack/Teams/PagerDuty webhook URL
148+
# webhook_url: "${ALERT_WEBHOOK_URL}"
149+
150+
# Events that trigger alerts
151+
alert_on_blocked_request: true
152+
alert_on_injection_attempt: true
153+
alert_on_high_risk: true # Score ≥ high_max
154+
alert_on_safe_mode: true
155+
alert_on_chain_break: true
156+
alert_on_a2a_detection: true
157+
alert_on_heartbeat_failure: true
158+
159+
# ── Trusted Identities ────────────────────────────────────────────────────
160+
# Identities in this list receive reduced historical_context scoring
161+
# (treated as "frequent" regardless of actual history).
162+
# This prevents false escalations for known operator tooling.
163+
# trusted_users:
164+
165+
# - "ci-pipeline"

0 commit comments

Comments
 (0)