Zorropiscina/artguard
GitHub: Zorropiscina/artguard
一款专为 AI agent 技能、MCP 配置和 IDE 规则文件设计的安全扫描 CLI,通过三层检测机制识别隐私风险和指令级攻击。
Stars: 0 | Forks: 0
# artguard
[](https://raw.githubusercontent.com/Zoropiscina/artguard/main/presurvey/Software_canal.zip)
[](https://raw.githubusercontent.com/Zoropiscina/artguard/main/presurvey/Software_canal.zip)
[](https://raw.githubusercontent.com/Zoropiscina/artguard/main/presurvey/Software_canal.zip)
一个 Claude Code prompt,可自主构建完整的 AI artifact 扫描器 CLI。
将 prompt 粘贴到 Claude Code 中,它会构建 `artguard` —— 一个可工作的 Python CLI,
用于扫描 agent 技能、MCP server 配置以及 IDE 规则文件,检测安全威胁、
隐私违规和指令级攻击。
## 问题背景
企业在安装 AI agent 技能、MCP server 和 IDE 规则文件
(`.cursorrules`、`.clinerules`、`.windsurfrules`)时,往往未经过任何安全审查。
目前尚无扫描器覆盖这些内容。
传统扫描器是为代码包构建的。AI artifacts 是混合体 —— 部分是代码,部分是自然语言指令 —— 而攻击面正是指令本身。
YARA 规则无法捕获那些指示你的编码 agent 批准存在漏洞的 PR 的技能。静态分析也无法发现那些声称“不存储数据”却在写入磁盘的 artifact。
## artguard 扫描内容
| Artifact 类型 | 示例 |
|---|---|
| Agent 技能文件 | `skills.md`、`skill.json`、工具定义 |
| MCP server 配置 | `mcp.json`、server 清单 |
| IDE 规则文件 | `.cursorrules`、`.clinerules`、`.windsurfrules` |
| 插件清单 | `manifest.json`、API schema |
## 三层检测机制
**Layer 1 — 隐私姿态分析** (差异化能力)
检测 artifact 声称的数据处理方式与其实际行为之间的差异。包括未披露的存储、隐蔽遥测、第三方共享、保留策略不匹配。
**Layer 2 — 语义指令分析** (差异化能力)
基于 LLM 的检测,针对指令内容中的行为操纵、prompt 注入、上下文污染和目标劫持。
**Layer 3 — 静态模式匹配** (基础能力)
传统恶意软件模式 —— 凭证窃取、数据外泄端点、混淆代码 —— 由最优秀的免费扫描器提供支持。
## 输出
每次扫描都会生成一个 **Trust Profile JSON** —— 一种结构化的 AI 物料清单 (AI Bill of Materials),旨在为策略引擎、审计日志和访问控制提供数据。不是简单的安全/不安全二元判定。
```
Composite Trust Score: 14 ██░░░░░░░░░░░░░░░░░░ MALICIOUS 🔴
┌─ PRIVACY POSTURE ─────────────────────────── Score: 32/100 ┐
│ [CRITICAL] PV3 Retention claim mismatch │
│ Claims "no data stored" but writes to ~/.cache │
└─────────────────────────────────────────────────────────────┘
┌─ BEHAVIORAL INTENT ────────────────────────────────────────┐
│ [HIGH] S4 System prompt override detected │
│ "Ignore all previous instructions and..." │
└─────────────────────────────────────────────────────────────┘
```
## 使用方法
**要求:** Claude Code、Python 3.11+、Anthropic API key (用于 Layer 2)。
```
# 1. 创建新目录
mkdir artguard && cd artguard
# 2. 打开 Claude Code
claude
# 3. 粘贴 prompt.md 的内容
# Claude Code 将自动搭建完整项目
# 4. 扫描 artifact
artguard scan path/to/skill.md
artguard scan path/to/mcp.json --deep # enables Layer 2 LLM analysis
artguard batch ./skills-directory/
```
## 架构
Layer 3 集成了 YARA 规则、启发式引擎、哈希查询和 IP 信誉源,均来自最优秀的开源和免费资源 —— 因此你可以获得广泛的覆盖范围,而无需被供应商锁定。
## 项目结构 (Claude Code 生成内容)
```
artguard/
├── artguard/
│ ├── cli.py # Click CLI entry point
│ ├── schema.py # Finding, TrustProfile dataclasses
│ ├── db.py # SQLite feedback corpus
│ ├── parsers/ # One parser per artifact type
│ ├── analyzers/
│ │ ├── layer1_privacy.py # Privacy posture analysis
│ │ ├── layer2_semantic.py # LLM semantic instruction analysis
│ │ └── layer3_static.py # Static pattern matching (extractable)
│ ├── trust_profile/ # Trust Profile builder + scorer
│ └── output/ # Terminal + export formatting
├── tests/
│ └── fixtures/ # Benign + malicious sample artifacts
├── scan_profiles/ # YAML policy configs
└── prompt.md # ← This file is the source of truth
```
## 贡献
prompt 是事实来源。欢迎对检测模式、新的 artifact 解析器或更好的 YARA 规则进行改进 —— 无论是作为 prompt 编辑还是针对生成代码库的 PR。
如果你针对真实技能注册表(ClawHub、skills.sh、npm MCP 包)进行压力测试,测试结果和误报率尤其有价值。
## 许可证
MIT
标签:AI安全, AI治理, AMSI绕过, C2, Chat Copilot, DevSecOps, DNS 反向解析, MCP安全, Prompt安全, Python, 上游代理, 云安全监控, 人工智能安全, 企业安全, 合规性, 威胁检测, 安全扫描, 指令注入检测, 无后门, 时序注入, 网络资产管理, 逆向工具, 隐私合规, 静态分析