Skip to content

Security Hardening ​

LLM Proxy sits between your applications and paid upstream APIs, stores provider credentials, and serves an admin console. Review these settings before exposing it to the internet.

Credential model ​

CredentialStorageNotes
API keys (sk-…)SHA-256 digestPlaintext shown once; used on /v1/* and /servers/* only. Keys are 256 random bits, so indexed SHA-256 lookup is sufficient
Console sessionsHS256 JWT, 24 h, no refresh, in an HttpOnly /api cookie/api/* only; invalidated by password, role, or deactivation changes. Unsafe cookie requests require the X-CSRF-Token double-submit header
Playground session keysHttpOnly /v1 cookie, 24 hBrowser-only transport for the console; explicit Authorization or x-api-key headers take precedence
User passwordsArgon2id (19 MiB), 8–72 chars with mixed character classesForced change for admin-created accounts; legacy bcrypt hashes are rehashed on next sign-in
Provider API keysFernet-encrypted at rest (enc: prefix)Reveal is admin-only and audited; rotating ENCRYPTION_KEY makes stored keys unreadable
JWT / encryption secretsAuto-generated, stored in the databaseProtect database backups because they contain both secrets

Edge and transport ​

ItemDefaultRecommendation
TLSTerminates at your reverse proxyAlways use HTTPS in production; see Reverse Proxy & TLS
HSTSon, max-age=31536000; includeSubDomainsKeep on; disable only for local HTTP development
Security headersnosniff, DENY, Referrer-Policy, Permissions-Policy, CSP default-src 'self' (script/style allow unsafe-inline)Sent by the app; no need to duplicate at the edge
TRUSTED_PROXIESRFC1918 + loopback + link-localSet to your actual proxy networks. This replaces the default list. Spoofed X-Forwarded-For headers from untrusted peers are ignored
Request body limit64 MiB, enforced while streaming (chunked bodies are measured as they arrive)Keep in sync with your reverse proxy's limit
CORSDisabled (empty origin list)Add only origins that need browser access

Abuse protection ​

ItemDefaultNotes
Rate limitingEnabled (in-memory)rate_limit_disabled is the master throttle switch covering rate-limit buckets, per-key RPM, both failure lockouts, and the auth failure delay. It does not disable budget caps or request size limits. The UI warns when disabled
Shared rate limitsOff until REDIS_RATE_LIMIT_ENABLED=trueRequired for multi-worker or multi-replica deployments. The memory backend keeps one window per process, so N workers allow N times the configured limit. Check GET /api/health → services.rate_limiting.backend to verify which store is active
Redis fail moderedis_rate_limit_fail_closed=trueBlocks requests when Redis errors; safer for public deployments
Login lockoutOff by default. When enabled: 5 failures / 15 min per usernameOff by default so an attacker who knows a username cannot lock out the account. Per-IP auth.login limits and the auth failure delay still apply
API-key IP lockoutOff by default. When enabled: 10 failures / 5 min per client IPOff by default because one bad client can lock out everyone behind a shared NAT or corporate egress (and in local dev, all traffic is 127.0.0.1). Enable for instances exposed to untrusted networks. Applies to /v1/* and /servers/*; the auth failure delay still applies
Model allowlist rejection403, not counted as an auth failureThe key is already authenticated, so requesting a disallowed model does not trigger IP lockout or failure delay
WebSocket quotasBudget checked before each billable turn/v1/responses re-checks the key before every response.create; /v1/realtime checks before forwarding response.create and after each completed turn. Enforcement is best-effort because spend is cached for 15 s and usage is written asynchronously, so bursts or in-flight turns can overshoot the cap
Auth failure delay100 ms ±10% jitterSlows brute-force attempts; keep enabled on public instances
Console auth bucketsauth.login 5/min, auth.setup 5/minTunable per bucket; see Server Settings → Rate Limits

Keys, roles, and tenants ​

  • viewer accounts cannot access provider, model, team, MCP, or settings APIs. Reserve admin for operators.
  • Set expiry dates, rate_limit_rpm, model allowlists, and budgets on every production key. An explicitly empty allowlist denies all models.
  • Account budgets cap total spend across all of a user's keys and can only be reset by an admin.
  • Viewers see only their own logs and usage. API keys are owner-scoped even for admins, and stored Responses are namespaced per key so tenants cannot read or delete each other's records.
  • For personal tracing, a non-admin's base_url must be a public host; internal collectors must be listed in HTTP_ALLOWED_HOSTS. Admins keep the permissive self-hosted check. Demoting an admin to viewer clears their personal tracing configuration, after which they can re-add a public collector.

Outbound media downloads ​

A client-supplied image URL is fetched by the proxy in two cases: a chat message's image_url when routed to a provider that expects inline bytes (such as Ollama), and a Responses request's input_image when bridged to a provider that does not fetch remote images. Both use the same SSRF-validated fetch:

  • Loopback, RFC1918, link-local, CGNAT, multicast, cloud metadata hosts, and URLs with embedded credentials are refused.
  • Hostnames are resolved and every returned address is checked, so a public domain pointing to a private IP is refused.
  • Up to five redirects are followed, and each hop is validated like the first. An http to https upgrade or CDN signing redirect works, while a redirect to 127.0.0.1 or a private host is blocked.
  • The response body is streamed and capped at HTTP_MAX_DOWNLOAD_BYTES (20 MiB by default), matching the per-image ceiling of mainstream vision APIs.
  • Downloads for a single request are bounded as a group: at most four run concurrently, and total inlined payloads are capped at HTTP_MAX_REQUEST_DOWNLOAD_BYTES (64 MiB by default, matching the request body limit).
  • On bridged Responses requests, a refused or failed download returns 400 naming the URL. On chat requests, the failed image part is dropped and the request proceeds.

If you use internal image hosts or split-horizon DNS resolving to private ranges, list those hosts in HTTP_ALLOWED_HOSTS to exempt them. Scheme and credential restrictions still apply.

Outbound requests ​

Every URL the proxy fetches (provider base_url, personal tracing collector, remote MCP server, web-search endpoint, or client media URL) is SSRF-checked when configured. Requests made through the proxy's shared outbound HTTP client are checked again at connect time when using the default backend: its DNS resolver rejects private-network answers, preventing DNS rebinding. Redirect targets are resolved and checked in both backends. Literal IP addresses and localhost are checked at configuration time, and HTTP_ALLOWED_HOSTS exempts a host in both places. Setting HTTP_CLIENT_BACKEND=httpx2 keeps configuration-time and redirect checks without the connect-time resolver. Remote MCP servers, smart-routing clients, and Langfuse/OTLP/LangSmith exporters use configuration-time URL checks only.

Response sizes are also bounded:

  • Buffered upstream responses are capped at HTTP_MAX_RESPONSE_BYTES (64 MiB by default); larger responses fail with 502.
  • Each line of a streamed SSE response is capped at 8 MiB.
  • An MCP tool call, prompt, or resource result is capped at 8 MiB across its content blocks (MCP_MAX_RESULT_BYTES); truncated payloads are marked so the model can tell.

MCP ​

MCP servers can run local commands and access the network, so the policy is deny-by-default:

  • Allowlist the exact commands and environment variables each server needs. Shell metacharacters in arguments are rejected.
  • SSRF protection resolves hostnames and rejects blocked IPs (loopback, RFC1918, link-local, cloud metadata, CGNAT) when a server is created or updated. This check runs at configuration time rather than at connect time. See Outbound requests.
  • Keep require_key_mcp_permissions=true so each MCP server must be explicitly granted per API key.
  • Session slots are capped per configured MCP server per worker (1000 sessions, 10 min idle) to prevent initialize loops from exhausting an endpoint.
  • Remote (streamableHttp) servers cannot be given custom auth headers; prefer stdio or a controlled network path.
  • Every MCP call is logged with masked arguments in Logs → MCP Calls.

See MCP Servers.

Logging and privacy ​

  • Request and response bodies are off by default (log_input_output). Every row still records status, tokens, cost, routing, and audit metadata, while content payloads are stored as {"_bodies_disabled": true} (including request/response bodies, upstream error bodies, and MCP/web-search arguments and results). Error classification and stack traces are kept. Turn body logging on only when needed for debugging, then turn it back off. It is a master switch: x-log-full: true cannot override it for a single request.
  • Masking is on by default; add custom field names under Sensitive keys. Masked values keep their first 3 and last 4 characters (values of 8 characters or fewer become ***). The built-in set covers Authorization, x-api-key, Cookie/Set-Cookie headers, request/response bodies, and MCP/tool arguments.
  • Sampling reduces body capture (when body logging is enabled) without losing metadata. Sampled-out bodies are stored as {"_sampled_out": true}, and x-log-full: true forces full capture for a single request.
  • Retention defaults to 30 days for logs, audit logs, and usage records. Shorten it for sensitive workloads.
  • Verify the audit chain regularly from Logs → Audit Logs → Verify Integrity and record the result. A failing chain indicates the audit history was altered.
  • There is no bulk export endpoint; treat database access as access to all logs and restrict it accordingly.

Secrets and rotation ​

ActionConsequenceProcedure
Rotate an API keyAffects only that keyCreate replacement, switch clients, delete old key
Reset a user passwordRevokes sessions; forces change at next sign-inAdmin: Team → Reset password
Rotate provider API keysNo downtimeEdit the provider (reveal is audited)

Rotating JWT_SECRET invalidates all active console sessions. Rotating ENCRYPTION_KEY makes stored provider keys undecryptable until they are re-entered. Both are auto-generated on first run; see Upgrades & Backups → Secrets: what rotation breaks for backup and migration details.

Air-gapped or privacy-strict deployments ​

  • Set UPDATE_CHECK__ENABLED=false to disable GitHub version checks.
  • Tracing is per-user and opt-in; leaving it disabled keeps request content inside your infrastructure.
  • Web search and MCP are disabled or deny-by-default until explicitly configured.

MIT licensed