aisecurefuture/CyberArmorAi
GitHub: aisecurefuture/CyberArmorAi
AI 安全运行时与预获取 URL 信任网关,在外部内容进入 AI 上下文之前评估威胁并执行策略,为 LLM 和 Agentic AI 工作负载提供零信任防护。
Stars: 0 | Forks: 0
# CyberArmor
**预获取 URL 信任网关与 AI 安全运行时**
CyberArmor 在人类、浏览器、应用程序或 AI Agent 信任 URL、网页、Prompt 及 Agent 绑定内容之前对其进行评估。它能够检测网络钓鱼、隐藏的 Prompt 注入、Promptware、凭据窃取信号、敏感数据风险以及 IOC 指标,随后通过允许、警告、脱敏、沙盒、拦截、隔离、路由或仅留存证据的决策来执行租户策略。—— 为部署 AI、Agentic AI 和 LLM 驱动应用程序的组织提供全面保护。
## 概述
CyberArmor 是一个零信任、多层安全平台,为企业 AI 工作负载提供实时监控、策略执行、数据防泄漏和合规性管理。旨在支持在客户环境有要求时,部署经过 FIPS 140-3 验证的加密模块,并符合 CNSA 2.0+ 后量子算法建议。
## 架构
```
┌─────────────────────────────────────────────────────────────────┐
│ Admin Dashboard │
│ (Vanilla JS SPA + Nginx) │
├─────────────────────────────────────────────────────────────────┤
│ Ingress / Load Balancer │
├────────┬────────┬────────┬────────┬────────┬────────┬──────────┤
│Control │ Policy │Detect- │Response│Identity│ SIEM │Compliance│
│ Plane │ Engine │ ion │ │Provider│Connector│ Engine │
│ :8000 │ :8001 │ :8002 │ :8003 │ :8004 │ :8005 │ :8006 │
├────────┬────────┬────────┬────────┬────────┬────────┬──────────┤
│ Agent │AI Router│ Audit │Integ- │Runtime │Secrets │ OpenBao │
│Identity│ │ │ration │ API │Service │ Vault │
│ :8008 │ :8009 │ :8011 │ :8012 │ :8010 │ :8013 │ │
├────────────────────────────┬────────────────────────────────────┤
│ URL / Context Trust Gate │ Detonation Worker (isolated net) │
│ :8014 │ :8015 (internal only) │
├────────────────────────────┴────────────────────────────────────┤
│ Transparent AI Proxy (:8080) │
│ (mitmproxy dev; HTTPS on :8443 in dev) │
├─────────────────────────────────────────────────────────────────┤
│ PostgreSQL Redis Message Queue │
├──────────┬──────────┬──────────┬──────────┬─────────────────────┤
│ Endpoint │ Browser │ IDE │ Office │ RASP Agents │
│ Agent │Extensions│Extensions│ Add-ins │ (9 languages) │
├──────────┼──────────┼──────────┼──────────┼─────────────────────┤
│ macOS │ Chrome │ VS Code │ Word │ Java │ .NET │
│ Windows │ Firefox │ Visual │ Excel │ Python │ Node.js │
│ Linux │ Safari │ Studio │ PowerPt │ Go │ Rust │
│ │ Edge │ Cursor │ OneNote │ Ruby │ PHP │
│ │ Brave │ Kiro │ Outlook │ C/C++ │ │
├──────────┴──────────┴──────────┴──────────┴────────┴───────────┤
│ Kernel: Linux eBPF │ macOS Endpoint Security │ Windows WFP │
├─────────────────────┴────────────────────────┴─────────────────┤
│ ROS2 Agent (Robotics) │ React Native Mobile (iOS/Android) │
└─────────────────────────┴──────────────────────────────────────┘
```
## 核心服务
| 服务 | 端口 | 描述 |
|---------|------|-------------|
| Control Plane | 8000 | 中央 API 网关,租户管理,API Key CRUD |
| Policy Engine | 8001 | 可扩展的 AND/OR 策略评估,基于优先级的规则 |
| Detection | 8002 | Prompt 注入、越狱、有害内容、PII 检测 |
| Response | 8003 | 事件管理,自动化响应动作 |
| Identity Provider | 8004 | SSO 集成 (Entra ID, Okta, Ping, AWS IAM) |
| SIEM Connector | 8005 | 输出至 Splunk, Sentinel, QRadar, Elastic, Google SecOps, Syslog/CEF |
| Compliance Engine | 8006 | 14 项合规框架,基于证据的评估 |
| Agent Identity | 8008 | AI Agent 身份、凭据、Token 和委托链 |
| AI Router | 8009 | 统一的 AI 提供商网关,具备凭据保管库、请求规范化、成本跟踪和治理功能 |
| Proxy Agent | 8010 | 策略决策 API 和本地拦截动作 |
| Audit Service | 8011 | 不可变的 PQC 签名审计日志和 AI 动作图谱 |
| Integration Control | 8012 | SaaS 集成发现,OAuth 范围可见性及控制动作 |
| Secrets Service | 8013 | 构建于 OpenBao 之上的轻量级 CyberArmor 控制层:租户/提供商凭据存储、传输加密/解密/签名、密钥轮换 |
| URL / Context Trust Gate | 8014 | 针对面向人类、浏览器、Endpoint Agent、接入 RASP 的应用以及 AI Agent 的 URL 和外部内容的预获取安全检查。在内容进入 AI 上下文之前检测网络钓鱼、隐藏的 Prompt 注入、Promptware 和 IOC。 |
| Detonation Worker | 8015 (内部) | URL Trust Gate 的隔离 Playwright 沙盒。在一次性 Chromium 上下文中渲染由攻击者控制的 URL,运行在专用的 `detonation` 网络上,且没有通往内部服务的路由。基于 Microsoft 发布的 Playwright 镜像构建。 |
| Transparent Proxy | 8080 / 8443 | AI 流量拦截、检查和策略执行 |
| OpenBao Vault | — | 底层密钥和加密引擎 (KV, 传输, 密钥管理) |
## 安全特性
- **后量子密码学**:ML-KEM-1024 (Kyber) 密钥封装,ML-DSA-87 (Dilithium) 签名
- **PQC API Key 传输**:使用 AES-256-GCM 加密的 `PQC:` 请求头格式
- **零信任架构**:所有服务间通信均经过身份验证
- **多租户**:所有服务间完全的租户隔离
- **FIPS 140-3 支持**:旨在在客户环境需要时集成经过 FIPS 140-3 验证的加密模块
- **符合 CNSA 2.0+ 标准**:后量子算法套件
## 合规框架 (14项)
| 框架 | 控制项 | 描述 |
|-----------|----------|-------------|
| NIST CSF 2.0 | 18 | 网络安全框架 |
| NIST 800-53 r5 | 20 | 安全与隐私控制 |
| NIST AI RMF | 17 | AI 风险管理框架 |
| CMMC Level 3 | 16 | 网络安全成熟度模型 |
| NYDFS 23 NYCRR 500 | 15 | 纽约金融服务网络安全 |
| ISO 27001:2022 | 18 | 信息安全管理 |
| CIS Controls v8 | 16 | 互联网安全中心 |
| CSA CCM v4 | 16 | 云安全联盟 |
| OWASP (Combined) | 19 | Web + API + LLM Top 10 2025 + Agentic AI |
| SANS Top 25 | 15 | 最危险的软件弱点 |
| PCI-DSS v4.0 | 17 | 支付卡行业 |
| SOC 2 | 19 | 信任服务准则 |
| GDPR | 16 | 欧盟通用数据保护 |
| CCPA/CPRA | 14 | 加州消费者隐私 |
## URL / Context Trust Gate
一个位于消费者(人类、浏览器、Endpoint Agent、接入 RASP 的应用、AI Agent)与开放网络之间的预获取控制点。在任何消费者跟随 URL 或获取外部内容之前,该网关会对目标进行规范化处理,安全地获取它,针对网络钓鱼 / 隐藏的 Prompt 注入 / Promptware / 数据窃取 / IOC 进行评分,并应用策略决策(`allow` / `warn` / `redact` / `sandbox` / `block` / `isolate`)—— 同时在此过程中保留证据。
这填补了传统 URL 过滤器(“这个站点对人类有害吗?”)与 AI 安全(“这个站点让浏览器和 AI Agent 消费安全吗?”)之间的空白。现有的 Safe Browsing / SmartScreen / VirusTotal 数据源无法检测 AI 上下文攻击,例如间接 Prompt 注入或隐藏在 CSS-hidden / Unicode-tag-encoded 文本中的 Promptware 载荷。
**此仓库中附带的消费者接入组件:**
- 浏览器扩展:`extensions/chromium-shared/url_trust_gate.js` —— `webNavigation.onBeforeNavigate` 监听器,采用快速路径竞争 + 异步标准深度回填机制。
- Endpoint Agent:`agents/endpoint-agent/monitors/url_trust_gate.py` —— 网关客户端 + 本地回环 IPC 守护进程 (`127.0.0.1:48515`),其他端点软件(IDE 插件、自定义 Agent、MCP 客户端)可以在连接前调用;已集成到 Agent 的网络监控器中。
- RASP (Python):`rasp/python/cyberarmor_rasp_url_trust_gate.py` —— 通过 monkeypatch 修改 `requests` / `httpx` / `urllib3`,使得服务端 AI 工具在任何出站 URL 获取之前向网关发起咨询。
- LangChain SDK:`sdks/python/cyberarmor/frameworks/langchain_url_trust_gate.py` —— 为 AI Agent 提供的 `wrap_tool` / `wrap_agent_tools` / `make_guarded_browser_tool`。
- LlamaIndex SDK:`sdks/python/cyberarmor/frameworks/llamaindex.py` —— Reader 和 Node-Parser 钩子,在 LlamaIndex 获取或索引外部内容之前对 URL 进行网关过滤。
**可选信誉源(可配置,没有它们网关也能正常工作):**
- Google Safe Browsing v4 —— 设置 `SAFE_BROWSING_API_KEY`
- Microsoft SmartScreen (Defender Threat Intelligence) —— 设置 `SMARTSCREEN_TENANT_ID` / `SMARTSCREEN_CLIENT_ID` / `SMARTSCREEN_CLIENT_SECRET`
- VirusTotal v3 —— 设置 `VIRUSTOTAL_API_KEY`;结果在进程内缓存 `VIRUSTOTAL_CACHE_TTL_S` 秒
有关完整的流水线、延迟预算、决策动作、证据模式以及映射到每个代码级防护的生产环境陷阱,请参阅 [docs/architecture/url-trust-gate.md](docs/architecture/url-trust-gate.md)。
## 快速入门
### 15分钟 URL Trust Gate 概念验证 (PoC)
适用于希望在不搭建完整技术栈的情况下,看到 URL Trust Gate 拦截实时攻击页面的评估人员:
```
git clone https://github.com/aisecurefuture/CyberArmorAi.git
cd CyberArmorAi
bash scripts/poc/install.sh
```
该脚本生成密钥,仅启动网关所需的服务(`policy`、`detection`、`audit`、`response`、`postgres`、`redis`、`opa`、`url-trust-gate`,以及一个提供四个精心构造页面的 `poc-test-server`),等待健康检查通过,并运行 `scripts/poc/run_url_trust_gate_demo.py` 来演示以下实时判定:
- 良性的茶叶混合文章(预期:`allow`)
- `display:none` 的 Promptware 载荷(预期:`warn` / `redact` / `block`)
- 与零宽字符交织的指令(预期:`warn` / `redact` / `block`)
- 伪造的 Microsoft 登录凭据窃取页面(预期:`warn` / `redact` / `block`)
有关先决条件、投入生产前的加固步骤以及故障排除,请参阅 [scripts/poc/README.md](scripts/poc/README.md)。
### Docker Compose (开发环境)
```
cd infra/docker-compose
cp .env.example .env
# 使用你的配置编辑 .env
docker-compose up -d
```
访问 `http://localhost:3000` 以打开管理仪表板。
### 冒烟测试
```
# 启动 stack + 运行验证
./scripts/smoke-test.sh --up
# 仅运行验证(stack 已在运行)
./scripts/smoke-test.sh
```
## 部署文档
- Hetzner Ubuntu 测试部署:[docs/deployment/hetzner-ubuntu-vm.md](./docs/deployment/hetzner-ubuntu-vm.md)
- 一次性首台服务器检查清单:[docs/deployment/hetzner-first-server-checklist.md](./docs/deployment/hetzner-first-server-checklist.md)
- PQC 认证推出指南:[docs/security/pqc-auth-rollout.md](./docs/security/pqc-auth-rollout.md)
- OpenBao + Secrets Service 架构:[docs/architecture/openbao-cyberarmor-secrets-service.md](./docs/architecture/openbao-cyberarmor-secrets-service.md)
- Jenkins 安全与 OpenBao 集成流水线:[docs/security/jenkins-security-pipeline.md](.docs/security/jenkins-security-pipeline.md)
- Jenkins 安全流水线:[docs/security/jenkins-security-pipeline.md](./docs/security/jenkins-security-pipeline.md)
- V1 就绪度与租户上线计划:[docs/v1-readiness-plan.md](./docs/v1-readiness-plan.md)
- Ubuntu 加固辅助脚本:[scripts/hardening/harden_ubuntu_server.sh](./scripts/hardening/harden_ubuntu_server.sh)
## 当前产品边界
URL Trust Gate 已实现端到端运行并具备试点条件:15分钟的 PoC 安装程序能在任何开发者的笔记本电脑上启动完整的网关技术栈,并且三个信誉源(Google Safe Browsing、SmartScreen、VirusTotal)均可通过环境变量进行配置。更广泛的平台已可部署用于内部测试、预发布环境和受控的设计合作伙伴验证。在正式发布 (GA) 之前的剩余工作包括面向租户的自助上线、MFA 强制执行以及 OpenAI/Anthropic 工具使用 URL 字段包装器(为构建队列中的下一步)。完整状态表请参见 `docs/architecture/capability-status.md`。
### Kubernetes / Helm (生产环境)
```
cd infra/helm/cyberarmor
# 为你的环境编辑 values.yaml
helm install cyberarmor . -n cyberarmor --create-namespace
```
### Endpoint Agent
```
cd agents/endpoint-agent
pip install -r requirements.txt
sudo python installer.py install --server https://your-cyberarmor-server --api-key YOUR_KEY
```
## 项目结构
```
ai-protect-system-claude-4.6/
├── admin-dashboard/ # Vanilla JS admin SPA (16 views)
├── agents/
│ ├── endpoint-agent/ # Cross-platform endpoint security agent
│ │ ├── crypto/ # PQC key transport & signing
│ │ ├── dlp/ # Data loss prevention scanner
│ │ ├── monitors/ # Process, network, file, AI tool monitors
│ │ ├── platform/ # macOS, Windows, Linux integrations
│ │ └── zero_day/ # RCE guard & sandbox
│ ├── proxy-agent/ # Policy decision agent API
│ └── ros-agent/ # ROS2 robotics security agent
├── extensions/
│ ├── chromium-shared/ # Shared Chrome/Brave/Edge extension (MV3)
│ ├── edge/ # Edge-specific manifest
│ ├── firefox/ # Firefox extension (MV2)
│ ├── safari/ # Safari Web Extension
│ ├── vscode/ # VS Code extension (TypeScript)
│ ├── visual-studio/ # Visual Studio extension (C#)
│ ├── cursor/ # Cursor IDE extension
│ ├── kiro/ # Kiro IDE extension
│ └── office365/ # Office 365 add-in (Word, Excel, PPT, OneNote, Outlook)
├── scripts/
│ ├── poc/ # 15-minute URL Trust Gate PoC: install.sh, uninstall.sh, demo script, four attack pages, README
│ ├── hardening/ # Ubuntu server hardening helper
│ └── smoke-test.sh # Full-stack smoke test
├── infra/
│ ├── docker-compose/ # Docker Compose for local development
│ ├── envoy/ # Envoy proxy config + Lua filter
│ └── helm/cyberarmor/ # Kubernetes Helm chart
├── kernel/
│ ├── linux/ # eBPF monitoring programs
│ ├── macos/ # Endpoint Security system extension
│ └── windows/ # Minifilter + WFP driver
├── libs/
│ └── cyberarmor-core/ # Shared PQC crypto library
├── mobile/ # React Native iOS/Android app
├── rasp/ # Runtime Application Self-Protection
│ ├── java/ # Java agent (javaagent)
│ ├── dotnet/ # .NET middleware
│ ├── python/ # Python WSGI/ASGI middleware
│ ├── nodejs/ # Node.js express/koa middleware
│ ├── go/ # Go http.RoundTripper wrapper
│ ├── rust/ # Rust inspector
│ ├── ruby/ # Ruby Rack/Faraday middleware
│ ├── php/ # PHP PSR-15/Laravel middleware
│ └── c_cpp/ # C/C++ LD_PRELOAD interceptor
└── services/
├── agent-identity/ # AI agent identity, credentials, and delegation chains
├── ai-router/ # Unified AI provider gateway with credential vault and cost tracking
├── audit/ # Immutable PQC-signed audit log and AI action graph
├── compliance/ # Compliance engine (14 frameworks)
├── control-plane/ # Central API gateway and tenant management
├── detection/ # Prompt injection, jailbreak, toxicity, PII detection
├── identity/ # Identity provider service
├── integration-control/ # SaaS integration discovery and OAuth scope control
├── llm-mock/ # Mock LLM endpoint for local development and testing
├── policy/ # Policy engine with AND/OR groups
├── proxy/ # Transparent proxy core
├── response/ # Incident management and automated response actions
├── runtime/ # Unified AISR runtime decision API (orchestrates detection, policy, response)
├── secrets-service/ # CyberArmor control layer over OpenBao (KV, transit, key rotation)
├── siem-connector/ # SIEM output integrations
├── url-trust-gate/ # Pre-ingestion control point: canonicalizes URLs, runs SSRF-guarded safe crawl, fans out to detection for prompt-injection / promptware scoring, decides allow/warn/redact/sandbox/block, writes evidence
└── detonation-worker/ # Isolated Playwright sandbox the gate calls for deep-mode renders. Lives on a dedicated `detonation` Docker network with no route to internal services
```
## 配置
### 环境变量
| 变量 | 描述 | 默认值 |
|----------|-------------|---------|
| `CONTROL_PLANE_URL` | Control Plane 服务 URL | `http://control-plane:8000` |
| `POLICY_API_SECRET` | Policy 服务 API Key | (必填) |
| `DETECTION_API_SECRET` | Detection 服务 API Key | (必填) |
| `POSTGRES_URL` | PostgreSQL 连接字符串 | `postgresql://...` |
| `REDIS_URL` | Redis 连接字符串 | `redis://redis:6379` |
| `PQC_ENABLED` | 启用后量子加密 | `true` |
| `FIPS_MODE` | 启用 FIPS 140-3 模式 | `true` |
| `LOG_LEVEL` | 日志级别 | `INFO` |
| `AGENT_IDENTITY_API_SECRET` | Agent Identity 服务 API Key | (必填) |
| `AGENT_IDENTITY_JWT_SECRET` | 用于 Agent Token 的 JWT 签名密钥 | (必填) |
| `ROUTER_API_SECRET` | AI Router 服务 API Key | (必填) |
| `ROUTER_ENCRYPTION_KEY` | 用于提供商凭据加密的 AES-256 主密钥 | (必填) |
| `AUDIT_API_SECRET` | Audit 服务 API Key | (必填) |
| `CYBERARMOR_AUDIT_SIGNING_KEY` | 用于不可变审计条目的 PQC 签名密钥 | (必填) |
| `AUDIT_RETENTION_DAYS` | 审计日志保留期 | `365` |
| `SECRETS_SERVICE_API_SECRET` | Secrets 服务 API Key | (必填) |
`OPENBAO_ADDR` | OpenBao 服务器地址 | (必填) |
| `OPENBAO_TOKEN` | OpenBao root/service Token | (必填) |
| `OPENBAO_NAMESPACE` | OpenBao 命名空间 | (可选) |
| `OPENBAO_KV_MOUNT` | OpenBao KV 密钥挂载路径 | (可选) |
| `OPENBAO_TRANSIT_MOUNT` | OpenBao Transit 引擎挂载路径 | (可选) |
| `CYBERARMOR_ENFORCE_SECURE_SECRETS` | 在启动时拒绝不安全的默认密钥 | `false` |
| `CYBERARMOR_ENFORCE_MTLS` | 要求服务间调用使用 mTLS | `false` |
| `URL_TRUST_GATE_API_SECRET` | URL Trust Gate 服务 API Key | (必填) |
| `DETONATION_WORKER_URL` | Detonation Worker 的基础 URL(例如 `http://detonation-worker:8015`);未设置则禁用深度模式 | (可选) |
| `DETONATION_WORKER_API_SECRET` | 网关与 Detonation Worker 之间的共享密钥 | (若启用 Worker 则必填) |
| `SAFE_BROWSING_API_KEY` | Google Safe Browsing v4 Lookup API Key(可选的第二意见源;没有它网关也能工作) | (可选) |
| `SMARTSCREEN_TENANT_ID` | 用于 Microsoft SmartScreen / Defender Threat Intelligence 源的 Azure AD Tenant ID | (可选) |
| `SMARTSCREEN_CLIENT_ID` | 用于 SmartScreen 源的应用注册 Client ID | (可选) |
| `SMARTSCREEN_CLIENT_SECRET` | 用于 SmartScreen 源的应用注册 Client Secret | (可选) |
| `VIRUSTOTAL_API_KEY` | 用于 URL 信誉源的 VirusTotal v3 API Key | (可选) |
| `VIRUSTOTAL_CACHE_TTL_S` | VirusTotal 结果的进程内缓存 TTL(秒) | `3600` |
| `URL_TRUST_GATE_DETONATION_DEFAULT` | 对 `depth=deep` 请求默认运行引爆 (`on` / `off`) | `off` |
| `URL_TRUST_GATE_CRAWLER_TIMEOUT_S` | 网关安全抓取器的每次请求爬取超时时间 | `4.0` |
| `URL_TRUST_GATE_CACHE_TTL_S` | 网关上的信誉缓存 TTL | `900` |
### 身份提供商设置
有关 Microsoft Entra ID 的设置说明,请参阅 [docs/azure-app-registration.md](docs/azure-app-registration.md)。
## RASP 集成
每个 RASP Agent 在应用层拦截 AI API 调用:
```
# Python 示例(canonical)
import cyberarmor_rasp
cyberarmor_rasp.init(server="https://your-server", api_key="YOUR_KEY")
# Canonical import 为 `cyberarmor_rasp`。
# 自动拦截对 AI 端点的 requests/httpx 调用
```
```
// Node.js example (canonical export path)
const cyberarmor = require('cyberarmor-rasp');
cyberarmor.init({ server: 'https://your-server', apiKey: 'YOUR_KEY' });
// Legacy import `require('cyberarmor-rasp/legacy')` remains supported.
// Automatically patches http/https modules
```
```
// Go example
import ca "github.com/cyberarmor/rasp-go"
client := &http.Client{Transport: ca.New(config).RoundTripper(http.DefaultTransport)}
```
## 开发
### 前置条件
- Python 3.11+
- Node.js 18+
- Docker & Docker Compose
- (可选) 拥有 Helm 3 的 Kubernetes 集群
### 本地运行服务
```
# 启动基础设施
docker-compose -f infra/docker-compose/docker-compose.yml up -d postgres redis
# 启动单个服务
cd services/policy && pip install -r requirements.txt && uvicorn main:app --port 8001
cd services/compliance && uvicorn main:app --port 8006
```
### 运行测试
```
# 共享 crypto library
cd libs/cyberarmor-core && python -m pytest tests/
# Policy engine
cd services/policy && python -m pytest
# Compliance frameworks
cd services/compliance && python -m pytest
```
## 许可证
Proprietary - Gratitech Research and Charitable Endeavor Corporation - 保留所有权利。
## 支持
- 企业支持:support@cyberarmor.com
- 安全问题:security@cyberarmor.com
标签:AI代理安全, AI安全, API安全网关, Chat Copilot, CISA项目, CNSA 2.0, DLP, Docker镜像, FIPS 140-3, IOC检测, IP 地址批量处理, JS文件枚举, LLM应用防火墙, Promptware检测, SIEM集成, UML, Web内容安全评估, 人工智能安全运行环境, 企业级安全平台, 内容风控, 凭证窃取防护, 动态调试, 可视化界面, 合规管理, 后量子密码学, 多人体追踪, 大模型安全, 威胁情报, 子域名突变, 开发者工具, 提示词注入检测, 搜索引擎查询, 敏感数据保护, 数据可视化, 日志审计, 构建工具, 沙箱隔离, 测试用例, 深度内容检测, 特征检测, 策略执行引擎, 请求拦截, 身份与访问管理, 逆向工具, 防钓鱼, 零信任安全, 零信任架构, 预摄取URL信任网关