leochong/Lateos

GitHub: leochong/Lateos

安全优先设计的 AWS serverless AI 代理平台,通过架构选择从根源消除传统 AI 代理的攻击面。

Stars: 0 | Forks: 0

# Lateos **安全设计优先的 AI 个人代理平台** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/) [![AWS CDK](https://img.shields.io/badge/AWS-CDK-orange.svg)](https://aws.amazon.com/cdk/) [![Security: Bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) ## 📋 目录 - [什么是 Lateos?](#what-is-lateos) - [Lateos 存在的原因](#why-lateos-exists) - [快速开始](#quick-start) - [架构概览](#architecture-overview) - [安全规则](#security-rules) - [文档](#documentation) - [贡献](#contributing) - [许可证](#license) ## 什么是 Lateos? Lateos 是一个基于 AWS serverless 架构构建的**开源 AI 个人代理**,以**安全作为基础设计原则**。与传统 AI 代理事后添加安全措施不同,Lateos 通过架构选择从根本上消除了整类漏洞。 **核心特性:** - 🔒 **Serverless 优先**:无监听进程 = 无远程代码执行攻击面 - 🛡️ 通过 CI/CD 强制执行的 **8 条不可变安全规则** - 🔍 **Prompt 注入检测**,包含 21 种模式和 43 个测试用例 - 🔐 **限定范围的 IAM 角色**:每个技能 Lambda 一个角色,无通配符 - 💰 **成本保护**:预留并发 + 紧急开关防止账单失控 - 📖 **开源**:MIT 许可,完全透明 **官方网站:** [lateos.ai](https://lateos.ai) **代码仓库:** [github.com/leochong/Lateos](https://github.com/leochong/Lateos) ## Lateos 存在的原因 在 **2026 年 1 月**,**Clawdbot/Moltbot 安全危机**暴露了 AI 代理安全的系统性失败: - 从暴露的管理面板泄露了 **1,247 个 API 密钥** - 因被盗的 Anthropic 凭证造成 **超过 50,000 美元的欺诈损失** - **892 个实例**存在命令注入漏洞 - 通过未经清理的 WebSocket 输入实现**远程代码执行** - 通过未签名的社区技能进行**供应链攻击** **Lateos 的创建是为了证明 AI 代理从第一天起就可以是安全的。** 每一个 OpenClaw/Moltbot CVE 都在 Lateos 中通过**架构设计被消除**: | OpenClaw 漏洞 | 根本原因 | Lateos 预防措施 | |------------------------|------------|-------------------| | **CVE-2026-25253 (RCE)** | WebSocket server with no sanitization | 无 WebSocket server(仅 API Gateway) | | **CVE-2026-24763 (容器逃逸)** | 特权 Docker 容器 | Serverless Lambda(Firecracker microVMs) | | **CVE-2026-25593 (命令注入)** | 技能中的 Shell 执行 | 规则 4:禁止 Shell 执行 | | **CVE-2026-25475 (令牌盗窃)** | 环境变量中的明文密钥 | 规则 1:仅限 Secrets Manager | | **ClawHavoc (供应链)** | 未签名的社区技能 | 无技能市场(仅 CDK 部署) | | **ClawJacked (身份验证绕过)** | Localhost 信任 | API Gateway + Cognito(无 localhost) | **完整 CVE 分析:** [docs/CVE-CHECKLIST.md](docs/CVE-CHECKLIST.md) ## 快速开始 ### 前置条件 - **Python 3.12**(Lambda 运行时和 CDK 必需) - **AWS CDK v2**(`npm install -g aws-cdk`) - **Docker**(用于 LocalStack 测试) - **AWS 账户**(用于部署 - 本地开发不需要) ### 本地开发设置 ``` # 克隆 repository git clone https://github.com/leochong/Lateos.git cd Lateos # 创建 Python 3.12 virtual environment python3.12 -m venv .venv312 source .venv312/bin/activate # 安装 dependencies pip install -r requirements.txt -r requirements-dev.txt # 安装 pre-commit hooks (强制执行安全规则) pre-commit install pre-commit install --hook-type commit-msg # 验证 setup cdk synth # Should synthesize all 5 stacks pytest tests/ -v # Run test suite (73 tests pass, 1 skipped) ``` ### 部署到 LocalStack(推荐的第一步) ``` # 启动 LocalStack docker-compose up -d # Bootstrap 并部署所有 stacks 到 LocalStack cdklocal bootstrap cdklocal deploy --all # 验证 deployment aws --endpoint-url=http://localhost:4566 dynamodb list-tables aws --endpoint-url=http://localhost:4566 lambda list-functions ``` ### 部署到 AWS ``` # 配置 AWS credentials aws configure --profile lateos-prod # 运行 account baseline 安全检查 python scripts/verify_account_baseline.py --profile lateos-prod # 部署所有 stacks cdk deploy --all --profile lateos-prod --require-approval never # 验证 deployment aws stepfunctions list-state-machines --profile lateos-prod ``` **部署指南:** [docs/deployment-guide.md](docs/deployment-guide.md) ## 架构概览 Lateos 使用 **AWS Step Functions Express Workflows** 来编排 Lambda 函数管道,每个函数都具有限定范围的 IAM 角色和预留并发。 ``` ┌─────────────────────────────────────┐ │ User Request │ │ (Cognito JWT Required) │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ API Gateway (REST API) │ │ - Cognito Authorizer (MFA enforced)│ │ - Throttling: 100 req/s burst │ │ - Request validation: max 4KB body │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ Step Functions Express Workflow │ │ (5-minute timeout) │ └──────────────────┬──────────────────┘ │ ┌─────────▼─────────┐ │ VALIDATOR Lambda │ │ - 21 inj patterns│ │ - Threat score≥2 │ │ = block │ │ - Concurrency: 10│ └─────────┬─────────┘ │ [sanitized_message] ┌─────────▼─────────┐ │ ORCHESTRATOR │ │ - Extract user_id│ │ - Audit log │ │ - Concurrency: 10│ └─────────┬─────────┘ │ [user_context] ┌─────────▼─────────┐ │ INTENT CLASSIFIER │ │ - Rule-based │ │ - Future: Bedrock│ │ - Concurrency: 10│ └─────────┬─────────┘ │ [intent] ┌─────────▼─────────┐ │ ACTION ROUTER │ │ - Routes skills │ │ - Built-in: help │ │ - Concurrency: 10│ └─────────┬─────────┘ │ ┌─────────▼─────────┐ │ Choice State │ │ (Skill Routing) │ └──┬──┬──┬──┬───────┘ │ │ │ │ EMAIL CAL WEB FILE SKILL SKL FET OPS │ │ │ │ Gmail GCal HTTP S3 OAuth API req per-user isolation └──┴──┴──┴───────┐ │ [skill_result] ┌─────────▼─────────┐ │ OUTPUT SANITIZER │ │ - RULE 8: Redact │ │ - Bedrock Guards │ │ - Concurrency: 10│ └─────────┬─────────┘ │ [sanitized_response] ┌──────────────────▼──────────────────┐ │ User Response (200 OK) │ └─────────────────────────────────────┘ Supporting Infrastructure: DynamoDB Tables (KMS encrypted): - conversations (user_id partition) - agent_memory (user_id partition) - audit_logs (user_id partition) - user_preferences (user_id partition) Cost Protection: - AWS Budgets: $10/month threshold - Kill switch Lambda (disables API Gateway) - CloudWatch alarms + SNS alerts Secrets Manager: - lateos/{env}/gmail/{user_id} - lateos/{env}/google_calendar/{user_id} - (per-user OAuth tokens, automatic rotation) ``` **详细架构:** [docs/architecture.md](docs/architecture.md) ## 安全规则 Lateos 通过 pre-commit hooks 和 CI/CD 强制执行 **8 条不可变安全规则**: ``` RULE 1: No secrets in code, environment variables, or config files. ALL secrets go through AWS Secrets Manager. No exceptions. RULE 2: No wildcard (*) actions or resources in any IAM policy. Every Lambda has a scoped execution role. Period. RULE 3: No public S3 buckets, no public endpoints without Cognito. (WAF deferred to Phase 2 per ADR-011) RULE 4: No shell execution in any Lambda or skill. os.system(), subprocess, eval(), exec() are banned. RULE 5: All user input is sanitized for prompt injection before touching the LLM. Never pass raw user input to Bedrock. RULE 6: No cross-user data access. Every DynamoDB query is scoped to the authenticated user_id partition key. No exceptions. RULE 7: Every Lambda has reserved_concurrent_executions set. No function can scale to infinity and run up costs. RULE 8: No plaintext logging of tokens, passwords, API keys, or PII. Use structured logging with field redaction. ``` **执行机制:** - **Pre-commit hooks**:`detect-secrets`、`gitleaks`、`bandit`(安全 linter) - **CI/CD pipeline**:任何安全规则违规都会导致失败 - **测试**:43 个 Prompt 注入测试用例,73 个测试的安全回归套件 **完整威胁模型:** [docs/threat-model.md](docs/threat-model.md) ## 文档 ### 安全 - **[SECURITY.md](SECURITY.md)** — 漏洞报告策略,安全特性 - **[PENTEST-GUIDE.md](PENTEST-GUIDE.md)** — 渗透测试指南 - **[docs/CVE-CHECKLIST.md](docs/CVE-CHECKLIST.md)** — OpenClaw CVE 映射 - **[docs/threat-model.md](docs/threat-model.md)** — 威胁分析和缓解措施 ### 开发 - **[CONTRIBUTING.md](CONTRIBUTING.md)** — 安全优先的贡献指南 - **[docs/architecture.md](docs/architecture.md)** — 详细的系统架构 - **[docs/deployment-guide.md](docs/deployment-guide.md)** — AWS 部署步骤 - **[DECISIONS.md](DECISIONS.md)** — 架构决策记录 (ADRs 001-016) ### 运维 - **[LAUNCH-CHECKLIST.md](LAUNCH-CHECKLIST.md)** — 发布前验证清单 - **[STATUS.md](STATUS.md)** — 当前构建状态和阶段进度 ## 贡献 我们欢迎贡献!请在提交 PR 之前阅读 [CONTRIBUTING.md](CONTRIBUTING.md)。 **安全研究人员:** 请参阅 [PENTEST-GUIDE.md](PENTEST-GUIDE.md) 获取测试指南。 **报告安全漏洞:** 请参阅 [SECURITY.md](SECURITY.md) — 请勿公开 issue。 ## 许可证 [MIT 许可证](LICENSE) ## 联系方式 - **一般问题:** [GitHub Discussions](https://github.com/leochong/Lateos/discussions) - **Bug:** [GitHub Issues](https://github.com/leochong/Lateos/issues) - **安全:** [security@lateos.ai](mailto:security@lateos.ai)(见 [SECURITY.md](SECURITY.md)) - **项目负责人:** Leo Chong (CISSP, AWS Cloud Practitioner, CCNA Security, NREMT) - **邮箱:** [leo@lateos.ai](mailto:leo@lateos.ai) *由 Anthropic 的 Claude AI 协助构建。* *Lateos 证明了 AI 代理可以通过设计实现安全。每一行代码都优先考虑安全而非便利。*
标签:API Gateway, AWS, Bedrock Guardrails, CDK, Cognito, DPI, DynamoDB, IAM, KMS加密, Lambda, PE 加载器, ProjectDiscovery, Python, Streamlit, 个人助理, 人工智能代理, 安全架构, 安全设计, 成本控制, 数据保护, 无后门, 私有化部署, 访问控制, 逆向工具, 防御规避