// PART 09
Security architecture
Security in General Bots is a set of enforced mechanisms in the request path and the script sandbox, not a checklist aspiration. This page inventories them; the adjacent pages cover authentication, RBAC/secrets and compliance in depth.
The enforcement inventory
| Mechanism | What it does | Where |
|---|---|---|
| Auth middleware | Bearer JWT / session cookie verification; anonymous allow-list; everything else 401 | main_module/server/run_axum_server.rs, botsecurity-auth |
| CSRF | double-submit token on state-changing requests; Bearer calls exempt | botsecurity-auth/src/csrf/ |
| Rate limiting | governor-based, per class: 100 req/s default, 10 req/s on auth surfaces |
botsecurity-auth/src/rate_limiter.rs |
SafeCommand |
binary allowlist, argv validation, scrubbed environment for every process spawn | botsecurity-core/src/command_guard.rs |
| SQL guards | identifier sanitizing + table-name validation before dynamic SQL | botsecurity-core (sql_guard) |
| Error sanitizer | internal error detail logged, safe message returned (log_and_sanitize) |
botsecurity-core |
| Upload policy | request-body caps (Drive 100 MiB, KB import 50 MiB, filename 180 chars) | botsecurity-core/src/upload_policy.rs |
| Script sandbox | loop caps, script timeout, string/array caps, API rate limits (HTTP 429) | BASIC host |
| Consent gate | per-user action classes for agent-initiated app actions | botconsent |
| Webhook signature gates | Meta X-Hub-Signature-256, Bot Framework JWT — fail closed |
channel crates |
| Security headers | CSP, HSTS, X-Frame-Options, nosniff, referrer policy on responses | middleware |
The no-panic rule is part of this list: any unwrap/panic! in production
crashes a process serving every session, so error paths propagate through
Result and are tested.
Tenancy and isolation
- Per-user/per-bot scoping is enforced at the handler layer: session,
drive bucket, KB collections and product data all resolve from the verified
identity, never from caller-supplied headers.
X-User-IDis correlation logging, not identity. - Drive has no public bucket; bytes leave only through revocable share links, revoked by any mutation of the object.
- Containers isolate the platform services; Incus is spawned only through
SafeCommand, and container names are derived, never taken verbatim from input.
Security bulletin program
The authoritative advisory channel is the security bulletin, not the community forum. For the public track record and recognition:
- RFC 9116 security.txt — canonical machine-readable reporting contact;
Preferred-Languages: pt-BR, en. - SECURITY.md — scope, acknowledgement in ≤ 3 business days, triage in ≤ 10, 90-day embargo and supported versions.
- Status and incident history — resolved advisories with dates, severity and affected versions.
- Hall of fame — opt-in credit for reporters; no bug bounty, reward budget 0.
Dependency and code hygiene
| Practice | Rule |
|---|---|
cargo audit |
weekly; findings become issues |
| Exact pins | critical crypto/security dependencies use exact versions |
Cargo.lock |
tracked for application crates |
No #[allow] |
fix the code; lint suppressions are forbidden |
| No hardcoded secrets | Vault paths; secret files live outside the repository |
| No secrets in prose | internal IPs and tokens never enter logs, docs or code |
What is not claimed
- The platform does not encrypt the database at rest wholesale; a narrow
set of fields is encrypted via
encrypt_field, and the docs say so. - No WAF is bundled; TLS termination and header hygiene are, WAF rules are an external concern.
- Compliance frameworks (SOC 2, ISO 27001) are control mappings, not certifications — see Compliance, consent, and audit for what the components actually provide.