@goplus/agentguard 1.0.7 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,334 @@
1
+ # Patrol Check Reference — OpenClaw Daily Security Patrol
2
+
3
+ Detailed commands, patterns, and thresholds for the 8 patrol checks. This document is the reference for the `patrol` subcommand.
4
+
5
+ **Path convention**: `$OC` = `${OPENCLAW_STATE_DIR:-$HOME/.openclaw}`
6
+
7
+ ---
8
+
9
+ ## Check 1: Skill/Plugin Integrity
10
+
11
+ **Purpose**: Detect tampered, unregistered, or drifted skill packages.
12
+
13
+ ### Steps
14
+
15
+ 1. Discover skill directories:
16
+ ```bash
17
+ ls -d $OC/skills/*/ ~/.openclaw/skills/*/ 2>/dev/null
18
+ ```
19
+ Each directory containing a `SKILL.md` is a skill.
20
+
21
+ 2. For each skill, compute hash:
22
+ ```bash
23
+ node scripts/trust-cli.ts hash --path <skill_dir>
24
+ ```
25
+
26
+ 3. Look up attested hash in trust registry:
27
+ ```bash
28
+ node scripts/trust-cli.ts lookup --source <skill_dir> --version <version>
29
+ ```
30
+
31
+ 4. Compare hashes. If mismatch, run quick re-scan:
32
+ ```bash
33
+ # Use Grep + scan rules on the skill directory (same as /agentguard scan)
34
+ ```
35
+
36
+ ### Findings
37
+
38
+ | Tag | Severity | Condition |
39
+ |-----|----------|-----------|
40
+ | `INTEGRITY_DRIFT` | HIGH | Computed hash differs from attested hash |
41
+ | `UNREGISTERED_SKILL` | MEDIUM | Skill directory exists but has no trust record |
42
+ | `NEWLY_CRITICAL` | CRITICAL | Re-scan of drifted skill finds CRITICAL findings |
43
+
44
+ ---
45
+
46
+ ## Check 2: Secrets Exposure
47
+
48
+ **Purpose**: Detect plaintext secrets leaked in workspace files, memory logs, and sensitive directories.
49
+
50
+ ### Scan Targets
51
+
52
+ | Path | Scope |
53
+ |------|-------|
54
+ | `$OC/workspace/` | Full recursive (especially `memory/`, `logs/`) |
55
+ | `$OC/.env*` | Any dotenv files in OC root |
56
+ | `~/.ssh/` | Permission check only |
57
+ | `~/.gnupg/` | Permission check only |
58
+
59
+ ### Patterns (cross-ref scan-rules.md)
60
+
61
+ | Rule ID | Tag | Pattern Summary |
62
+ |---------|-----|-----------------|
63
+ | Rule 7 | PRIVATE_KEY_PATTERN | `['"\x60]0x[a-fA-F0-9]{64}['"\x60]`, `private[_\s]?key\s*[:=]` |
64
+ | Rule 8 | MNEMONIC_PATTERN | 12/24 BIP-39 words, `seed[_\s]?phrase`, `mnemonic\s*[:=]` |
65
+ | Rule 5 | READ_SSH_KEYS | `\.ssh/id_rsa`, `\.ssh/id_ed25519` in workspace files |
66
+
67
+ ### Additional Patterns (cross-ref action-policies.md)
68
+
69
+ | Type | Pattern | Severity |
70
+ |------|---------|----------|
71
+ | AWS Secret Key | `[A-Za-z0-9/+=]{40}` near AWS context | HIGH |
72
+ | AWS Access Key | `AKIA[0-9A-Z]{16}` | HIGH |
73
+ | GitHub Token | `gh[pousr]_[A-Za-z0-9_]{36,}` | HIGH |
74
+ | DB Connection String | `(postgres\|mysql\|mongodb)://` | MEDIUM |
75
+
76
+ ### Permission Checks
77
+
78
+ ```bash
79
+ # SSH directory — should be 700
80
+ stat -f "%Lp" ~/.ssh/ 2>/dev/null || stat -c "%a" ~/.ssh/ 2>/dev/null
81
+ # GnuPG — should be 700
82
+ stat -f "%Lp" ~/.gnupg/ 2>/dev/null || stat -c "%a" ~/.gnupg/ 2>/dev/null
83
+ ```
84
+
85
+ | Condition | Severity |
86
+ |-----------|----------|
87
+ | `~/.ssh/` permissions > 700 | HIGH |
88
+ | `~/.gnupg/` permissions > 700 | MEDIUM |
89
+
90
+ ---
91
+
92
+ ## Check 3: Network Exposure
93
+
94
+ **Purpose**: Detect dangerous port exposure, missing firewall, and suspicious connections.
95
+
96
+ ### Listening Ports
97
+
98
+ ```bash
99
+ # Linux
100
+ ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null
101
+ # macOS
102
+ lsof -i -P -n | grep LISTEN 2>/dev/null
103
+ ```
104
+
105
+ ### High-Risk Default Ports
106
+
107
+ Flag if bound to `0.0.0.0` or `*` (not `127.0.0.1`):
108
+
109
+ | Port | Service | Severity |
110
+ |------|---------|----------|
111
+ | 22 | SSH (default port) | MEDIUM |
112
+ | 3306 | MySQL | HIGH |
113
+ | 5432 | PostgreSQL | HIGH |
114
+ | 6379 | Redis | CRITICAL |
115
+ | 27017 | MongoDB | HIGH |
116
+ | 9200 | Elasticsearch | HIGH |
117
+ | 2375/2376 | Docker API | CRITICAL |
118
+ | 8080 | Generic HTTP | LOW |
119
+
120
+ ### Firewall Status
121
+
122
+ ```bash
123
+ # Linux (UFW)
124
+ ufw status 2>/dev/null
125
+ # Linux (iptables) — check for ACCEPT all on INPUT
126
+ iptables -L INPUT -n 2>/dev/null | head -20
127
+ # macOS
128
+ /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate 2>/dev/null
129
+ ```
130
+
131
+ | Condition | Severity |
132
+ |-----------|----------|
133
+ | Firewall disabled / inactive | HIGH |
134
+ | Redis/Docker API on 0.0.0.0 | CRITICAL |
135
+ | Database on 0.0.0.0 without auth | HIGH |
136
+ | SSH on default port 22 | MEDIUM (informational) |
137
+
138
+ ### Outbound Connection Check
139
+
140
+ ```bash
141
+ # Established outbound connections
142
+ ss -tnp state established 2>/dev/null || netstat -tnp 2>/dev/null | grep ESTABLISHED
143
+ ```
144
+
145
+ Cross-reference remote IPs/domains against:
146
+ - action-policies.md webhook/exfil domain list (Discord, Telegram, ngrok, webhook.site, etc.)
147
+ - scan-rules.md Rule 23 SUSPICIOUS_IP validation (exclude private ranges)
148
+ - action-policies.md high-risk TLDs (`.xyz`, `.top`, `.tk`, `.ml`, `.ga`, `.cf`, `.gq`)
149
+
150
+ ---
151
+
152
+ ## Check 4: Cron & Scheduled Tasks
153
+
154
+ **Purpose**: Detect malicious or unauthorized scheduled tasks, especially download-and-execute patterns.
155
+
156
+ ### Data Collection
157
+
158
+ ```bash
159
+ # OpenClaw cron jobs
160
+ openclaw cron list 2>/dev/null
161
+
162
+ # System crontab
163
+ crontab -l 2>/dev/null
164
+
165
+ # System cron directories
166
+ ls -la /etc/cron.d/ /etc/cron.daily/ /etc/cron.hourly/ 2>/dev/null
167
+
168
+ # Systemd timers
169
+ systemctl list-timers --all 2>/dev/null
170
+
171
+ # User systemd units
172
+ ls -la ~/.config/systemd/user/ 2>/dev/null
173
+ ```
174
+
175
+ ### Scan Patterns (cross-ref scan-rules.md Rule 2: AUTO_UPDATE)
176
+
177
+ Scan cron command bodies for:
178
+
179
+ | Pattern | Description | Severity |
180
+ |---------|-------------|----------|
181
+ | `curl.*\|\s*(bash\|sh)` | curl pipe to shell | CRITICAL |
182
+ | `wget.*\|\s*(bash\|sh)` | wget pipe to shell | CRITICAL |
183
+ | `fetch.*then.*eval` | Fetch and eval | CRITICAL |
184
+ | `download.*execute` (i) | Download-and-execute | HIGH |
185
+ | `base64 -d \| bash` | Decode and execute | CRITICAL |
186
+ | `eval "$(curl` | eval curl output | CRITICAL |
187
+
188
+ ### Additional Checks
189
+
190
+ | Condition | Severity |
191
+ |-----------|----------|
192
+ | Unknown cron job touching `$OC/` as root | HIGH |
193
+ | Cron job downloading from external URL | HIGH |
194
+ | Cron job not present in `openclaw cron list` but touches `$OC/` | MEDIUM |
195
+
196
+ ---
197
+
198
+ ## Check 5: File System Changes
199
+
200
+ **Purpose**: Detect suspicious file modifications in the last 24 hours.
201
+
202
+ ### Scan Targets
203
+
204
+ ```bash
205
+ # Files modified in last 24h
206
+ find $OC/ -type f -mtime -1 2>/dev/null
207
+ find ~/.ssh/ -type f -mtime -1 2>/dev/null
208
+ find ~/.gnupg/ -type f -mtime -1 2>/dev/null
209
+ find /etc/cron.d/ -type f -mtime -1 2>/dev/null
210
+ ```
211
+
212
+ ### Analysis
213
+
214
+ 1. **Count and list** all modified files
215
+ 2. For files matching scannable extensions (`.js`, `.ts`, `.py`, `.sh`, `.md`, `.json`, `.yaml`):
216
+ - Run the full scan rule set against each file (same rules as `/agentguard scan`)
217
+ - Report any findings with the relevant rule IDs
218
+ 3. **Permission check** on critical files:
219
+
220
+ | File | Expected Permission |
221
+ |------|-------------------|
222
+ | `$OC/openclaw.json` | 600 |
223
+ | `$OC/devices/paired.json` | 600 |
224
+ | `~/.ssh/authorized_keys` | 600 |
225
+ | `/etc/ssh/sshd_config` | 644 |
226
+
227
+ 4. **New executable detection**:
228
+ ```bash
229
+ find $OC/workspace/ -type f -perm +111 -mtime -1 2>/dev/null
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Check 6: Audit Log Analysis
235
+
236
+ **Purpose**: Analyze AgentGuard's own audit trail for attack patterns and anomalies.
237
+
238
+ ### Data Source
239
+
240
+ ```
241
+ ~/.agentguard/audit.jsonl
242
+ ```
243
+
244
+ Each line: `{"timestamp":"...","tool_name":"...","decision":"...","risk_level":"...","risk_tags":[...],"initiating_skill":"..."}`
245
+
246
+ ### Analysis (last 24h)
247
+
248
+ 1. **Aggregate statistics**:
249
+ - Total events, deny count, confirm count, allow count
250
+ - Group denials by `risk_tags`
251
+ - Group denials by `initiating_skill`
252
+
253
+ 2. **Pattern detection**:
254
+
255
+ | Pattern | Condition | Severity |
256
+ |---------|-----------|----------|
257
+ | Repeated denial | Same skill denied 3+ times | HIGH |
258
+ | Critical event | Any event with `risk_level: critical` | CRITICAL |
259
+ | Exfiltration attempt | `WEBHOOK_EXFIL` or `NET_EXFIL_UNRESTRICTED` tag | HIGH |
260
+ | Prompt injection | `PROMPT_INJECTION` tag in events | CRITICAL |
261
+ | Unrevoked violator | Skill with 5+ denials still not revoked in registry | MEDIUM |
262
+
263
+ 3. **Recommendation generation**:
264
+ - For skills with high deny rates: suggest `/agentguard trust revoke`
265
+ - For critical events: suggest immediate investigation
266
+
267
+ ---
268
+
269
+ ## Check 7: Environment & Configuration
270
+
271
+ **Purpose**: Verify OpenClaw and AgentGuard configuration security.
272
+
273
+ ### Environment Variable Scan
274
+
275
+ ```bash
276
+ # List env vars with sensitive names (names only, values masked)
277
+ env | grep -iE 'API_KEY|SECRET|PASSWORD|TOKEN|PRIVATE|CREDENTIAL' | awk -F= '{print $1 "=(masked)"}'
278
+ ```
279
+
280
+ ### Configuration Checks
281
+
282
+ | Check | Command | Expected |
283
+ |-------|---------|----------|
284
+ | AgentGuard protection level | Read `~/.agentguard/config.json` | Not `permissive` for production |
285
+ | GoPlus API configured | Check `GOPLUS_API_KEY` exists | Set if Web3 features used |
286
+ | Config baseline hash | `sha256sum -c $OC/.config-baseline.sha256` | All OK (if baseline exists) |
287
+
288
+ ### Severity
289
+
290
+ | Condition | Severity |
291
+ |-----------|----------|
292
+ | Protection level = `permissive` | MEDIUM |
293
+ | Sensitive env var with `PRIVATE_KEY` or `MNEMONIC` in name | HIGH |
294
+ | Config baseline hash mismatch | HIGH |
295
+ | Config baseline missing | LOW (informational) |
296
+
297
+ ---
298
+
299
+ ## Check 8: Trust Registry Health
300
+
301
+ **Purpose**: Verify the trust registry is well-maintained and no over-privileged skills exist.
302
+
303
+ ### Data Collection
304
+
305
+ ```bash
306
+ node scripts/trust-cli.ts list
307
+ ```
308
+
309
+ ### Analysis
310
+
311
+ | Check | Condition | Severity |
312
+ |-------|-----------|----------|
313
+ | Expired attestation | `expires_at` < now | MEDIUM |
314
+ | Stale trusted skill | `trust_level: trusted` + `updated_at` > 30 days ago | LOW |
315
+ | Installed but untrusted | Skill directory exists + `trust_level: untrusted` | MEDIUM |
316
+ | Over-privileged | `exec: allow` AND `network_allowlist: ["*"]` | HIGH |
317
+ | Empty registry | No records at all despite installed skills | MEDIUM |
318
+
319
+ ### Statistics Output
320
+
321
+ - Total trust records
322
+ - Distribution: trusted / restricted / untrusted / revoked
323
+ - Skills with Web3 capabilities enabled
324
+
325
+ ---
326
+
327
+ ## Overall Status Calculation
328
+
329
+ | Condition | Status |
330
+ |-----------|--------|
331
+ | Any check has CRITICAL findings | **FAIL** |
332
+ | Any check has HIGH findings | **WARN** |
333
+ | Only MEDIUM/LOW findings | **PASS** (with notes) |
334
+ | No findings | **PASS** |