Authentication và credential
CaberOS tách operator authentication khỏi external-service credential. Operator session kiểm soát management API; credential mã hóa cho phép gateway gọi provider, MCP và messaging platform mà không đưa plaintext vào agent config hoặc API response thông thường.
Operator authentication
Phần tiêu đề “Operator authentication”Release hiện tại có một security role. Authenticated operator quản lý mọi agent, provider, memory, document, integration, trace và backup. Chưa có tenant isolation, per-agent authorization hoặc RBAC.
Password hash bằng bcrypt và salt tự sinh. First launch seed:
username: adminpassword: adminAccount có must_change_password; đổi ngay trước khi expose gateway ngoài loopback. Đổi password tạo operator-audit record.
Session token
Phần tiêu đề “Session token”Login tạo token random từ 32 random bytes, chỉ lưu SHA-256 hash trong database, gắn operator/expiry, cập nhật last_seen_at bounded và xóa session khi logout. Session hết hạn sau bảy ngày.
Browser dùng cookie agentos_session với HttpOnly, SameSite=Lax và max age bảy ngày. Desktop dùng:
Authorization: Bearer <session-token>Giữ desktop gateway ở loopback và bảo vệ OS account vì process local có thể lấy bearer token từ storage/memory.
Authentication boundary
Phần tiêu đề “Authentication boundary”Hầu hết /api cần authenticated operator. Ngoại lệ là /health readiness và external webhook dùng webhook secret. OAuth callback validate pending flow state. CORS chỉ cho Vite/Tauri origin; CORS không thay authentication.
Credential inventory
Phần tiêu đề “Credential inventory”| Secret | Storage | API thường trả |
|---|---|---|
| Operator password | Bcrypt hash | Không |
| Session token | SHA-256 hash | Raw token lúc login |
| Provider API key | Fernet ciphertext | has_key |
| MCP credential | Fernet ciphertext | Metadata |
| MCP OAuth token | Fernet ciphertext | Status metadata |
| Channel bot token | Fernet ciphertext | has_token |
| Webhook secret | Plaintext database field | has_webhook_secret |
| Fernet key | Local secret.key |
Chỉ full backup/export |
Prompt và MEMORY.md |
Plaintext DB/filesystem | Operator authenticated có thể đọc |
CaberOS không encrypt toàn bộ database hoặc application directory.
Fernet secret store
Phần tiêu đề “Fernet secret store”First use tạo Fernet key tại AGENTOS_SECRET_KEY_PATH, mặc định development:
data/secret.keyDesktop override path vào application-data directory. CaberOS cố enforce mode 0600. Fernet bảo vệ credential field khỏi người chỉ có database; process có database và key vẫn decrypt được.
Key loss và compromise
Phần tiêu đề “Key loss và compromise”Mất key làm provider/MCP/OAuth/channel credential không decrypt được; nhập lại hoặc reauthorize. Nếu key bị copy, revoke/rotate ở upstream vì thay local key không revoke token. Product chưa có automatic re-encryption rotation workflow.
Provider và MCP credential
Phần tiêu đề “Provider và MCP credential”Provider key được decrypt lúc model request; agent chỉ lưu provider ID/model. MCP decrypt credential ở mediated execution time rồi render environment/header:
{ "SERVICE_API_KEY": "{{credential_value}}"}Rendered secret không nằm trong model-controlled args. Local stdio server nhận environment và chạy như local code; chỉ cài server đáng tin.
OAuth
Phần tiêu đề “OAuth”Flow tạo pending state, mở authorization URL, nhận loopback callback, reject state mismatch, đổi code, lưu access/refresh token mã hóa và persist token replacement khi refresh. Pending flow timeout sau năm phút và mất khi gateway restart. Review OAuth scope ở provider.
Channel webhook
Phần tiêu đề “Channel webhook”Bot token được mã hóa; webhook secret lưu plaintext để constant-time comparison. Route nhận X-Webhook-Secret, X-Bot-Api-Secret-Token hoặc query webhook_secret. Public webhook phải có secret mạnh, TLS, rate limit và platform signature nếu có. Header an toàn hơn query vì query có thể vào log.
Backup
Phần tiêu đề “Backup”Full export gồm agentos.db, secret.key, agent home, MEMORY.md, workspace và attachment. Archive chứa cả ciphertext lẫn key nên phải xem như credential/private data. ZIP không được CaberOS encrypt; lưu trong encrypted volume/backup.
Logs và trace
Phần tiêu đề “Logs và trace”Gateway log rotate bounded; run trace/audit có message, args, result, URL và filename. Trước khi share log/trace, inspect toàn file, xóa token/path/private data và revoke credential có thể đã lộ.
Deployment guidance
Phần tiêu đề “Deployment guidance”Desktop: bind 51718 vào 127.0.0.1, bảo vệ OS login và disk encryption, không share data directory. Docker/remote: đổi default password, HTTPS reverse proxy, không publish backend trực tiếp và bảo vệ volume/env/log.
Incident checklist
Phần tiêu đề “Incident checklist”- Revoke upstream token.
- Disable agent/channel/MCP.
- Replace credential hoặc OAuth lại.
- Search trace, message, workspace, log và backup.
- Rotate webhook/session credential.
- Review audit.
- Xóa hoặc encrypt backup lộ.