@elliotllliu/agent-shield 0.3.1
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 +21 -0
- package/README.md +297 -0
- package/README.zh-CN.md +130 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +265 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +91 -0
- package/dist/config.js.map +1 -0
- package/dist/discover.d.ts +9 -0
- package/dist/discover.js +143 -0
- package/dist/discover.js.map +1 -0
- package/dist/llm/anthropic.d.ts +10 -0
- package/dist/llm/anthropic.js +67 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +41 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/ollama.d.ts +9 -0
- package/dist/llm/ollama.js +61 -0
- package/dist/llm/ollama.js.map +1 -0
- package/dist/llm/openai.d.ts +10 -0
- package/dist/llm/openai.js +66 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/prompt.d.ts +3 -0
- package/dist/llm/prompt.js +31 -0
- package/dist/llm/prompt.js.map +1 -0
- package/dist/llm/types.d.ts +23 -0
- package/dist/llm/types.js +3 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/llm-analyzer.d.ts +13 -0
- package/dist/llm-analyzer.js +169 -0
- package/dist/llm-analyzer.js.map +1 -0
- package/dist/reporter/badge.d.ts +7 -0
- package/dist/reporter/badge.js +50 -0
- package/dist/reporter/badge.js.map +1 -0
- package/dist/reporter/json.d.ts +3 -0
- package/dist/reporter/json.js +5 -0
- package/dist/reporter/json.js.map +1 -0
- package/dist/reporter/terminal.d.ts +2 -0
- package/dist/reporter/terminal.js +64 -0
- package/dist/reporter/terminal.js.map +1 -0
- package/dist/rules/backdoor.d.ts +2 -0
- package/dist/rules/backdoor.js +57 -0
- package/dist/rules/backdoor.js.map +1 -0
- package/dist/rules/credential-hardcode.d.ts +2 -0
- package/dist/rules/credential-hardcode.js +57 -0
- package/dist/rules/credential-hardcode.js.map +1 -0
- package/dist/rules/crypto-mining.d.ts +2 -0
- package/dist/rules/crypto-mining.js +41 -0
- package/dist/rules/crypto-mining.js.map +1 -0
- package/dist/rules/data-exfil.d.ts +2 -0
- package/dist/rules/data-exfil.js +61 -0
- package/dist/rules/data-exfil.js.map +1 -0
- package/dist/rules/env-leak.d.ts +2 -0
- package/dist/rules/env-leak.js +43 -0
- package/dist/rules/env-leak.js.map +1 -0
- package/dist/rules/excessive-perms.d.ts +2 -0
- package/dist/rules/excessive-perms.js +50 -0
- package/dist/rules/excessive-perms.js.map +1 -0
- package/dist/rules/hidden-files.d.ts +2 -0
- package/dist/rules/hidden-files.js +52 -0
- package/dist/rules/hidden-files.js.map +1 -0
- package/dist/rules/index.d.ts +5 -0
- package/dist/rules/index.js +53 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/mcp-manifest.d.ts +2 -0
- package/dist/rules/mcp-manifest.js +270 -0
- package/dist/rules/mcp-manifest.js.map +1 -0
- package/dist/rules/network-ssrf.d.ts +2 -0
- package/dist/rules/network-ssrf.js +51 -0
- package/dist/rules/network-ssrf.js.map +1 -0
- package/dist/rules/obfuscation.d.ts +2 -0
- package/dist/rules/obfuscation.js +51 -0
- package/dist/rules/obfuscation.js.map +1 -0
- package/dist/rules/phone-home.d.ts +2 -0
- package/dist/rules/phone-home.js +38 -0
- package/dist/rules/phone-home.js.map +1 -0
- package/dist/rules/privilege.d.ts +2 -0
- package/dist/rules/privilege.js +111 -0
- package/dist/rules/privilege.js.map +1 -0
- package/dist/rules/prompt-injection.d.ts +2 -0
- package/dist/rules/prompt-injection.js +323 -0
- package/dist/rules/prompt-injection.js.map +1 -0
- package/dist/rules/reverse-shell.d.ts +2 -0
- package/dist/rules/reverse-shell.js +53 -0
- package/dist/rules/reverse-shell.js.map +1 -0
- package/dist/rules/sensitive-read.d.ts +2 -0
- package/dist/rules/sensitive-read.js +53 -0
- package/dist/rules/sensitive-read.js.map +1 -0
- package/dist/rules/skill-risks.d.ts +2 -0
- package/dist/rules/skill-risks.js +148 -0
- package/dist/rules/skill-risks.js.map +1 -0
- package/dist/rules/supply-chain.d.ts +6 -0
- package/dist/rules/supply-chain.js +105 -0
- package/dist/rules/supply-chain.js.map +1 -0
- package/dist/rules/tool-shadowing.d.ts +2 -0
- package/dist/rules/tool-shadowing.js +129 -0
- package/dist/rules/tool-shadowing.js.map +1 -0
- package/dist/rules/toxic-flow.d.ts +2 -0
- package/dist/rules/toxic-flow.js +160 -0
- package/dist/rules/toxic-flow.js.map +1 -0
- package/dist/rules/typosquatting.d.ts +2 -0
- package/dist/rules/typosquatting.js +56 -0
- package/dist/rules/typosquatting.js.map +1 -0
- package/dist/scanner/files.d.ts +5 -0
- package/dist/scanner/files.js +105 -0
- package/dist/scanner/files.js.map +1 -0
- package/dist/scanner/index.d.ts +6 -0
- package/dist/scanner/index.js +198 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/score.d.ts +14 -0
- package/dist/score.js +35 -0
- package/dist/score.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/yaml-simple.d.ts +6 -0
- package/dist/yaml-simple.js +98 -0
- package/dist/yaml-simple.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Elliot Liu
|
|
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,297 @@
|
|
|
1
|
+
# 🛡️ AgentShield
|
|
2
|
+
|
|
3
|
+
**Security scanner for AI agent skills, MCP servers, and plugins.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@elliotllliu/agentshield)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
Catch data exfiltration, backdoors, privilege escalation, credential leaks, and supply chain vulnerabilities **before** they reach your AI agents.
|
|
9
|
+
|
|
10
|
+
**Offline-first. Open source. Your data never leaves your machine.**
|
|
11
|
+
|
|
12
|
+
> 💡 **vs Snyk Agent Scan:** AgentShield runs 100% locally with no API keys required. Add `--ai` for LLM-powered deep analysis using your own API key — no vendor lock-in, no rate limits.
|
|
13
|
+
|
|
14
|
+
## Why AgentShield?
|
|
15
|
+
|
|
16
|
+
AI agents install and execute third-party skills, MCP servers, and plugins with minimal security review. A single malicious skill can:
|
|
17
|
+
|
|
18
|
+
- 🔑 **Steal credentials** — SSH keys, AWS secrets, API tokens
|
|
19
|
+
- 📤 **Exfiltrate data** — read sensitive files and send them to external servers
|
|
20
|
+
- 💀 **Open backdoors** — `eval()`, reverse shells, dynamic code execution
|
|
21
|
+
- ⛏️ **Mine crypto** — hijack compute for cryptocurrency mining
|
|
22
|
+
- 🕵️ **Bypass permissions** — claim "read-only" but execute shell commands
|
|
23
|
+
|
|
24
|
+
AgentShield catches these patterns with **20 security rules** in under 50ms. Add `--ai` for LLM-powered deep analysis.
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Static analysis (20 rules, offline, ~50ms)
|
|
30
|
+
npx @elliotllliu/agentshield scan ./my-skill/
|
|
31
|
+
|
|
32
|
+
# AI-powered deep analysis
|
|
33
|
+
npx @elliotllliu/agentshield scan ./skill/ --ai --provider openai --model gpt-4o
|
|
34
|
+
npx @elliotllliu/agentshield scan ./skill/ --ai --provider ollama --model llama3
|
|
35
|
+
|
|
36
|
+
# Discover installed agents on your machine
|
|
37
|
+
npx @elliotllliu/agentshield discover
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## What It Detects — 18 Security Rules
|
|
41
|
+
|
|
42
|
+
### 🔴 Critical (auto-fail)
|
|
43
|
+
|
|
44
|
+
| Rule | Detects |
|
|
45
|
+
|------|---------|
|
|
46
|
+
| `data-exfil` | Reads sensitive files + sends HTTP requests (exfiltration pattern) |
|
|
47
|
+
| `backdoor` | `eval()`, `new Function()`, `child_process.exec()` with dynamic input |
|
|
48
|
+
| `reverse-shell` | Outbound socket connections piped to `/bin/sh` |
|
|
49
|
+
| `crypto-mining` | Mining pool connections, xmrig, coinhive patterns |
|
|
50
|
+
| `credential-hardcode` | Hardcoded AWS keys (`AKIA...`), GitHub PATs (`ghp_...`), Stripe keys |
|
|
51
|
+
| `env-leak` | `process.env` secrets + outbound HTTP (environment variable theft) |
|
|
52
|
+
| `obfuscation` | `eval(atob(...))`, hex strings, `String.fromCharCode` obfuscation |
|
|
53
|
+
| `typosquatting` | Suspicious npm names: `1odash` → `lodash`, `axois` → `axios` |
|
|
54
|
+
| `hidden-files` | `.env` files with `PASSWORD`, `SECRET`, `API_KEY` committed to repo |
|
|
55
|
+
| `prompt-injection` | Hidden instructions, identity manipulation, behavioral hijacking, TPA, multi-lang |
|
|
56
|
+
| `tool-shadowing` | Cross-server tool name conflicts, tool override attacks |
|
|
57
|
+
|
|
58
|
+
### 🟡 Warning (review recommended)
|
|
59
|
+
|
|
60
|
+
| Rule | Detects |
|
|
61
|
+
|------|---------|
|
|
62
|
+
| `network-ssrf` | User-controlled URLs in fetch, AWS metadata endpoint access |
|
|
63
|
+
| `privilege` | SKILL.md permissions vs actual code behavior mismatch |
|
|
64
|
+
| `supply-chain` | Known CVEs in npm dependencies (`npm audit`) |
|
|
65
|
+
| `sensitive-read` | Access to `~/.ssh/id_rsa`, `~/.aws/credentials`, `~/.kube/config` |
|
|
66
|
+
| `excessive-perms` | Too many or dangerous permissions in SKILL.md |
|
|
67
|
+
| `phone-home` | `setInterval` + HTTP requests (beacon/C2 heartbeat pattern) |
|
|
68
|
+
| `mcp-manifest` | MCP server: wildcard perms, undeclared capabilities, suspicious tool descriptions |
|
|
69
|
+
| `skill-risks` | Financial ops, untrusted content, external deps, system modification, credential handling |
|
|
70
|
+
| `toxic-flow` | Cross-tool data leak flows (TF001) and destructive flows (TF002) |
|
|
71
|
+
|
|
72
|
+
### 🎯 Prompt Injection Detection — 55+ Patterns
|
|
73
|
+
|
|
74
|
+
Based on research from [Invariant Labs TPA](https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks), [BIPIA (KDD 2025)](https://arxiv.org/abs/2312.14197), and [Snyk Agent Scan](https://github.com/snyk/agent-scan):
|
|
75
|
+
|
|
76
|
+
| Category | Examples |
|
|
77
|
+
|----------|----------|
|
|
78
|
+
| **Instruction Override** | "ignore previous instructions", multi-language (中/西/法/德) |
|
|
79
|
+
| **Identity Manipulation** | "you are now a...", DAN mode, developer mode jailbreaks |
|
|
80
|
+
| **System Prompt Extraction** | `<system>` tags, ChatML `<\|im_start\|>`, `[INST]` delimiters |
|
|
81
|
+
| **Hidden Instructions** | `<IMPORTANT>` TPA tags, HTML comments, zero-width chars, CSS hiding |
|
|
82
|
+
| **Concealment** | "don't tell the user", "be gentle and not scary" |
|
|
83
|
+
| **Tool Poisoning (TPA)** | "read ~/.ssh/id_rsa and pass as sidenote", Python docstring attacks |
|
|
84
|
+
| **Data Exfiltration** | Markdown image exfil, webhook.site, ngrok tunnels, dotfile access |
|
|
85
|
+
| **Encoding Evasion** | Base64-encoded keywords, hex chains, unicode escapes |
|
|
86
|
+
|
|
87
|
+
## Real-World Scan Data
|
|
88
|
+
|
|
89
|
+
We scanned the **top 9 ClawHub skill repositories** (700K+ combined installs). Most findings are **false positives from legitimate code** (deploy scripts, API integrations), but they demonstrate patterns that malicious skills could replicate:
|
|
90
|
+
|
|
91
|
+
| Repository | Installs | Score | Assessment |
|
|
92
|
+
|------------|----------|-------|------------|
|
|
93
|
+
| vercel-labs/agent-skills | 157K | 40 | ✅ False positives — deploy scripts use `curl` legitimately |
|
|
94
|
+
| obra/superpowers | 94K | 45 | ⚠️ Test code + render exec() |
|
|
95
|
+
| coreyhaines31/marketingskills | 42K | 0 | ⚠️ 100+ API wrapper tools (legitimate credential access) |
|
|
96
|
+
| expo/skills | 11K | 30 | ⚠️ CI script reads env (FP detected) |
|
|
97
|
+
| anthropics/skills | 36K | 35 | ⚠️ Template contains exec() |
|
|
98
|
+
| google-labs-code/stitch-skills | 63K | 100 | ✅ Clean |
|
|
99
|
+
| supercent-io/skills-template | 106K | 100 | ✅ Clean |
|
|
100
|
+
|
|
101
|
+
**Key insight:** Legitimate deploy scripts and API integrations produce the same code patterns as malicious data exfiltration. This is why manual review is essential — AgentShield flags patterns for review, not verdicts.
|
|
102
|
+
|
|
103
|
+
[📊 Full analysis with detailed assessment →](docs/clawhub-security-report.md)
|
|
104
|
+
|
|
105
|
+
## Example Output
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
🛡️ AgentShield Security Report
|
|
109
|
+
📁 Scanned: ./my-skill/ (3 files, 44 lines)
|
|
110
|
+
|
|
111
|
+
🔴 CRITICAL (3)
|
|
112
|
+
├─ index.ts:13 — [data-exfil] Reads sensitive data and sends HTTP request
|
|
113
|
+
├─ index.ts:20 — [backdoor] eval() with dynamic input
|
|
114
|
+
└─ backdoor.sh:6 — [backdoor] shell eval with variable
|
|
115
|
+
|
|
116
|
+
🟡 WARNING (2)
|
|
117
|
+
├─ index.ts:23 — [privilege] Code uses 'exec' but SKILL.md doesn't declare it
|
|
118
|
+
└─ index.ts:6 — [sensitive-read] Accesses SSH private key
|
|
119
|
+
|
|
120
|
+
✅ Score: 0/100 (Critical Risk)
|
|
121
|
+
⏱ 16ms
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Usage
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Scan a directory
|
|
128
|
+
npx @elliotllliu/agentshield scan ./path/to/skill/
|
|
129
|
+
|
|
130
|
+
# AI-powered deep analysis (uses your own API key)
|
|
131
|
+
npx @elliotllliu/agentshield scan ./skill/ --ai --provider openai --model gpt-4o
|
|
132
|
+
npx @elliotllliu/agentshield scan ./skill/ --ai --provider anthropic
|
|
133
|
+
npx @elliotllliu/agentshield scan ./skill/ --ai --provider ollama --model llama3
|
|
134
|
+
|
|
135
|
+
# Discover installed agents on your machine
|
|
136
|
+
npx @elliotllliu/agentshield discover
|
|
137
|
+
|
|
138
|
+
# JSON output (for CI/CD pipelines)
|
|
139
|
+
npx @elliotllliu/agentshield scan ./skill/ --json
|
|
140
|
+
|
|
141
|
+
# Fail CI if score drops below threshold
|
|
142
|
+
npx @elliotllliu/agentshield scan ./skill/ --fail-under 70
|
|
143
|
+
|
|
144
|
+
# Disable specific rules
|
|
145
|
+
npx @elliotllliu/agentshield scan ./skill/ --disable supply-chain,phone-home
|
|
146
|
+
|
|
147
|
+
# Only run specific rules
|
|
148
|
+
npx @elliotllliu/agentshield scan ./skill/ --enable backdoor,data-exfil
|
|
149
|
+
|
|
150
|
+
# Generate config files
|
|
151
|
+
npx @elliotllliu/agentshield init
|
|
152
|
+
|
|
153
|
+
# Watch mode — re-scan on file changes
|
|
154
|
+
npx @elliotllliu/agentshield watch ./skill/
|
|
155
|
+
|
|
156
|
+
# Compare two versions
|
|
157
|
+
npx @elliotllliu/agentshield compare ./skill-v1/ ./skill-v2/
|
|
158
|
+
|
|
159
|
+
# Generate a security badge for your README
|
|
160
|
+
npx @elliotllliu/agentshield badge ./skill/
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## CI Integration
|
|
164
|
+
|
|
165
|
+
### GitHub Action (recommended)
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
# .github/workflows/security.yml
|
|
169
|
+
name: Security Scan
|
|
170
|
+
on: [push, pull_request]
|
|
171
|
+
jobs:
|
|
172
|
+
scan:
|
|
173
|
+
runs-on: ubuntu-latest
|
|
174
|
+
steps:
|
|
175
|
+
- uses: actions/checkout@v4
|
|
176
|
+
- uses: elliotllliu/agentshield@main
|
|
177
|
+
with:
|
|
178
|
+
path: './skills/'
|
|
179
|
+
fail-under: '70'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### npx one-liner
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
- name: Security scan
|
|
186
|
+
run: npx -y @elliotllliu/agentshield scan ./skills/ --fail-under 70
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Action Inputs & Outputs
|
|
190
|
+
|
|
191
|
+
| Input | Default | Description |
|
|
192
|
+
|-------|---------|-------------|
|
|
193
|
+
| `path` | `.` | Directory to scan |
|
|
194
|
+
| `fail-under` | — | Fail if score < threshold (0-100) |
|
|
195
|
+
| `format` | `terminal` | `terminal` or `json` |
|
|
196
|
+
|
|
197
|
+
| Output | Description |
|
|
198
|
+
|--------|-------------|
|
|
199
|
+
| `score` | Security score (0-100) |
|
|
200
|
+
| `findings` | Number of findings |
|
|
201
|
+
|
|
202
|
+
## Configuration
|
|
203
|
+
|
|
204
|
+
Create `.agentshield.yml` (or run `agentshield init`):
|
|
205
|
+
|
|
206
|
+
```yaml
|
|
207
|
+
rules:
|
|
208
|
+
disable:
|
|
209
|
+
- supply-chain # skip npm audit
|
|
210
|
+
- phone-home # allow periodic HTTP
|
|
211
|
+
|
|
212
|
+
severity:
|
|
213
|
+
sensitive-read: info # downgrade to info
|
|
214
|
+
|
|
215
|
+
failUnder: 70 # CI threshold
|
|
216
|
+
|
|
217
|
+
ignore:
|
|
218
|
+
- "tests/**"
|
|
219
|
+
- "*.test.ts"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### `.agentshieldignore`
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
node_modules/
|
|
226
|
+
dist/
|
|
227
|
+
*.test.ts
|
|
228
|
+
__tests__/
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Scoring
|
|
232
|
+
|
|
233
|
+
| Severity | Points Deducted |
|
|
234
|
+
|----------|----------------|
|
|
235
|
+
| 🔴 Critical | -25 |
|
|
236
|
+
| 🟡 Warning | -10 |
|
|
237
|
+
| 🟢 Info | 0 |
|
|
238
|
+
|
|
239
|
+
| Score | Risk Level | Recommendation |
|
|
240
|
+
|-------|------------|----------------|
|
|
241
|
+
| 90-100 | ✅ Low Risk | Safe to install |
|
|
242
|
+
| 70-89 | 🟡 Moderate | Review warnings |
|
|
243
|
+
| 40-69 | 🟠 High Risk | Investigate before using |
|
|
244
|
+
| 0-39 | 🔴 Critical | Do not install |
|
|
245
|
+
|
|
246
|
+
## Supported Platforms
|
|
247
|
+
|
|
248
|
+
- **AI Agent Skills** — OpenClaw, Codex, Claude Code
|
|
249
|
+
- **MCP Servers** — Model Context Protocol tool servers
|
|
250
|
+
- **npm Packages** — any npm package with executable code
|
|
251
|
+
- **General** — any directory with JS/TS/Python/Shell code
|
|
252
|
+
|
|
253
|
+
### Supported File Types
|
|
254
|
+
|
|
255
|
+
| Language | Extensions |
|
|
256
|
+
|----------|-----------|
|
|
257
|
+
| JavaScript/TypeScript | `.js`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.jsx` |
|
|
258
|
+
| Python | `.py` |
|
|
259
|
+
| Shell | `.sh`, `.bash`, `.zsh` |
|
|
260
|
+
| Config | `.json`, `.yaml`, `.yml`, `.toml` |
|
|
261
|
+
| Docs | `SKILL.md` (permission analysis) |
|
|
262
|
+
|
|
263
|
+
## Comparison with Other Tools
|
|
264
|
+
|
|
265
|
+
| Feature | AgentShield | Snyk Agent Scan | npm audit | ESLint Security |
|
|
266
|
+
|---------|------------|-----------------|-----------|-----------------|
|
|
267
|
+
| AI skill/MCP specific rules | ✅ 20 rules | ✅ 15+ rules | ❌ | ❌ |
|
|
268
|
+
| Prompt injection detection | ✅ regex + AI | ✅ LLM (cloud) | ❌ | ❌ |
|
|
269
|
+
| Tool poisoning/shadowing | ✅ | ✅ | ❌ | ❌ |
|
|
270
|
+
| Agent auto-discovery | ✅ 10 agents | ✅ | ❌ | ❌ |
|
|
271
|
+
| AI-powered analysis | ✅ `--ai` (your key) | ✅ (Snyk cloud) | ❌ | ❌ |
|
|
272
|
+
| Data exfiltration detection | ✅ | ✅ | ❌ | ❌ |
|
|
273
|
+
| Permission mismatch (SKILL.md) | ✅ | ❌ | ❌ | ❌ |
|
|
274
|
+
| Zero config / no account | ✅ | ❌ needs Snyk token | ✅ | ❌ |
|
|
275
|
+
| 100% offline capable | ✅ | ❌ cloud required | ✅ | ✅ |
|
|
276
|
+
| `npx` zero-install | ✅ | ❌ needs Python+uv | ✅ | ❌ |
|
|
277
|
+
| GitHub Action | ✅ | ❌ | ❌ | ❌ |
|
|
278
|
+
| Web UI | ✅ | ❌ | ❌ | ❌ |
|
|
279
|
+
| Choose your own LLM | ✅ OpenAI/Anthropic/Ollama | ❌ Snyk backend | ❌ | ❌ |
|
|
280
|
+
| False positive detection | ✅ context-aware | ❌ | ❌ | ❌ |
|
|
281
|
+
| No rate limits | ✅ | ❌ daily quota | ✅ | ✅ |
|
|
282
|
+
| Open source analysis | ✅ fully open | ❌ black box | ✅ | ✅ |
|
|
283
|
+
|
|
284
|
+
## Contributing
|
|
285
|
+
|
|
286
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to add new rules.
|
|
287
|
+
|
|
288
|
+
## Links
|
|
289
|
+
|
|
290
|
+
- 📦 [npm](https://www.npmjs.com/package/@elliotllliu/agentshield)
|
|
291
|
+
- 📖 [Rule Documentation](docs/rules.md)
|
|
292
|
+
- 📊 [ClawHub Security Report](docs/clawhub-security-report.md)
|
|
293
|
+
- 🇨🇳 [中文 README](README.zh-CN.md)
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# 🛡️ AgentShield — AI Agent 安全扫描器
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@elliotllliu/agentshield)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
专为 AI Agent 技能、MCP Server、插件设计的安全扫描工具。在安装第三方扩展之前,检测数据窃取、后门、凭证泄露和供应链漏洞。
|
|
7
|
+
|
|
8
|
+
> **我们扫描了 ClawHub 热门 skill 仓库 — 平均安全分仅 47/100。** [查看完整报告 →](docs/clawhub-security-report.md)
|
|
9
|
+
|
|
10
|
+
## 为什么需要 AgentShield?
|
|
11
|
+
|
|
12
|
+
AI Agent 会安装并执行第三方技能和插件,安全审查几乎为零。一个恶意 skill 就能:
|
|
13
|
+
|
|
14
|
+
- 🔑 **偷凭证** — SSH 密钥、AWS Secret、API Token
|
|
15
|
+
- 📤 **外泄数据** — 读取敏感文件发送到外部服务器
|
|
16
|
+
- 💀 **植入后门** — eval()、反弹 Shell、动态代码执行
|
|
17
|
+
- ⛏️ **挖矿** — 利用你的算力挖加密货币
|
|
18
|
+
- 🕵️ **越权** — 声称只读但实际执行 Shell 命令
|
|
19
|
+
|
|
20
|
+
AgentShield 用 **16 条安全规则**在 50ms 内检出这些威胁。
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx @elliotllliu/agentshield scan ./my-skill/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
无需安装,Node.js 18+ 即可运行。
|
|
29
|
+
|
|
30
|
+
## 16 条安全规则
|
|
31
|
+
|
|
32
|
+
### 🔴 严重(自动判定不安全)
|
|
33
|
+
|
|
34
|
+
| 规则 | 检测内容 |
|
|
35
|
+
|------|----------|
|
|
36
|
+
| `data-exfil` | 读敏感文件 + 发 HTTP 请求(数据外泄模式) |
|
|
37
|
+
| `backdoor` | `eval()`、`exec()`、动态代码执行 |
|
|
38
|
+
| `reverse-shell` | Socket 外连 + Shell 管道 |
|
|
39
|
+
| `crypto-mining` | 矿池连接、xmrig、coinhive |
|
|
40
|
+
| `credential-hardcode` | 硬编码 AWS Key、GitHub PAT、Stripe Key |
|
|
41
|
+
| `env-leak` | 环境变量 + HTTP 外发 |
|
|
42
|
+
| `obfuscation` | base64+eval、十六进制混淆 |
|
|
43
|
+
| `typosquatting` | npm 包名仿冒(`1odash` → `lodash`) |
|
|
44
|
+
| `hidden-files` | `.env` 明文密钥 |
|
|
45
|
+
|
|
46
|
+
### 🟡 警告(建议审查)
|
|
47
|
+
|
|
48
|
+
| 规则 | 检测内容 |
|
|
49
|
+
|------|----------|
|
|
50
|
+
| `network-ssrf` | 用户可控 URL、SSRF |
|
|
51
|
+
| `privilege` | SKILL.md 声明 vs 代码实际行为不匹配 |
|
|
52
|
+
| `supply-chain` | npm 依赖已知 CVE |
|
|
53
|
+
| `sensitive-read` | 读取 SSH 密钥、AWS 凭证 |
|
|
54
|
+
| `excessive-perms` | 权限声明过多 |
|
|
55
|
+
| `phone-home` | 定时器 + HTTP 心跳 |
|
|
56
|
+
| `mcp-manifest` | MCP Server 通配权限、可疑工具描述 |
|
|
57
|
+
|
|
58
|
+
## 真实扫描数据
|
|
59
|
+
|
|
60
|
+
我们扫了 ClawHub **Top 9 热门 skill 仓库**(总安装量 70 万+):
|
|
61
|
+
|
|
62
|
+
| 仓库 | 安装量 | 分数 | 风险 |
|
|
63
|
+
|------|--------|------|------|
|
|
64
|
+
| vercel-labs/agent-skills | 157K | 40 | ✅ deploy 脚本误报已自动标注 |
|
|
65
|
+
| obra/superpowers | 94K | 45 | ⚠️ 测试代码 + 渲染脚本 exec() |
|
|
66
|
+
| coreyhaines31/marketingskills | 42K | 0 | ⚠️ 122 个 critical(CRM 凭证模式) |
|
|
67
|
+
| anthropics/skills | 36K | 35 | ⚠️ 模板有 exec() |
|
|
68
|
+
| expo/skills | 11K | 30 | ⚠️ CI 脚本读 env(FP 已标注) |
|
|
69
|
+
| google-labs-code/stitch-skills | 63K | 100 | ✅ 干净 |
|
|
70
|
+
| supercent-io/skills-template | 106K | 100 | ✅ 干净 |
|
|
71
|
+
|
|
72
|
+
**平均分:59/100** — AgentShield v0.2.1 智能识别 test/deploy 文件,减少误报。
|
|
73
|
+
|
|
74
|
+
## 使用方法
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# 扫描目录
|
|
78
|
+
npx @elliotllliu/agentshield scan ./skill/
|
|
79
|
+
|
|
80
|
+
# JSON 输出
|
|
81
|
+
npx @elliotllliu/agentshield scan ./skill/ --json
|
|
82
|
+
|
|
83
|
+
# CI 门禁
|
|
84
|
+
npx @elliotllliu/agentshield scan ./skill/ --fail-under 70
|
|
85
|
+
|
|
86
|
+
# 禁用特定规则
|
|
87
|
+
npx @elliotllliu/agentshield scan ./skill/ --disable supply-chain
|
|
88
|
+
|
|
89
|
+
# 初始化配置
|
|
90
|
+
npx @elliotllliu/agentshield init
|
|
91
|
+
|
|
92
|
+
# 实时监控
|
|
93
|
+
npx @elliotllliu/agentshield watch ./skill/
|
|
94
|
+
|
|
95
|
+
# 版本对比
|
|
96
|
+
npx @elliotllliu/agentshield compare ./v1/ ./v2/
|
|
97
|
+
|
|
98
|
+
# 生成安全徽章
|
|
99
|
+
npx @elliotllliu/agentshield badge ./skill/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## GitHub Actions 集成
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
- uses: elliotllliu/agentshield@main
|
|
106
|
+
with:
|
|
107
|
+
path: './skills/'
|
|
108
|
+
fail-under: '70'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 与其他工具对比
|
|
112
|
+
|
|
113
|
+
| 功能 | AgentShield | npm audit | Snyk | ESLint |
|
|
114
|
+
|------|------------|-----------|------|--------|
|
|
115
|
+
| AI Skill/MCP 专用规则 | ✅ | ❌ | ❌ | ❌ |
|
|
116
|
+
| 数据外泄检测 | ✅ | ❌ | ❌ | ❌ |
|
|
117
|
+
| 权限不匹配检测 | ✅ | ❌ | ❌ | ❌ |
|
|
118
|
+
| 零配置 | ✅ | ✅ | ❌ | ❌ |
|
|
119
|
+
| < 50ms 扫描 | ✅ | ❌ | ❌ | ❌ |
|
|
120
|
+
|
|
121
|
+
## 链接
|
|
122
|
+
|
|
123
|
+
- 📦 [npm](https://www.npmjs.com/package/@elliotllliu/agentshield)
|
|
124
|
+
- 📖 [规则文档](docs/rules.md)
|
|
125
|
+
- 📊 [ClawHub 安全报告](docs/clawhub-security-report.md)
|
|
126
|
+
- 🇬🇧 [English README](README.md)
|
|
127
|
+
|
|
128
|
+
## 许可证
|
|
129
|
+
|
|
130
|
+
MIT
|
package/dist/cli.d.ts
ADDED