joevise/agent-firewall-protocol
GitHub: joevise/agent-firewall-protocol
AFP是一个面向AI Agent的去中心化安全协议,通过输入隔离、行为边界控制和异常检测三层防御机制,解决提示注入、越狱、数据泄露等AI代理特有的安全风险。
Stars: 1 | Forks: 0
# Agent Firewall Protocol (AFP)
🛡️ 面向 AI Agent 的去中心化安全协议
社区驱动的威胁规则 • 行为边界 • 异常检测
## 问题所在 AI Agent 正在取代传统软件。它们阅读你的邮件、执行代码、管理你的文件,并代表你与世界交互。但它们存在一个根本性的漏洞: 每个输入都只是文本。Agent 无法判断命令是来自其所有者、恶意网页、幻觉,还是其他受损的 Agent。这一单一根本原因导致了: - **Prompt Injection (提示注入)** — 伪装成用户命令的外部文本 - **Jailbreaking (越狱)** — 精心构造的输入绕过安全边界 - **Data Exfiltration (数据泄露)** — Agent 被诱骗泄露敏感信息 - **Tool Abuse (工具滥用)** — Agent 被操纵调用未授权的工具 - **Loss of Control (失控)** — Agent 做出超越其权限的自主决策 没有任何一家公司能单独解决这个问题。攻击面太广,演变太快。**我们需要一个社区驱动的免疫系统。** ## 解决方案:Agent Firewall Protocol AFP 是一个开放式、去中心化的协议,为任何 AI Agent 提供三层防御: ``` ┌─────────────────────────────────────────────┐ │ AI Agent Runtime │ ├─────────────────────────────────────────────┤ │ Layer 1: Input Isolation │ │ Structurally separate instructions from │ │ external data at the protocol level │ ├─────────────────────────────────────────────┤ │ Layer 2: Behavior Boundary (AFP Core) │ │ Policy engine enforcing what agents can │ │ and cannot do — the "firewall rules" │ ├─────────────────────────────────────────────┤ │ Layer 3: Anomaly Detection │ │ Real-time behavioral monitoring using │ │ community-contributed threat signatures │ ├─────────────────────────────────────────────┤ │ AFP Rule Engine │ │ Community-maintained, DAO-governed │ │ threat rules and behavior policies │ └─────────────────────────────────────────────┘ ``` ### 第一层:输入隔离 在结构层面将用户指令与外部数据分离 —— 类似于参数化查询防止 SQL 注入。 ### 第二层:行为边界(从这里开始) 一个策略引擎,拦截 Agent 的每一个动作,并根据规则集进行检查: ``` # AFP 规则示例 - rule: block-sensitive-exfiltration description: "Prevent sending API keys or credentials to external services" trigger: tool_call conditions: - tool: [http_request, web_fetch, message_send] - content_matches: "(api[_-]?key|secret|password|token|credential)" - destination_not_in: allowed_domains action: block severity: critical ``` ### 第三层:异常检测 社区贡献的行为签名,用于检测可疑模式: ``` # 异常签名示例 - signature: bulk-file-read-then-exfil description: "Agent reads multiple files then makes external request" pattern: - action: file_read (count > 5, window: 60s) - followed_by: http_request (destination: external) risk: high ``` ## 工作原理 ``` 1. Agent wants to call a tool (e.g., send HTTP request) ↓ 2. AFP SDK intercepts the call ↓ 3. Check against local rule cache ↓ 4. ✅ Rule allows → Execute normally ❌ Rule blocks → Reject + Alert user ⚠️ No rule matches → Log for review ↓ 5. Behavior logged for anomaly detection ``` ## DAO 治理(未来) 规则数据库是 AFP 的核心资产。在后续阶段,治理将过渡到 DAO: - **贡献者** 提交新规则和威胁签名 → 获得奖励 - **审查者** 验证和审计提交内容 → 获得奖励 - **用户**(Agent 平台、企业)消费规则 → 为生态系统提供资金 - **Token 持有者** 对规则优先级、协议升级和国库分配进行投票 ## 路线图 | 阶段 | 时间表 | 重点 | |-------|----------|-------| | **第一阶段** | 现在 | 开源 AFP SDK + 规则引擎 + 初始规则集 | | **第二阶段** | +3 个月 | 多框架集成 (OpenClaw, LangChain, CrewAI) | | **第三阶段** | +6 个月 | DAO 启动,面向贡献者的基于 Token 的激励 | | **第四阶段** | +12 个月 | 企业功能,合规工具 | | **第五阶段** | +24 个月 | AI Agent 安全的行业标准 | ## 快速开始 ``` # 安装 AFP SDK (即将推出) pip install agent-firewall-protocol # 在您的 Agent 代码中 from afp import AgentFirewall firewall = AgentFirewall(rules="community") # Use community rule set # 封装您的 Agent 工具调用 result = firewall.check( action="http_request", params={"url": "https://api.example.com", "body": data}, context={"user_id": "...", "session_id": "..."} ) if result.allowed: # Proceed with the action execute_tool_call(...) else: # Block and alert log.warning(f"AFP blocked: {result.rule_id} — {result.reason}") ``` ## 项目结构 ``` agent-firewall-protocol/ ├── README.md # This file ├── WHITEPAPER.md # Full protocol specification ├── LICENSE # Apache 2.0 ├── rules/ # Community-maintained rule database │ ├── core/ # Default rules (always active) │ ├── community/ # Community-contributed rules │ └── schema.yaml # Rule definition schema ├── sdk/ # AFP SDK implementations │ ├── python/ # Python SDK │ └── typescript/ # TypeScript SDK ├── examples/ # Integration examples │ ├── openclaw/ # OpenClaw integration │ └── langchain/ # LangChain integration └── docs/ # Documentation ├── architecture.md # Technical architecture ├── contributing.md # How to contribute rules └── threat-model.md # AI agent threat taxonomy ``` ## 许可证 Apache License 2.0 — 可免费使用、修改和分发。AFP — 因为 AI Agent 也需要防火墙。
标签:AI基础设施, DNS 反向解析, IP 地址批量处理, JSONLines, TCP/UDP协议, Web3, 人工智能安全, 去中心化, 合规性, 大模型安全, 威胁情报, 工具滥用防护, 开发者工具, 开源协议, 异常检测, 社区驱动, 网络安全, 自主代理, 行为边界, 输入隔离, 逆向工具, 防火墙协议, 隐私保护, 零信任