clawguard-cli 0.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 Vishal M
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,247 @@
1
+ # ClawGuard
2
+
3
+ **Security scanner for OpenClaw AI agent installations.**
4
+
5
+ OpenClaw ships with dangerous defaults: sandbox disabled, plaintext API keys in config files, gateway exposed to LAN, and a skills marketplace with [341 known malicious packages](https://clawhub.dev/security). CVE-2026-25253 allows 1-click remote code execution on unpatched installations.
6
+
7
+ ClawGuard scans your local OpenClaw setup, flags every vulnerability with severity ratings, and auto-fixes the most common issues. Think `npm audit` for your AI agent.
8
+
9
+ [![npm version](https://img.shields.io/npm/v/clawguard.svg)](https://www.npmjs.com/package/clawguard)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+ [![Node 18+](https://img.shields.io/badge/node-18+-blue.svg)](https://nodejs.org/)
12
+
13
+ ## Why ClawGuard?
14
+
15
+ A default OpenClaw install scores **0/100** on our security checks:
16
+
17
+ - Sandbox mode is **OFF** - agents execute commands directly on your host
18
+ - API keys are stored in **plaintext** in `~/.openclaw/openclaw.json`
19
+ - Gateway binds to **LAN** instead of loopback
20
+ - No exec allowlisting - any tool call runs unrestricted
21
+ - Skills from ClawHub run with whatever permissions they request
22
+ - Session transcripts can leak credentials into `.jsonl` logs
23
+
24
+ Most users don't know this. ClawGuard tells them exactly what's wrong and how to fix it.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ npm install -g clawguard
30
+ ```
31
+
32
+ Or with npx (no install):
33
+
34
+ ```bash
35
+ npx clawguard scan
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ```bash
41
+ # Scan your OpenClaw installation (auto-detects ~/.openclaw/)
42
+ clawguard scan
43
+
44
+ # Auto-fix common security issues
45
+ clawguard fix
46
+
47
+ # Verify fixes
48
+ clawguard scan
49
+ ```
50
+
51
+ ## Example Output
52
+
53
+ ```
54
+ ClawGuard v0.1.0 - OpenClaw Security Scanner
55
+
56
+ Scanning /home/user/.openclaw/ ...
57
+
58
+ CRITICAL Plaintext API keys found in configuration
59
+ openclaw.json: Anthropic API key (sk-ant-...) on line 14
60
+ openclaw.json: OpenAI API key (sk-proj-...) on line 18
61
+ credentials/profiles.json: Telegram bot token on line 7
62
+ Fix: Use environment variables: "apiKey": "${ANTHROPIC_API_KEY}"
63
+
64
+ CRITICAL Sandbox mode is disabled
65
+ agents.defaults.sandbox.mode = "off"
66
+ Fix: Set sandbox.mode to "all" in openclaw.json
67
+
68
+ CRITICAL Gateway bound to LAN
69
+ gateway.bind = "lan" (should be "loopback")
70
+ Fix: Set gateway.bind to "loopback" in openclaw.json
71
+
72
+ HIGH Weak gateway auth token
73
+ Token length: 4 characters (minimum: 32)
74
+ Fix: openssl rand -hex 32
75
+
76
+ HIGH Commands execute on host, not in sandbox
77
+ tools.exec.host = "gateway"
78
+ Fix: Set to "sandbox" in openclaw.json
79
+
80
+ MEDIUM Log redaction not enabled
81
+ Fix: Set logging.redactSensitive to "tools" in openclaw.json
82
+
83
+ ==================================================
84
+
85
+ Score: 0/100 CRITICAL RISK
86
+
87
+ Found: 3 critical, 2 high, 1 medium, 0 info
88
+ Run clawguard fix to auto-fix 6 issues
89
+ ```
90
+
91
+ After running `clawguard fix`:
92
+
93
+ ```
94
+ Score: 85/100 GOOD
95
+
96
+ Found: 0 critical, 0 high, 0 medium, 3 info
97
+ ```
98
+
99
+ ## CLI Reference
100
+
101
+ ```bash
102
+ # Full scan (auto-detects ~/.openclaw/, ~/.clawdbot/, ~/.moltbot/)
103
+ clawguard scan
104
+
105
+ # Scan a specific directory
106
+ clawguard scan --path /path/to/openclaw
107
+
108
+ # JSON output for CI/CD pipelines
109
+ clawguard scan --format json
110
+
111
+ # Run only specific check categories
112
+ clawguard scan --check credentials gateway sandbox
113
+
114
+ # Auto-fix common issues
115
+ clawguard fix
116
+ clawguard fix --path /path/to/openclaw
117
+
118
+ # Show version
119
+ clawguard version
120
+ ```
121
+
122
+ ### Available Check Categories
123
+
124
+ `credentials` `gateway` `sandbox` `permissions` `version` `skills` `memory`
125
+
126
+ ### Exit Codes
127
+
128
+ | Code | Meaning |
129
+ |---|---|
130
+ | 0 | Scan passed, no critical issues |
131
+ | 1 | Error (path not found, invalid args) |
132
+ | 2 | Critical issues found |
133
+
134
+ ## Security Checks
135
+
136
+ ### 25+ checks across 7 categories:
137
+
138
+ | Category | Checks | Severity |
139
+ |---|---|---|
140
+ | **Credentials** | Plaintext API keys in config, `.env`, `.bak` files, session transcripts, log redaction settings | CRITICAL |
141
+ | **Gateway** | Bind address (loopback vs LAN), auth token strength, port exposure on 0.0.0.0 | CRITICAL |
142
+ | **Sandbox** | Sandbox mode, Docker availability, network isolation, exec host, exec allowlisting | CRITICAL |
143
+ | **Version** | OpenClaw version against CVE-2026-25253 (RCE) and CVE-2026-21636, Node.js version | CRITICAL |
144
+ | **Skills** | Malicious patterns, C2 IPs, typosquatted publishers, permission analysis, suspicious binaries | CRITICAL |
145
+ | **Permissions** | Directory (700) and file (600) permissions on sensitive configs and credentials | HIGH |
146
+ | **Memory** | SOUL.md/MEMORY.md injection detection, credential leaks in daily logs | HIGH |
147
+
148
+ ### Credential Patterns
149
+
150
+ Detects 17+ key formats: `sk-ant-` (Anthropic), `sk-proj-` (OpenAI), `gsk_` (Groq), `xai-` (xAI), `AKIA` (AWS), `ghp_`/`gho_` (GitHub), `glpat-` (GitLab), `xoxb-`/`xoxp-` (Slack), Telegram bot tokens, Discord tokens, `sk_live_` (Stripe), OpenRouter, Google AI, and generic Bearer tokens.
151
+
152
+ ### Malicious Skill Detection
153
+
154
+ - Remote code execution patterns (`curl | sh`, `wget | bash`)
155
+ - Base64-encoded payloads over 50 characters
156
+ - Known C2 IP addresses from the ClawHavoc campaign
157
+ - References to paste services (glot.io, pastebin.com, hastebin)
158
+ - Typosquatted ClawHub publisher names
159
+ - Suspicious binary requirements (`nc`, `ncat`, `netcat`, `nmap`, `socat`)
160
+ - Excessive permission requests (exec + sensitive_data + filesystem write)
161
+ - Password-protected archive downloads
162
+
163
+ ## Auto-Fix
164
+
165
+ `clawguard fix` remediates these issues automatically:
166
+
167
+ | Issue | Fix Applied |
168
+ |---|---|
169
+ | Wrong file permissions | `chmod 700` dirs, `chmod 600` config files |
170
+ | Sandbox disabled | Sets `sandbox.mode` to `"all"` |
171
+ | No Docker network isolation | Sets `docker.network` to `"none"` |
172
+ | Exec runs on host | Sets `tools.exec.host` to `"sandbox"` |
173
+ | Log redaction off | Sets `logging.redactSensitive` to `"tools"` |
174
+ | Weak gateway token | Generates 64-character hex token |
175
+ | `.bak` files with old creds | Deletes backup files |
176
+
177
+ ## CI/CD Integration
178
+
179
+ ClawGuard returns exit code `2` when critical issues are found:
180
+
181
+ ```yaml
182
+ # GitHub Actions
183
+ - name: OpenClaw security scan
184
+ run: |
185
+ npm install -g clawguard
186
+ clawguard scan --format json > security-report.json
187
+ clawguard scan
188
+ ```
189
+
190
+ ```yaml
191
+ # GitLab CI
192
+ security_scan:
193
+ script:
194
+ - npm install -g clawguard
195
+ - clawguard scan --format json --path $OPENCLAW_DIR
196
+ allow_failure: false
197
+ ```
198
+
199
+ ## Scoring
200
+
201
+ Starts at 100, deducted per finding:
202
+
203
+ | Severity | Points Deducted |
204
+ |---|---|
205
+ | CRITICAL | -20 |
206
+ | HIGH | -10 |
207
+ | MEDIUM | -5 |
208
+ | INFO | 0 |
209
+
210
+ | Score Range | Rating |
211
+ |---|---|
212
+ | 81-100 | Good |
213
+ | 61-80 | Fair |
214
+ | 31-60 | Poor |
215
+ | 0-30 | Critical Risk |
216
+
217
+ ## Development
218
+
219
+ ```bash
220
+ git clone https://github.com/vman7250/clawguard.git
221
+ cd clawguard-npm
222
+ npm install
223
+ npm run build
224
+
225
+ # Test against insecure fixture
226
+ node dist/index.js scan --path tests/fixtures/
227
+
228
+ # Test against secure fixture
229
+ node dist/index.js scan --path tests/fixtures/secure_config.json
230
+ ```
231
+
232
+ ## Contributing
233
+
234
+ Contributions welcome. Please open an issue first to discuss what you'd like to change.
235
+
236
+ 1. Fork the repo
237
+ 2. Create a feature branch (`git checkout -b feature/new-check`)
238
+ 3. Add tests for new checks in `tests/`
239
+ 4. Submit a PR
240
+
241
+ ## Security
242
+
243
+ If you find a security vulnerability in ClawGuard itself, please report it privately via [GitHub Security Advisories](https://github.com/vman7250/clawguard/security/advisories/new) instead of opening a public issue.
244
+
245
+ ## License
246
+
247
+ [MIT](LICENSE)