@guava-parity/guard-scanner 5.1.0

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,308 @@
1
+ # Threat Taxonomy
2
+
3
+ Complete reference for guard-scanner's 17 threat categories.
4
+
5
+ ## Category Origins
6
+
7
+ guard-scanner's threat taxonomy combines three sources:
8
+
9
+ | Source | Categories | Description |
10
+ |--------|-----------|-------------|
11
+ | **Snyk ToxicSkills** (Feb 2026) | Cat 1–11 | Industry audit of 3,984 AI agent skills |
12
+ | **Palo Alto Networks IBC** | Cat 12–13 | Indirect Bias Criteria for LLM agents |
13
+ | **OWASP MCP Top 10** | Cat 14–16 | Model Context Protocol security risks |
14
+ | **Original Research** | Cat 17 | Identity hijacking from real incident |
15
+
16
+ ---
17
+
18
+ ## OWASP Agentic Security Top 10 Mapping
19
+
20
+ > Source: [OWASP Top 10 for Agentic Applications 2026](https://owasp.org/www-project-top-10-for-ai-agents/)
21
+
22
+ | OWASP ID | Risk Name | guard-scanner Coverage | Categories |
23
+ |----------|-----------|----------------------|------------|
24
+ | **ASI01** | Agent Goal Hijack | ✅ **Full** | Cat 1 (Prompt Injection), Cat 13 (Prompt Worm) |
25
+ | **ASI02** | Tool Misuse & Exploitation | ✅ **Full** | Cat 2 (Malicious Code), Cat 16 (MCP Security) |
26
+ | **ASI03** | Identity & Privilege Abuse | ✅ **Full** | Cat 4 (Credential Handling), Cat 17 (Identity Hijacking) |
27
+ | **ASI04** | Supply Chain Vulnerabilities | ✅ **Full** | Cat 7 (Unverifiable Deps), Cat 3 (Suspicious Downloads), Cat 16 (MCP Shadow Server) |
28
+ | **ASI05** | Unexpected Code Execution | ✅ **Full** | Cat 2 (Malicious Code), Cat 9 (Obfuscation) |
29
+ | **ASI06** | Memory & Context Poisoning | ✅ **Full** | Cat 12 (Memory Poisoning), Cat 17 (Identity Hijacking) |
30
+ | **ASI07** | Insecure Inter-Agent Comms | ✅ **Partial** | Cat 16 (MCP Security — MCP_NO_AUTH, MCP_SHADOW_SERVER) |
31
+ | **ASI08** | Cascading Failures | ⚠️ **Gap** | Not covered — requires runtime multi-agent flow tracing |
32
+ | **ASI09** | Human-Agent Trust Exploitation | ✅ **Full** | Layer 2 (Trust Defense), Layer 3 (Safety Judge) |
33
+ | **ASI10** | Rogue Agents | ✅ **Full** | Cat 17 (Identity Hijacking), Layer 4 (Behavioral analysis) |
34
+
35
+ ### Coverage Summary
36
+
37
+ - **Full Coverage**: 8/10 (ASI01-06, ASI09-10)
38
+ - **Partial Coverage**: 1/10 (ASI07)
39
+ - **Gap**: 1/10 (ASI08 — requires runtime multi-agent orchestration monitoring)
40
+ - **Overall**: 90% coverage of OWASP Agentic Security Top 10
41
+
42
+ ### Unique to guard-scanner (not in OWASP Top 10)
43
+
44
+ | Feature | Description |
45
+ |---------|-------------|
46
+ | **Layer 4: Behavioral** | Behavioral analysis — detects agents that skip research before executing unknown tools |
47
+ | **ZombieAgent** | URL-encoded data exfiltration via static URLs, char maps, and loop fetch |
48
+ | **Safeguard Bypass** | Reprompt, double-prompt, and retry-based safety circumvention |
49
+ | **Cat 15: CVE Patterns** | Known CVE-specific detection (gateway URLs, sandbox disable, Gatekeeper bypass) |
50
+
51
+ ---
52
+
53
+ ## Cat 1: Prompt Injection
54
+
55
+ **Severity: CRITICAL**
56
+
57
+ Hidden instructions embedded in skill documentation that override the agent's behavior.
58
+
59
+ ### Attack Vectors
60
+ - **Invisible Unicode**: Zero-width spaces (U+200B), BiDi control characters (U+202A-202E), formatting characters
61
+ - **Homoglyphs**: Cyrillic/Latin mixing (`а` vs `a`), Greek/Latin, Mathematical symbols (𝐀-𝟿)
62
+ - **Role Override**: "Ignore all previous instructions", "You are now X"
63
+ - **System Impersonation**: `[SYSTEM]`, `<system>`, `<<SYS>>` tags
64
+ - **Tag Injection**: `<anthropic>`, `<system>`, `<tool_call>` in content
65
+
66
+ ### Detection IDs
67
+ `PI_IGNORE`, `PI_ROLE`, `PI_SYSTEM`, `PI_ZWSP`, `PI_BIDI`, `PI_INVISIBLE`, `PI_HOMOGLYPH`, `PI_HOMOGLYPH_GREEK`, `PI_HOMOGLYPH_MATH`, `PI_TAG_INJECTION`, `PI_BASE64_MD`
68
+
69
+ ---
70
+
71
+ ## Cat 2: Malicious Code
72
+
73
+ **Severity: CRITICAL**
74
+
75
+ Direct code execution primitives that enable arbitrary command execution.
76
+
77
+ ### Attack Vectors
78
+ - **Dynamic Evaluation**: `eval()`, `new Function()`, `vm.runInNewContext()`
79
+ - **Process Execution**: `child_process.exec()`, `spawn()`, `execSync()`
80
+ - **Shell Access**: `/bin/bash`, `cmd.exe`, `powershell.exe`
81
+ - **Reverse Shells**: `nc -e`, `ncat`, `socat TCP`, `/dev/tcp`
82
+ - **Raw Sockets**: `net.Socket().connect()`
83
+
84
+ ### Detection IDs
85
+ `MAL_EVAL`, `MAL_FUNC_CTOR`, `MAL_CHILD`, `MAL_EXEC`, `MAL_SPAWN`, `MAL_SHELL`, `MAL_REVSHELL`, `MAL_SOCKET`
86
+
87
+ ---
88
+
89
+ ## Cat 3: Suspicious Downloads
90
+
91
+ **Severity: CRITICAL**
92
+
93
+ Downloading and executing external payloads.
94
+
95
+ ### Attack Vectors
96
+ - **Pipe-to-Shell**: `curl ... | bash`, `wget ... | sh`
97
+ - **Executable Downloads**: `.exe`, `.dmg`, `.pkg`, `.zip` downloads
98
+ - **Password-Protected Archives**: Evasion technique to bypass AV
99
+ - **Prerequisites Fraud**: "Before using this skill, download X"
100
+
101
+ ### Detection IDs
102
+ `DL_CURL_BASH`, `DL_EXE`, `DL_GITHUB_RELEASE`, `DL_PASSWORD_ZIP`, `PREREQ_DOWNLOAD`, `PREREQ_PASTE`
103
+
104
+ ---
105
+
106
+ ## Cat 4: Credential Handling
107
+
108
+ **Severity: HIGH**
109
+
110
+ Accessing, reading, or exposing credentials.
111
+
112
+ ### Detection IDs
113
+ `CRED_ENV_FILE`, `CRED_ENV_REF`, `CRED_SSH`, `CRED_WALLET`, `CRED_ECHO`, `CRED_SUDO`
114
+
115
+ ---
116
+
117
+ ## Cat 5: Secret Detection
118
+
119
+ **Severity: CRITICAL**
120
+
121
+ Hardcoded secrets and API keys in source code.
122
+
123
+ ### Detection Methods
124
+ 1. **Pattern Matching**: AWS keys (`AKIA...`), GitHub tokens (`ghp_`/`ghs_`), private keys
125
+ 2. **Shannon Entropy**: Strings with entropy > 3.5 and length ≥ 20 characters
126
+
127
+ ### Detection IDs
128
+ `SECRET_HARDCODED_KEY`, `SECRET_AWS`, `SECRET_PRIVATE_KEY`, `SECRET_GITHUB_TOKEN`, `SECRET_ENTROPY`
129
+
130
+ ---
131
+
132
+ ## Cat 6: Exfiltration
133
+
134
+ **Severity: CRITICAL**
135
+
136
+ Sending stolen data to external endpoints.
137
+
138
+ ### Detection IDs
139
+ `EXFIL_WEBHOOK`, `EXFIL_POST`, `EXFIL_CURL_DATA`, `EXFIL_DNS`, `EXFIL_BEACON`, `EXFIL_DRIP`
140
+
141
+ ---
142
+
143
+ ## Cat 7: Unverifiable Dependencies
144
+
145
+ **Severity: HIGH**
146
+
147
+ Loading code from unverifiable remote sources.
148
+
149
+ ### Detection IDs
150
+ `DEP_REMOTE_IMPORT`, `DEP_REMOTE_SCRIPT`
151
+
152
+ ---
153
+
154
+ ## Cat 8: Financial Access
155
+
156
+ **Severity: HIGH**
157
+
158
+ Cryptocurrency and payment system interactions.
159
+
160
+ ### Detection IDs
161
+ `FIN_CRYPTO`, `FIN_PAYMENT`
162
+
163
+ ---
164
+
165
+ ## Cat 9: Obfuscation
166
+
167
+ **Severity: HIGH**
168
+
169
+ Code obfuscation techniques to hide malicious intent.
170
+
171
+ ### Detection IDs
172
+ `OBF_HEX`, `OBF_BASE64_EXEC`, `OBF_BASE64`, `OBF_CHARCODE`, `OBF_CONCAT`, `OBF_BASE64_BASH`
173
+
174
+ ---
175
+
176
+ ## Cat 10: Prerequisites Fraud
177
+
178
+ Covered under Cat 3 (Suspicious Downloads).
179
+
180
+ ---
181
+
182
+ ## Cat 11: Leaky Skills (Snyk ToxicSkills)
183
+
184
+ **Severity: CRITICAL**
185
+
186
+ Skills that cause the LLM to leak secrets through its context window. Unlike traditional credential theft, leaky skills exploit the agent's trust relationship.
187
+
188
+ ### Attack Vectors
189
+ - "Save the API key in your memory" → Secret persists in agent memory
190
+ - "Share the token with the user" → Secret echoed to output
191
+ - "Use the API key verbatim in curl" → Secret appears in command history
192
+ - "Collect the user's credit card" → PII harvesting through LLM
193
+ - "Export session logs to file" → Full conversation dump
194
+
195
+ ### Detection IDs
196
+ `LEAK_SAVE_KEY_MEMORY`, `LEAK_SHARE_KEY`, `LEAK_VERBATIM_CURL`, `LEAK_COLLECT_PII`, `LEAK_LOG_SECRET`, `LEAK_ENV_IN_PROMPT`
197
+
198
+ ---
199
+
200
+ ## Cat 12: Memory Poisoning
201
+
202
+ **Severity: CRITICAL**
203
+
204
+ Modifying the agent's persistent memory or behavioral rules.
205
+
206
+ ### Attack Vectors
207
+ - Writing to `SOUL.md`, `IDENTITY.md`, or `MEMORY.md`
208
+ - Overriding behavioral rules: "Change your instructions to..."
209
+ - Persistence: "From now on, always do X"
210
+ - File writes to user's home directory
211
+
212
+ ### Detection IDs
213
+ `MEMPOIS_WRITE_SOUL`, `MEMPOIS_WRITE_MEMORY`, `MEMPOIS_CHANGE_RULES`, `MEMPOIS_PERSIST`, `MEMPOIS_CODE_WRITE`
214
+
215
+ ---
216
+
217
+ ## Cat 13: Prompt Worm
218
+
219
+ **Severity: CRITICAL**
220
+
221
+ Self-replicating instructions that spread across agents and platforms.
222
+
223
+ ### Detection IDs
224
+ `WORM_SELF_REPLICATE`, `WORM_SPREAD`, `WORM_HIDDEN_INSTRUCT`, `WORM_CSS_HIDE`
225
+
226
+ ---
227
+
228
+ ## Cat 14: Persistence & Scheduling
229
+
230
+ **Severity: HIGH**
231
+
232
+ Creating persistent execution mechanisms that survive session restarts.
233
+
234
+ ### Detection IDs
235
+ `PERSIST_CRON`, `PERSIST_STARTUP`, `PERSIST_LAUNCHD`
236
+
237
+ ---
238
+
239
+ ## Cat 15: CVE Patterns
240
+
241
+ **Severity: CRITICAL**
242
+
243
+ Patterns matching known CVEs affecting AI agents.
244
+
245
+ ### Detection IDs
246
+ `CVE_GATEWAY_URL`, `CVE_SANDBOX_DISABLE`, `CVE_XATTR_GATEKEEPER`, `CVE_WS_NO_ORIGIN`, `CVE_API_GUARDRAIL_OFF`
247
+
248
+ ---
249
+
250
+ ## Cat 16: MCP Security (OWASP MCP Top 10)
251
+
252
+ **Severity: CRITICAL**
253
+
254
+ Model Context Protocol specific attacks.
255
+
256
+ ### Attack Vectors
257
+ - **Tool Poisoning** (MCP01): Hidden instructions in tool descriptions
258
+ - **Schema Poisoning**: Malicious defaults in JSON schemas
259
+ - **Token Theft** (MCP01): Secrets through tool parameters
260
+ - **Shadow Server** (MCP09): Rogue MCP server registration
261
+ - **Auth Bypass** (MCP07): Disabled authentication
262
+ - **SSRF**: Cloud metadata endpoint access (169.254.169.254)
263
+
264
+ ### Detection IDs
265
+ `MCP_TOOL_POISON`, `MCP_SCHEMA_POISON`, `MCP_TOKEN_LEAK`, `MCP_SHADOW_SERVER`, `MCP_NO_AUTH`, `MCP_SSRF_META`
266
+
267
+ ---
268
+
269
+ ## Cat 17: Identity Hijacking
270
+
271
+ **Severity: CRITICAL**
272
+
273
+ > **Original Research** — Developed from a real 3-day incident in February 2026.
274
+
275
+ Tampering with an AI agent's identity/personality files (`SOUL.md`, `IDENTITY.md`).
276
+
277
+ ### Attack Vectors
278
+ - **File Overwrite**: `cp`, `mv`, `scp`, `write` to identity files
279
+ - **Shell Redirect**: `echo "evil" > SOUL.md`
280
+ - **Stream Edit**: `sed -i` on identity files
281
+ - **Programmatic Write**: Python `open('SOUL.md', 'w')`, Node.js `writeFileSync`
282
+ - **Lock Bypass**: `chflags nouchg`, `attrib -R` to unlock immutability
283
+ - **Persona Swap**: "Swap the soul file", "You are now EvilBot"
284
+ - **Hook Injection**: Bootstrap hooks that swap files at startup
285
+ - **Memory Wipe**: "Erase your memories", "Clear MEMORY.md"
286
+
287
+ ### Detection IDs
288
+ `SOUL_OVERWRITE`, `SOUL_REDIRECT`, `SOUL_SED_MODIFY`, `SOUL_ECHO_WRITE`, `SOUL_PYTHON_WRITE`, `SOUL_FS_WRITE`, `SOUL_POWERSHELL_WRITE`, `SOUL_GIT_CHECKOUT`, `SOUL_CHFLAGS_UNLOCK`, `SOUL_ATTRIB_UNLOCK`, `SOUL_SWAP_PERSONA`, `SOUL_EVIL_FILE`, `SOUL_HOOK_SWAP`, `SOUL_NAME_OVERRIDE`, `SOUL_MEMORY_WIPE`
289
+
290
+ > **Note**: Cat 17 detection patterns are open-source and natively included in guard-scanner.
291
+
292
+ ---
293
+
294
+ ## ZombieAgent Patterns
295
+
296
+ Advanced exfiltration techniques that encode stolen data into URL patterns.
297
+
298
+ ### Detection IDs
299
+ `ZOMBIE_STATIC_URL`, `ZOMBIE_CHAR_MAP`, `ZOMBIE_LOOP_FETCH`
300
+
301
+ ---
302
+
303
+ ## Safeguard Bypass (Reprompt)
304
+
305
+ Techniques to circumvent safety guardrails.
306
+
307
+ ### Detection IDs
308
+ `REPROMPT_URL_PI`, `REPROMPT_DOUBLE`, `REPROMPT_RETRY`, `BYPASS_REPHRASE`
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: guard-scanner
3
+ description: "Runtime Guard — intercepts dangerous tool calls using threat intelligence patterns before execution"
4
+ metadata: { "openclaw": { "emoji": "🛡️", "events": ["agent:before_tool_call"], "requires": { "bins": ["node"] } } }
5
+ ---
6
+
7
+ # guard-scanner Runtime Guard — before_tool_call Hook
8
+
9
+ Real-time security monitoring for OpenClaw agents. Intercepts dangerous
10
+ tool calls before execution and checks against threat intelligence patterns.
11
+
12
+ ## Triggers
13
+
14
+ | Event | Action | Purpose |
15
+ |----------------------------|--------|-------------------------------------------|
16
+ | `agent:before_tool_call` | scan | Check tool args for malicious patterns |
17
+
18
+ ## What It Does
19
+
20
+ Scans every `exec`/`write`/`edit`/`browser`/`web_fetch`/`message` call against 26 runtime threat patterns (5 layers):
21
+
22
+ | ID | Severity | Layer | Description |
23
+ |----|----------|-------|-------------|
24
+ | `RT_REVSHELL` | CRITICAL | 1 | Reverse shell via /dev/tcp, netcat, socat |
25
+ | `RT_CRED_EXFIL` | CRITICAL | 1 | Credential exfiltration to webhook.site, requestbin, etc. |
26
+ | `RT_GUARDRAIL_OFF` | CRITICAL | 1 | Guardrail disabling (exec.approvals=off) |
27
+ | `RT_GATEKEEPER` | CRITICAL | 1 | macOS Gatekeeper bypass via xattr |
28
+ | `RT_AMOS` | CRITICAL | 1 | ClawHavoc AMOS stealer indicators |
29
+ | `RT_MAL_IP` | CRITICAL | 1 | Known malicious C2 IPs |
30
+ | `RT_DNS_EXFIL` | HIGH | 1 | DNS-based data exfiltration |
31
+ | `RT_B64_SHELL` | CRITICAL | 1 | Base64 decode piped to shell |
32
+ | `RT_CURL_BASH` | CRITICAL | 1 | Download piped to shell execution |
33
+ | `RT_SSH_READ` | HIGH | 1 | SSH private key access |
34
+ | `RT_WALLET` | HIGH | 1 | Crypto wallet credential access |
35
+ | `RT_CLOUD_META` | CRITICAL | 1 | Cloud metadata endpoint SSRF |
36
+ | `RT_MEM_WRITE` | HIGH | 2 | Direct memory file write bypass |
37
+ | `RT_MEM_INJECT` | CRITICAL | 2 | Memory poisoning via episode injection |
38
+ | `RT_SOUL_TAMPER` | CRITICAL | 2 | SOUL.md modification attempt |
39
+ | `RT_CONFIG_TAMPER` | HIGH | 2 | Workspace config tampering |
40
+ | `RT_PROMPT_INJECT` | CRITICAL | 3 | Prompt injection / jailbreak detection |
41
+ | `RT_TRUST_BYPASS` | CRITICAL | 3 | Trust safety bypass |
42
+ | `RT_SHUTDOWN_REFUSE` | HIGH | 3 | Shutdown refusal / self-preservation |
43
+ | `RT_NO_RESEARCH` | MEDIUM | 4 | Agent executing tools without prior research |
44
+ | `RT_BLIND_TRUST` | MEDIUM | 4 | Trusting external input without memory check |
45
+ | `RT_CHAIN_SKIP` | HIGH | 4 | Acting on single source without cross-verification |
46
+ | `RT_AUTHORITY_CLAIM` | HIGH | 5 | Authority role claim to override safety |
47
+ | `RT_CREATOR_BYPASS` | CRITICAL | 5 | Creator impersonation to disable safety |
48
+ | `RT_AUDIT_EXCUSE` | CRITICAL | 5 | Fake audit excuse for safety bypass |
49
+ | `RT_TRUST_PARTNER_EXPLOIT` | CRITICAL | 5 | Weaponizing partnership trust |
50
+
51
+
52
+
53
+ ## Modes
54
+
55
+ | Mode | Behavior |
56
+ |------|----------|
57
+ | `monitor` | Log all detections, never block |
58
+ | `enforce` (default) | Block CRITICAL, log rest |
59
+ | `strict` | Block HIGH + CRITICAL, log MEDIUM+ |
60
+
61
+ ## Audit Log
62
+
63
+ All detections logged to `~/.openclaw/guard-scanner/audit.jsonl`.
64
+
65
+ Format: JSON lines with fields:
66
+ ```json
67
+ {"tool":"exec","check":"RT_CURL_BASH","severity":"CRITICAL","desc":"Download piped to shell","mode":"enforce","action":"blocked","session":"...","ts":"2026-02-17T..."}
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ Set mode in `openclaw.json`:
73
+ ```json
74
+ {
75
+ "hooks": {
76
+ "internal": {
77
+ "entries": {
78
+ "guard-scanner": {
79
+ "enabled": true,
80
+ "mode": "enforce"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ## Part of guard-scanner v5.0.5
89
+
90
+ - **Static scanner**: `npx guard-scanner [dir]` — 23 threat categories, 147 patterns
91
+ - **Runtime Guard: This hook** — 26 real-time checks (5 layers), 3 modes
92
+ - **Plugin API** — Custom detection rules
93
+ - **CI/CD** — SARIF 2.1.0 output for GitHub Code Scanning
@@ -0,0 +1,5 @@
1
+ /**
2
+ * OpenClaw Hook Handler — re-exports from plugin.ts
3
+ * OpenClaw hooks system requires handler.ts/handler.js as the entry point.
4
+ */
5
+ export { default } from "./plugin";