Security Hardening
Built-in security mechanisms
| Mechanism | Description |
|---|---|
| Encrypted upstream key storage | Each tenant has a random tenant key that encrypts upstream keys and Vertex private keys with XChaCha20-Poly1305; the tenant key is in turn encrypted with the account's own API key |
| Credential isolation | Applications hold only XSI keys; all caller credentials and client IP headers are stripped before forwarding, and upstream keys are never returned to regular accounts |
| Authentication protection | Authentication failures are counted per IP with temporary bans; invalid keys are negatively cached |
| Admission pipeline | IP, status, quota, rate limits, and resource and model allowlists are checked layer by layer |
| Tenant isolation | Keys, configuration, and pricing are isolated per tenant; account management only applies to the operator's own subtree |
| Signup abuse prevention | IP and email rate limits, progressive delays, automatic bans, and a site-wide daily quota |
| Memory protection | Core dumps are disabled at process startup |
Deployment checklist
Secrets
- The root key and database password use randomly generated values, and
docker-compose.ymlhas permissions600. - The root key is used only for administration, never for model calls or distribution to applications.
- Applications use dedicated sub-account keys, split by environment and purpose.
- If a leak is suspected, rotate the key with
POST /x-self; the old key is invalidated immediately.
Network
- Ports stay bound to
127.0.0.1, so only the reverse proxy can reach the API and console ports. - PostgreSQL and Redis are not published to host ports (the template default).
- HTTPS is enabled on every entry point.
-
TRUSTED_PROXY_CIDRScontains only your own proxy addresses, so clients cannot spoof their IP. - Block utility paths that need no public exposure at the proxy:
/x-gkey,/x-ekey/,/x-dkey/. They require no authentication, only generate and encode/decode keys, and serve no purpose for external users.
location ~ ^/x-(gkey|ekey|dkey) { return 404; }- If the configuration console is not meant for the public, restrict access to it by source IP.
- Configure your own SMTP for the mail service in
docker-compose.yml. - Keep
EMAIL_SMTP,EMAIL_AUTH, andEMAIL_PASSfor the API container as empty strings, as in the template, or set them explicitly to your own values. Do not rely on the defaults in the code. - Set
XAI_MAILto your own operations mailbox to receive notifications such as unknown models and failovers. - Welcome emails and key rotation emails contain the API key in plaintext, so make sure the mail path uses TLS.
Upstream keys
- Use
fields=summarywhen querying keys;fullmode and the sleeping/disabled lists inGET /x-confreturn plaintext. - Set
AUTO_DISABLE_KEY_STATUS=401so keys revoked by the upstream drop out of rotation automatically. - Rotate upstream keys regularly, and set usage caps in the upstream consoles as a last line of defense.
Access control
- Accounts that need quotas and rate limits enforced use Role 2 or 3 (Role 0/1 skips quota and rate limit checks).
- Set
AllowIPson production accounts; setAllowModelsandResourceson accounts distributed externally. - Keep
USER_FILTER=true. - For deployments without open signup, set
SIGN_ENABLE=false; with open signup, configureSIGNUP_ALLOW_DOMAINSorSIGNUP_DENY_DOMAINS.
Logs and errors
- Keep
LOG_ENABLE=falsein production, and enable it only briefly while troubleshooting. - For services facing end users, set
MASK_ERRORS=trueto hide upstream error details. - Redact the
Authorizationandx-api-keyrequest headers in proxy and application logs.
Data
- Copy PostgreSQL and Redis backups to another machine, and rehearse restores regularly.
- Restrict access to the
backups/directory on the host.
Reporting vulnerabilities
If you find a security issue, email [email protected]. Do not disclose details in a public issue.