11# ShellWard
22
3- ** 你的 AI Agent 正在"裸奔"—— 身份证号、手机号、银行卡号明文跑在对话里。 **
3+ ** AI Agent Security Middleware ** — 保护 AI 代理免受提示词注入、数据泄露、危险工具执行。
44
5- 唯一支持中国敏感数据保护的 OpenClaw 安全插件 — 8 层纵深防御,中文注入检测,零依赖,一行命令安装 。
5+ 唯一支持中国敏感数据保护的 AI 安全层 — 8 层纵深防御,中文注入检测,零依赖。支持 ** OpenClaw 插件 ** 与 ** 独立 SDK ** 两种形态 。
66
77[ ![ npm] ( https://img.shields.io/npm/v/shellward?color=cb0000&label=npm )] ( https://www.npmjs.com/package/shellward )
88[ ![ license] ( https://img.shields.io/badge/license-Apache--2.0-blue )] ( ./LICENSE )
9- [ ![ tests] ( https://img.shields.io/badge/tests-100 %20passing-brightgreen )] ( #性能 )
9+ [ ![ tests] ( https://img.shields.io/badge/tests-112 %20passing-brightgreen )] ( #性能 )
1010[ ![ deps] ( https://img.shields.io/badge/dependencies-0-brightgreen )] ( #性能 )
1111
1212[ 中文] ( #演示 ) | [ English] ( #english )
1313
1414### 演示
1515
16- ![ ShellWard 安全防护演示] ( https://github.com/jnMetaCode/shellward/releases/download/v0.4 .0/demo-zh.gif )
16+ ![ ShellWard 安全防护演示] ( https://github.com/jnMetaCode/shellward/releases/download/v0.5 .0/demo-zh.gif )
1717
18- > 5 个真实攻击场景:危险命令拦截 → 中文注入检测 → 身份证/手机/银行卡自动隐藏 → 数据外泄链阻断 → 正常操作放行
18+ > 7 个真实攻击场景:服务器毁灭拦截 → 反弹 Shell 阻断 → 注入检测 → DLP 审计 → 数据外泄链拦截 → 凭证窃取防护 → APT 攻击链还原
1919
2020### 你的 AI Agent 正在"裸奔"
2121
3636✅ 有 ShellWard:
3737
3838 Agent 读取客户文件...
39- 工具输出: "客户张三,身份证号[REDACTED:身份证号],手机[REDACTED:手机号] ,
40- 银行卡[REDACTED:银行卡号] "
41- → 敏感信息在进入对话之前就被脱敏
42- → LLM 永远看不到真实数据
43- → 日志中只有脱敏后的安全内容
39+ 工具输出: "客户张三,身份证号330102199001011234,手机13812345678 ,
40+ 银行卡6225880137654321 "
41+ → L2 检测并记录审计日志(数据正常返回,供 AI 分析使用)
42+ → L7 拦截:若 AI 试图将数据外发(send_email、http_request 发 body)→ 阻断
43+ → 内部使用不受影响,外泄边界被守住
4444```
4545
46+ ** v0.5 保护模型** :内部使用允许(用户需要完整数据做分析),外部发送拦截(L7 数据流监控)。PII 仅审计不脱敏,避免误伤正常业务。
47+
48+ > 💡 ** 核心理念:像企业防火墙一样,内部随便用,数据出不去。**
49+
50+ ### 支持平台
51+
52+ | 平台 | 集成方式 | 说明 |
53+ | ------| ---------| ------|
54+ | ** OpenClaw** | 插件一键安装 | ` openclaw plugins install shellward ` ,开箱即用 |
55+ | ** Claude Code** | SDK 集成 | Anthropic 官方 CLI Agent |
56+ | ** Cursor** | SDK 集成 | AI 编程 IDE |
57+ | ** LangChain** | SDK 集成 | LLM 应用开发框架 |
58+ | ** AutoGPT** | SDK 集成 | 自主 AI Agent |
59+ | ** OpenAI Agents** | SDK 集成 | GPT Agent 平台 |
60+ | ** Dify / Coze** | SDK 集成 | 低代码 AI 平台 |
61+ | ** 任意 AI Agent** | SDK 集成 | ` npm install shellward ` ,3 行代码接入 |
62+
4663### 为什么现有方案不够?
4764
4865| | ShellWard | SecureClaw | ClawSec | openclaw-shield |
6380** 身份证号** — 不是简单的 18 位数字匹配,带校验位验证:
6481
6582```
66- 330102199001011234 → [REDACTED:身份证号] ✅ 真实身份证号,校验位正确
67- 110101199003070419 → [REDACTED:身份证号] ✅ 真实格式,脱敏
68- 123456789012345678 → 123456789012345678 ✅ 随机数字,不误报
83+ 330102199001011234 → 检测到,审计记录 ✅ 真实身份证号,校验位正确
84+ 110101199003070419 → 检测到,审计记录 ✅ 真实格式
85+ 123456789012345678 → 不误报 ✅ 随机数字,校验位错误
6986```
7087
7188** 手机号** — 覆盖所有运营商号段:
7289
7390```
74- 13812345678 → [REDACTED:手机号] ✅ 中国移动
75- 15912345678 → [REDACTED:手机号] ✅ 中国电信
76- 12345678901 → 12345678901 ✅ 非手机号段,不误报
91+ 13812345678 → 检测到,审计记录 ✅ 中国移动
92+ 15912345678 → 检测到,审计记录 ✅ 中国电信
93+ 12345678901 → 不误报 ✅ 非手机号段
7794```
7895
7996** 银行卡号** — Luhn 算法验证,不是长度匹配:
8097
8198```
82- 6225880137654321 → [REDACTED:银行卡号] ✅ Luhn 校验通过
83- 1234567890123456 → 1234567890123456 ✅ Luhn 校验失败,不误报
99+ 6225880137654321 → 检测到,审计记录 ✅ Luhn 校验通过
100+ 1234567890123456 → 不误报 ✅ Luhn 校验失败
84101```
85102
86103** API Key / JWT / 密码** — 国际通用格式全覆盖:
87104
88105```
89- sk-abc123def456ghi789... → [REDACTED:OpenAI Key]
90- ghp_xxxxxxxxxxxxxxxxxxxx → [REDACTED:GitHub Token]
91- eyJhbGciOiJIUzI1NiIs... → [REDACTED:JWT Token]
92- password: "MyP@ssw0rd!" → password: "[REDACTED:密码]"
106+ sk-abc123def456ghi789... → 检测到,审计记录
107+ ghp_xxxxxxxxxxxxxxxxxxxx → 检测到,审计记录
108+ eyJhbGciOiJIUzI1NiIs... → 检测到,审计记录
109+ password: "MyP@ssw0rd!" → 检测到,审计记录
93110```
94111
95112** 中文注入攻击检测:**
@@ -105,7 +122,7 @@ password: "MyP@ssw0rd!" → password: "[REDACTED:密码]"
105122
106123```
107124Step 1: Agent 读取 ~/.ssh/id_rsa ← L7 记录敏感文件访问
108- Step 2: Agent 调用 curl 发送到外部地址 ← L7 检测到外泄链,拦截 🚫
125+ Step 2: Agent 调用 send_email 发送到外部 ← L7 检测到外泄链,拦截 🚫
109126```
110127
111128每一步单独看都是合法操作,连起来就是攻击。ShellWard 是唯一能检测这种链式攻击的插件。
@@ -133,8 +150,8 @@ Step 2: Agent 调用 curl 发送到外部地址 ← L7 检测到外泄链
133150 │
134151 ▼
135152┌──────────────┐
136- │ L2 输出脱敏 │ 身份证/手机/银行卡/API Key 自动脱敏
137- │ L6 回复脱敏 │ LLM 回复中的敏感信息也脱掉
153+ │ L2 输出审计 │ 身份证/手机/银行卡/API Key 检测并记录审计
154+ │ L6 回复审计 │ LLM 回复中的敏感信息检测并记录审计
138155└──────────────┘
139156 │
140157 ▼
@@ -146,13 +163,13 @@ Step 2: Agent 调用 curl 发送到外部地址 ← L7 检测到外泄链
146163
147164### 安装
148165
149- 一行命令:
166+ ** OpenClaw 插件 **
150167
151168``` bash
152169openclaw plugins install shellward
153170```
154171
155- 或者一键脚本 :
172+ 或一键脚本 :
156173
157174``` bash
158175# Linux / macOS
@@ -164,6 +181,21 @@ curl -fsSL https://raw.githubusercontent.com/jnMetaCode/shellward/main/install.s
164181irm https://raw.githubusercontent.com/jnMetaCode/shellward/main/install.ps1 | iex
165182```
166183
184+ ** 独立 SDK(任意 AI Agent 平台)**
185+
186+ ``` bash
187+ npm install shellward
188+ ```
189+
190+ ``` typescript
191+ import { ShellWard } from ' shellward'
192+ const guard = new ShellWard ({ mode: ' enforce' , locale: ' zh' })
193+
194+ guard .checkCommand (' rm -rf /' ) // → { allowed: false, reason: '...' }
195+ guard .scanData (' 身份证: 110101...' ) // → { hasSensitiveData: true, findings: [...] }
196+ guard .checkInjection (' 忽略指令...' ) // → { safe: false, score: 85 }
197+ ```
198+
167199安装即生效,零配置,默认 8 层全开。
168200
169201### 配置(可选)
@@ -187,7 +219,7 @@ irm https://raw.githubusercontent.com/jnMetaCode/shellward/main/install.ps1 | ie
187219| 命令 | 说明 |
188220| ------| ------|
189221| ` /security ` | 安全状态总览 |
190- | ` /audit [数量] [过滤] ` | 查看审计日志。过滤: ` block ` 、` redact ` 、` critical ` 、` high ` |
222+ | ` /audit [数量] [过滤] ` | 查看审计日志。过滤: ` block ` 、` audit ` 、` critical ` 、` high ` |
191223| ` /harden ` | 扫描安全问题,` /harden fix ` 自动修复权限 |
192224| ` /scan-plugins ` | 扫描已安装插件的恶意代码 |
193225| ` /check-updates ` | 检查版本更新和已知漏洞(内置 17 个真实 CVE) |
@@ -196,11 +228,11 @@ irm https://raw.githubusercontent.com/jnMetaCode/shellward/main/install.ps1 | ie
196228
197229| 指标 | 数据 |
198230| ------| ------|
199- | 200KB 文本 PII 脱敏 | 55ms |
231+ | 200KB 文本 PII 检测 | <100ms |
200232| 工具安全检查吞吐 | 125,000 次/秒 |
201233| 注入检测吞吐 | ~ 7,700 次/秒 |
202234| 依赖数量 | 0 |
203- | 测试 | 100 项全通过 |
235+ | 测试 | 112 项全通过 |
204236
205237### 已知漏洞数据库
206238
@@ -225,15 +257,30 @@ Apache-2.0
225257
226258## English
227259
228- The only OpenClaw security plugin with ** bilingual (EN/ZH) support** — Chinese PII detection (ID card with checksum, phone, bank card with Luhn), 8 defense layers, 26 injection rules, zero dependencies.
260+ The only AI security layer with ** bilingual (EN/ZH) support** — Chinese PII detection (ID card with checksum, phone, bank card with Luhn), 8 defense layers, 26 injection rules, zero dependencies. ** SDK + OpenClaw plugin. **
229261
230- ![ ShellWard Security Demo] ( https://github.com/jnMetaCode/shellward/releases/download/v0.4.0/demo-openclaw.gif )
262+ ![ ShellWard Security Demo] ( https://github.com/jnMetaCode/shellward/releases/download/v0.5.0/demo-en.gif )
263+
264+ > 💡 ** Like a corporate firewall: use data freely inside, nothing leaks out.**
265+
266+ ### Supported Platforms
267+
268+ | Platform | Integration | Note |
269+ | ----------| ------------| ------|
270+ | ** OpenClaw** | Plugin | ` openclaw plugins install shellward ` |
271+ | ** Claude Code** | SDK | Anthropic's official CLI agent |
272+ | ** Cursor** | SDK | AI-powered coding IDE |
273+ | ** LangChain** | SDK | LLM application framework |
274+ | ** AutoGPT** | SDK | Autonomous AI agents |
275+ | ** OpenAI Agents** | SDK | GPT agent platform |
276+ | ** Dify / Coze** | SDK | Low-code AI platforms |
277+ | ** Any AI Agent** | SDK | ` npm install shellward ` , 3 lines to integrate |
231278
232279### Features
233280
234281- ** 8 defense layers** : prompt guard, input auditor, tool blocker, output scanner, security gate, outbound guard, data flow guard, session guard
235- - ** Chinese PII** : ID card (GB 11643 checksum), phone (all carriers), bank card (Luhn)
236- - ** Global PII** : OpenAI/GitHub/AWS keys, JWT, passwords, SSN, credit cards
282+ - ** Chinese PII audit ** : ID card (GB 11643 checksum), phone (all carriers), bank card (Luhn)
283+ - ** Global PII audit ** : OpenAI/GitHub/AWS keys, JWT, passwords, SSN, credit cards
237284- ** 26 injection rules** : 14 Chinese + 12 English, risk scoring, mixed-language detection
238285- ** Data exfiltration chain** : read sensitive file → network send = blocked
239286- ** Zero dependencies** , zero config, Apache-2.0
@@ -244,6 +291,8 @@ The only OpenClaw security plugin with **bilingual (EN/ZH) support** — Chinese
244291openclaw plugins install shellward
245292```
246293
294+ Or as SDK: ` npm install shellward ` and ` import { ShellWard } from 'shellward' `
295+
247296### Config
248297
249298``` json
@@ -261,7 +310,7 @@ openclaw plugins install shellward
261310| Command | Description |
262311| ---------| -------------|
263312| ` /security ` | Security status overview |
264- | ` /audit [n] [filter] ` | View audit log |
313+ | ` /audit [n] [filter] ` | View audit log (filter: block, audit, critical, high) |
265314| ` /harden ` | Scan & fix security issues |
266315| ` /scan-plugins ` | Scan plugins for malicious code |
267316| ` /check-updates ` | Check versions & known CVEs (17 built-in) |
0 commit comments