// PART 09
Security model
The security model is layered, and each layer has one job: the directory answers “who is this user”, Vault answers “what may this process touch”, config.csv answers “how should this bot behave”, and the session layer ties every bot action to an authenticated user.
The layers
| Layer | Holds | Never holds |
|---|---|---|
.env |
VAULT_ADDR, VAULT_TOKEN, VAULT_CACERT only |
any service credential |
| Zitadel (directory) | user accounts, organizations, applications, MFA, SSO | service passwords, API keys |
| Vault/OpenBao | database, storage, cache, mail, LLM keys, encryption keys, per-bot LLM settings | user identities |
config.csv |
bot behavior: models, thresholds, feature flags | plaintext credentials (use vault:path/key) |
| Sessions | user ↔ bot binding; every bot action rides a user session | bot credentials (bots have none) |
Encryption: what is and is not provided
General Bots does not provide platform-wide encryption at rest. There is
no PostgreSQL TDE, no OtterIO SSE/KMS registration, no Valkey RDB encryption
and no LUKS/TPM provisioning in the shipped image. TLS is used in transit
between components, and field-level encryption exists at exactly three
production call sites — attendance content, external Drive content, and
session content (botsecurity_crypto::encryption::encrypt_field; keys derive
from the master encryption key in botcoresession). Anything beyond that is a
storage-layer decision (disk encryption, encrypted backups).
Hardening surfaces the CLI owns
./botserver security status # firewall, fail2ban, caddy — read-only report
./botserver security fix # applies the hardening steps (firewall, fail2ban, caddy)
The security subcommand ships with the security Cargo feature and reports
each target’s state plus an overall pass/partial result. Runtime guardrails
enforced by the code: every inbound channel webhook fails closed when its
secret is unset (#2142), all state-changing endpoints require CSRF protection
(Bearer-token API endpoints are the stateless exemption), security headers
(HSTS, CSP, X-Frame-Options, nosniff, Referrer-Policy,
Permissions-Policy) go on all responses, and rate limiting defaults are
General 100 req/s global, Auth 10 req/s on login endpoints, API 50 req/s per
token, with WebSocket message limits.
Failure containment
- No panics in production:
unwrap/expect/panic!are forbidden outside tests; errors propagate asResultand HTTP clients receive sanitized errors (log_and_sanitize), never raw strings. - Command execution goes through
SafeCommand(binary allowlist, argv validation, scrubbed environment); rawCommand::newis a review blocker. - SQL identifiers pass
sql_guard(sanitize_identifier,validate_table_name). - Container isolation: Incus instances per component; a compromised component does not share a filesystem with the others. Names are derived, never taken from user input.
What to review first on a new deployment
.envcontains only Vault variables (cat .env— two or three lines)../botserver security statusis green.conf/vault/init.jsonischmod 600and copied off-host.- The webhook secrets for every enabled channel are set in Vault.
- The admin password from first boot was changed.