
Shellward
io.github.jnMetaCode由 GitHub 账号 jnMetaCode 发布v0.5.11更新于 Oct 24, 2026
AI agent security: 7 MCP tools for injection detection, PII scanning, command safety, DLP.
概览
Shellward 为助手提供运行时安全检查:提示注入检测、PII 与密钥扫描、危险命令拦截和数据外泄防护。
- 可以做什么
- Shellward 是本地 MCP 服务器,提供 check_command、check_injection、scan_data、check_path、check_tool、check_response、scan_mcp_tool、security_status、compliance_check 等安全工具。它按中英文规则为文本打注入风险分,识别 PII 与凭据(含中国身份证号、手机号、银行卡号),标记危险 shell 命令与敏感路径,并在读取敏感数据后拦截外发。它还会对 MCP 工具定义做指纹,标记投毒与静默变更,并可运行面向中国的合规扫描。
- 适用场景
- 当助手拥有 shell、文件、HTTP 或邮件工具,且你希望在命令、工具定义和外发流量执行前加一层护栏时适合使用。也适合需要中文注入与 PII 检测或中国合规自查的团队。它不是 RAG 或向量工具。
- 运行要求
- 以 npm 包形式通过 stdio 在本地运行(npx shellward,shellward-mcp 可执行文件),需要 Node.js 与 npm。未声明账号或 API 密钥。可选环境变量:SHELLWARD_MODE(enforce 或 audit)、SHELLWARD_LOCALE(auto、zh、en)、SHELLWARD_THRESHOLD(0-100)。
安装
在 SourceWeft 中
- 打开 控制台中的 Shellward,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
ShellWard
AI 应用合规网关 — 为中国监管而生的 AI Agent 安全合规工具(网安法 2026 / PIPL / 等保2.0 / 数据出境 / AI标识)。先一行命令体检项目合规风险,再在运行时拦截提示注入、数据外泄与危险命令。中文威胁检测 + 中文 PII + 零依赖——英文工具不做的事。
[npm] [license] [tests] [deps]
🌐 官网: https://jnmetacode.github.io/shellward/
30 秒合规体检
零安装、只读、不上传任何数据。一行命令,扫出你的 AI 项目踩了哪些合规红线:
输出一张映射到 网安法 / PIPL / 等保2.0 / 数据出境 / AI标识 的红黄绿评分卡,并精确到 文件:行:
🆕 让你的 agent 做一次完整合规审计(Skill)
scan 是确定性扫描:它能告诉你「项目里有境外模型端点」,但判断不了个人信息有没有真的流过去;14 个法规控制项里也有 11 个它只能标「需人工确认」。这一段交给你的编码 agent 来做——Claude Code、Cursor、Codex 等支持 Agent Skills 的工具都能用。
把这句话粘贴给你的 agent:
或者用命令装:npx skills add jnMetaCode/shellward --skill china-ai-compliance-audit
它会先跑 shellward scan 拿确定性基线,再顺着数据流逐项取证,最后产出 .compliance/COMPLIANCE-REPORT.md。和「让 AI 随便看看合不合规」的区别在三道闸:
另外:14 个控制项必须全部有结论,不许悄悄跳过;报告里不许出现完整密钥、手机号、身份证号——合规报告自己不能泄漏数据。
示例(演示项目 · 完整记录):一个客服机器人,shellward scan 给 75 分 [B]、只报出「有 OpenAI 端点」;审计顺着调用链查到客户手机号和身份证号被拼进 system prompt 发往境外——2 条严重、3 条高,外加 6 个只有人能回答的问题(比如「审核是不是在网关侧做了」——仓库里看不到的事,它不替你下结论)。
这是技术自查材料,不是法律意见。备案、定级、PIA 等主体责任不能由工具代替。
团队要对多个 AI 项目做合规自查、或想把它接进内部流程? 邮件 [email protected],说一下团队规模和场景。
想在浏览器里看?npx shellward scan --open(扫完直接打开报告)或 --serve(本地 http://localhost 提供报告)——数据全程不出本机。
Web 扫描器 / 客户端(双模式):
shellward web— 公开仓库 web 扫描器:网页贴「公开仓库 URL」或用/scan?repo=URL链接体检(可部署,见Dockerfile)。shellward web --local— 本地 web GUI(客户端体验):填本地路径扫描,私有代码不上传、不出本机,无需命令行。
--json 供 CI · --ci 发现 critical 时让构建失败 · --html report.html 导出可打印成 PDF 的报告(备案/审计存档)· 也可作 GitHub Action 接入 PR 门禁。
检测重点:境外大模型端点与 SDK 依赖(数据出境——中国独有、英文工具没有的概念)、硬编码密钥、文件中的中文 PII、
.env暴露。扫到境外模型(如openai依赖)时,直接给出境内合规替代(通义千问 / DeepSeek / Kimi / 智谱)及其 OpenAI 兼容base_url——多数迁移只需改一个base_url。
境内合规替代表(src/rules/domestic-alternatives.ts,报告里默认推荐前 4 个;欢迎 PR 补充,见 #3)
base_url 为各厂商公开的 OpenAI 兼容端点,可能随官方调整,迁移前以官方文档为准。境外识别覆盖 OpenAI / Anthropic / Gemini / Azure / Bedrock / Cohere / Mistral / Groq / Together / Perplexity / OpenRouter / HuggingFace / xAI / Replicate / AI21 / Fireworks / DeepInfra / Cerebras / Voyage / NVIDIA NIM 的端点,以及 npm / pip / Go 的 SDK 依赖(含 LangChain、LlamaIndex、Vercel AI SDK 适配包),见 src/rules/overseas-llm.ts(#4)。
想在浏览器里看报告? 在项目目录跑 npx shellward scan --open —— 自动扫描并在浏览器打开报告,无需上传、无弹框、数据不出本机(最干净)。也可 npx shellward web --local 起本地图形界面(粘贴/点选路径,服务端直读)。
更多命令、运行时防护(MCP / 插件)、与英文文档见下方 English 章节。
English
AI Agent Security & Compliance Gateway — the AI agent security middleware built for China's regulatory regime (CSL / PIPL / MLPS 2.0 / cross-border data / AI labeling). Scan your project for compliance risks, then block prompt injection, data exfiltration, and dangerous commands at runtime. Chinese-language threat detection + Chinese PII + zero dependencies — things English tools don't do.
Quick start: npx shellward scan — zero install, read-only, nothing uploaded. Outputs a red/yellow/green scorecard mapped to Chinese regulations plus concrete file:line findings, and prescribes domestic compliant model alternatives for any overseas LLM it finds.
Agent skill: a full compliance audit, with receipts
scan is deterministic: it can tell you "this project calls an overseas LLM endpoint", but not whether personal data actually flows to it — and 11 of the 14 regulatory controls can only be marked "needs manual review". The china-ai-compliance-audit skill hands that part to your coding agent (Claude Code, Cursor, Codex, or anything that supports Agent Skills).
Paste this into your agent:
or npx skills add jnMetaCode/shellward --skill china-ai-compliance-audit.
It runs shellward scan as a deterministic baseline, traces the data flow control by control, and writes .compliance/COMPLIANCE-REPORT.md. What makes it different from "ask the AI if this looks compliant" is three gates:
- Evidence gate — every finding needs
file:lineplus a verbatim quote. A zero-dependency validator opens each file and checks the quote is really there. Hallucinated citations fail the run. - Verification gate — every "gap" and every "measure found" is handed to a fresh agent that never saw the auditor's reasoning, whose only job is to disprove it. Overturned findings are kept on record, not deleted.
- Honesty gate — facts that aren't in the repo (filings, impact assessments, actual log retention) can't be guessed. The agent must ask one specific question a human can answer, with no severity attached.
All 14 controls must reach a verdict — no silent skips — and the report itself may not contain full secrets, phone numbers or ID numbers.
Example (demo project, full record): a support bot that shellward scan grades 75/100 [B] with a single "OpenAI endpoint" note. The audit follows the call chain and finds customer phone and national-ID numbers interpolated into the system prompt sent overseas — 2 critical, 3 high, plus 6 questions only a human can answer.
A technical self-check, not legal advice.
Demo
7 real-world scenarios: server wipe → reverse shell → prompt injection → DLP audit → data exfiltration chain → credential theft → APT attack chain
The Problem
Your AI agent has full access to tools — shell, email, HTTP, file system. One prompt injection and it can:
Like a corporate firewall: use data freely inside, nothing leaks out.
Supported Platforms
Features
- 8 defense layers: prompt guard, input auditor, tool blocker, output scanner, security gate, outbound guard, data flow guard, session guard
- DLP model: data returns in full (no redaction), outbound sends are blocked when PII was recently accessed
- PII detection: SSN, credit cards, API keys (OpenAI/GitHub/AWS), JWT, passwords — plus Chinese ID card (GB 11643 checksum), carrier-validated mobile, UnionPay bank card (Luhn) — precision-tuned to cut false positives
- 37 injection rules: 20 Chinese + 17 English, risk scoring, mixed-language detection
- MCP tool-poisoning scan: detects hidden instructions, invisible characters, concealment ("hide from user"), secret-file access & exfiltration hints in a tool's description/parameters
- MCP rug-pull detection: fingerprints each tool's description on first sight, flags silent changes across runs
- Data exfiltration chain: read sensitive data → send email / HTTP POST / curl = blocked
- Bash bypass detection: catches
curl -X POST,wget --post,nc, Python/Node network exfil - Zero dependencies, zero config, Apache-2.0
Quick Start
As MCP Server
ShellWard runs as a standalone MCP server over stdio — zero dependencies, no @modelcontextprotocol/sdk needed.
Claude Desktop / Cursor / any MCP client:
Add to your MCP config (claude_desktop_config.json, .cursor/mcp.json, OpenClaw, etc.) — no install path needed, npx fetches the published shellward-mcp bin:
If installed globally (npm i -g shellward), simply use "command": "shellward-mcp".
8 MCP tools available:
Environment variables:
As SDK (any AI agent platform):
As OpenClaw plugin:
Zero config, 8 layers active by default.
GitHub Action (PR Compliance Gate)
Block hardcoded secrets and overseas-LLM data-export risk before they merge. Add to .github/workflows/compliance.yml:
Or run it directly without the Action: npx shellward scan --ci.
Policy-as-code (.shellward.json)
声明式 CI 门禁(issue #2)— put a .shellward.json in your repo root:
failOn— fail CI if any finding matches these kinds (secret/pii/overseas/env-perm) or severities (critical/high/medium)maxFindings— max total findings allowedallowOverseas— overseas providers explicitly permitted (exempt from failure)
Per-path rules(按路径的规则,issue #5)— stricter constraints for sensitive directories, checked in addition to the global ones:
path— one pattern or a list, relative to the repo root:**any depth,*within one directory,?one char. A pattern without/(e.g.*.py) matches at any depth, like.gitignore; a pattern without wildcards (e.g.agents) matches that file or everything under that directory.failOn/maxFindings— same meaning as the global fields, counted only over findings in scope.allowOverseas— omitted = inherit the global list; set it (even to[]) to override for that path. Above,agents/**must have no overseas calls at all, while OpenAI stays allowed elsewhere.
Unknown fields, misspelled failOn values (e.g. "secrets") and a broken JSON file are printed as ⚠️ warnings in CI instead of being silently ignored — a typo can no longer turn the gate into a no-op.
shellward scan --ci reads it; without the file it defaults to "fail on any critical". 实现「策略在 Git push 时声明 → 运行时执行」的纵深防御。
8-Layer Defense
Detection Examples
Dangerous Commands:
Prompt Injection:
Data Exfiltration Chain:
Each step looks legitimate alone. Together it's an attack. ShellWard catches the chain.
PII Detection:
OWASP Coverage
How ShellWard maps to the OWASP Top 10 for LLM Applications (2025) and common MCP risks. Honest scope — ✅ covered, ◐ partial, ✗ out of scope.
Configuration
Custom Rules (SDK)
Extend the built-in rules without forking — every field is additive, except allowedTools which always wins:
Invalid regexes are skipped (never throws), so user input can't break the guard.
Commands (OpenClaw)
Performance
Detection Benchmark
Effectiveness is measured, not asserted. npm run bench runs every detector over a labeled corpus (attacks and hard negatives — benign text that looks suspicious) and reports precision/recall/F1. The corpus and harness live in bench/; CI fails on regression.
The compliance scanner has its own gated corpus — npm run bench:scan runs the real scanProject pipeline over 41 labeled cases (24 real risks + 17 hard negatives: domestic endpoints, placeholder keys, doc examples, lock files, invalid checksums). Self-authored corpus, CI-gated against regression.
83 gated samples (attacks + hard negatives). Zero-width-interleaved and empty-quote (r''m) obfuscation are normalized before matching. The corpus also tracks 5 documented bypasses (leetspeak, base64, non-zh/en languages, shell variable indirection) that regex/heuristics are not expected to catch — listed explicitly and excluded from the gate rather than hidden.
Numbers are on the current in-repo corpus — a floor, not a universal guarantee. Found a bypass? Add it to
bench/corpus.tsas a labeled row and the gap becomes measurable (and CI-enforced).Conservative by design: in enforce mode ShellWard fails safe — e.g.
echo "rm -rf /"(printing a literal) is flagged, since regex can't distinguish it fromecho "$(rm -rf /)"(which executes).
Vulnerability Database
17 built-in CVE / GitHub Security Advisories. /check-updates checks if your version is affected:
- CVE-2025-59536 (CVSS 8.7) — Malicious repo executes commands via Hooks/MCP before trust prompt
- CVE-2026-21852 (CVSS 5.3) — API key theft via settings.json
- GHSA-ff64-7w26-62rf — Persistent config injection, sandbox escape
- Plus 14 more confirmed vulnerabilities...
Remote vuln DB syncs every 24h, falls back to local DB when offline.
Use Cases
ShellWard is built for teams that need runtime security for AI agents — whether you are building autonomous coding assistants, customer-facing chatbots with tool access, or internal automation powered by LLMs. Common use cases include MCP security enforcement, tool call interception and filtering, and adding agent guardrails to any LLM-powered workflow.
Why ShellWard?
ShellWard is the only tool with DLP-style data flow tracking + Chinese language security + zero dependencies in a single package.
Recent research (arXiv:2603.08665) demonstrates GenAI discovering 38 real-world vulnerabilities in 7 hours — AI-powered attacks are scaling fast. Defense must be built into the agent layer.
Author
jnMetaCode · Apache-2.0
中文
AI Agent 安全 · 合规网关 — 唯一为中国监管(网安法 / PIPL / 等保2.0 / 数据出境 / AI标识 GB45438)和中文语境而生的 AI Agent 安全中间件。先一键体检项目合规风险,再在运行时拦截提示注入、数据外泄与危险命令。中文威胁检测 + 中文 PII + 零依赖——英文工具不做的事。
30 秒合规体检
零安装、只读、不上传任何数据。现在就扫你的 AI 项目:
输出一张映射到 网安法 / PIPL / 等保2.0 / 数据出境 / AI标识 的红黄绿评分卡,并列出项目里 文件:行 级别的真实风险:
--json 供 CI 消费 · --ci 发现 critical 时让构建失败 · 也可作 GitHub Action 接入 PR 门禁。
检测重点:境外大模型端点(数据出境风险 — 中国独有、英文工具没有这个概念)、硬编码密钥、文件中的中文 PII、
.env暴露。命令形态/compliance,MCP 工具compliance_check。
[ShellWard AI Agent 安全防火墙演示 — 拦截提示词注入、数据泄露和反弹Shell攻击]
7 个真实攻击场景:服务器毁灭拦截 → 反弹 Shell → 注入检测 → DLP 审计 → 数据外泄链 → 凭证窃取 → APT 攻击链
核心理念:像企业防火墙一样,内部随便用,数据出不去。
支持平台
安装
MCP 服务器模式(推荐):
在 MCP 配置中添加(适用于 Claude Desktop、Cursor、OpenClaw 等)。无需本地路径,npx 会拉取已发布的 shellward-mcp:
若已全局安装(npm i -g shellward),直接用 "command": "shellward-mcp" 即可。
零依赖,原生实现 MCP 协议。提供 8 个安全工具:命令检查、注入检测、敏感数据扫描、路径保护、工具策略、响应审计、MCP 工具投毒/rug-pull 扫描、安全状态。
OpenClaw 插件模式:
SDK 模式:
特色
- DLP 模型:数据完整返回(不脱敏),外部发送才拦截 — 用户体验零影响
- 中文 PII:身份证号(GB 11643 校验位)、手机号(全运营商)、银行卡号(Luhn 校验)
- 中文注入检测:18 条中文规则 + 14 条英文规则,支持中英混合攻击检测
- MCP 工具投毒扫描:检测工具描述/参数里的隐藏指令、不可见字符、"对用户隐瞒" 类隐蔽指令、敏感文件访问与外泄提示
- MCP rug-pull 检测:首次见到工具时记录描述指纹,后续被偷改即告警(
/scan-mcp一键扫描已配置 MCP 服务器) - 数据外泄链:读敏感数据 → send_email / HTTP POST / curl 外发 = 拦截
- 零依赖、零配置、Apache-2.0
为什么选 ShellWard?
ShellWard 是唯一同时具备 DLP 数据流追踪 + 中文语言安全 + 零依赖 的 AI Agent 安全工具。
最新研究 (arXiv:2603.08665) 显示 GenAI 在 7 小时内发现 38 个真实漏洞 — AI 驱动的攻击正在规模化,防御必须内建到 Agent 层。
交流 · Community
微信公众号 「AI不止语」(微信搜索 AI_BuZhiYu)— 技术问答 · 项目更新 · 实战文章
姊妹项目
作者
jnMetaCode · Apache-2.0
来源:README.md,提交 78444dd
工具
0版本历史
1- v0.5.11最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分