Security for Operators
This is the practical security runbook for KafClaw operators.
1. Baseline Deployment Rules
- Run KafClaw as a non-root user.
- Keep default bind on loopback unless you explicitly need remote access.
- If remote access is enabled, always set
KAFCLAW_GATEWAY_AUTH_TOKEN. - Keep bot workspace and work repo isolated from sensitive host paths.
- Treat the host as production: patched OS, firewall, no shared admin accounts.
2. Required Configuration
Minimum hardened remote setup:
export KAFCLAW_GATEWAY_HOST=0.0.0.0
export KAFCLAW_GATEWAY_PORT=18790
export KAFCLAW_GATEWAY_DASHBOARD_PORT=18791
export KAFCLAW_GATEWAY_AUTH_TOKEN='<long-random-token>'
export KAFCLAW_TOOLS_EXEC_RESTRICT_WORKSPACE=true
Provider keys should be set from environment variables, not committed config files.
3. Token Handling
KAFCLAW_GATEWAY_AUTH_TOKEN is a shared bearer token for direct API clients.
Operational policy:
- Generate with high entropy (>= 32 random bytes).
- Distribute through your secret manager only.
- Never paste tokens in chat, tickets, or docs.
- Rotate immediately if exposed.
- Rotate on schedule (for example, every 30-90 days).
4. Access Control Model
- External senders are constrained by policy tiering.
- Keep WhatsApp/bridge allowlists tight.
- Use room/account session scopes to avoid cross-tenant leakage.
- Keep default-deny behavior for unknown senders where supported.
5. Runtime Hardening Checklist
Before go-live:
kafclaw doctorpasseskafclaw statusshows expected providers/channels- Gateway auth token configured for non-localhost deployments
- Work repo path and workspace path are correct and isolated
- Backups configured for
~/.kafclaw/timeline.db - Log retention and access controls defined
- Incident owner and escalation path defined
6. Monitoring and Incident Response
Watch for:
- Unexpected spikes in token usage.
- Unknown sender activity.
- Suspicious or repetitive high-risk tool attempts.
- Repeated auth failures on gateway endpoints.
Immediate response playbook:
- Rotate gateway auth token.
- Disable affected channel integrations.
- Restrict tool surface (temporary deny/allow tightening).
- Snapshot logs and timeline DB for investigation.
- Restore service with staged re-enable of channels/tools.
7. Backup and Recovery
Back up at minimum:
~/.kafclaw/timeline.db~/.kafclaw/config.json(sanitized in secure storage)- Workspace identity/soul files if operationally required
Test restore regularly on a clean host.
8. Operator Commands
./kafclaw status
./kafclaw doctor
./kafclaw doctor --fix
./kafclaw security check
./kafclaw security audit --deep
./kafclaw security fix --yes
Use these as part of daily operations and after any security-relevant change.
9. Skills and OAuth Security Notes
- Prefer
skills.scope=selectedfor least-privilege skill exposure. - Use
skills.runtimeIsolation=auto(orstrictwhen container runtime is guaranteed). - When using
strict,kafclaw security checkvalidates thatdocker/podmanis actually usable by the current operator user. - OAuth skill tokens are encrypted at rest with local tomb-key management by default (
~/.config/kafclaw/tomb.rr), with optional keyring/file backends. doctor --fixmoves sensitive env keys into tomb-managed encrypted storage and scrubs them from~/.config/kafclaw/env.- Security events and install decisions are chained into immutable-style audit logs under
~/.kafclaw/skills/audit/. - For deployment-specific skill operations and remediations, refer to: