Skip to content

Security

ConceptExplains how it works and why.

What protects the gateway, the console and your callers, and how it is verified.

Callers

  • Authentication: API keys (hashed at rest, per-key allowed source addresses, rotation with overlap, immediate revocation), access tokens the gateway issues to your applications (OAuth 2 client credentials; RS256 tokens signed with an environment key sealed by your master key and verified without a network call; refresh tokens that work once, a reuse after 30 seconds ending the session; revoked secrets and sessions refused from the next request), JWTs from any OpenID Connect or OAuth 2 provider (JWKS fetched and cached, algorithms allow-listed, none refused, scopes and claims required), HTTP Basic. Bound together they are alternatives, and only the policy a credential is addressed to may refuse it. See Authentication at a glance.
  • Protection: threat protection (JSON and XML structure limits, DTD and entity expansion refused, injection patterns in path, query, headers and body), request validation against JSON Schema written by hand or taken from an imported OpenAPI document (body, query, headers and path parameters; a schema may refer only to its own definitions, never to a file or URL), request size limits, IP allow and deny lists, CORS, method allow lists. Every regular expression written into an API (a custom threat pattern, a schema pattern, a path rewrite, a route's header match, one in a jq program) is priced before it reads a value: a value too long for it to read in bounded time is refused or fails, never read for minutes and never let through unchecked.
  • Limits: rate limits (sliding window, token bucket, fixed window), concurrency limits, plan quotas per subscription. Exact on one node, verified under load.
  • The caller's address behind a proxy: with trust_x_forwarded_for the gateway takes the last X-Forwarded-For entry (the one your proxy appended), and only from a loopback, private or link-local peer; list a CDN in trusted_proxies. A client cannot name itself. Identity headers (X-Apinx-*) a client sends are dropped on every request.
  • Cached answers are kept per caller unless a policy says vary_by_consumer: false: per authenticated identity and per credential the request carries on to the backend (a bearer token behind an API key, a session cookie), and a caller the gateway cannot name is not cached at all. The backend's Vary is honoured and Vary: * is never stored; a route's canary is left out; a HEAD never fills the cache; keys that long queries would make are not stored.
  • Keys and tokens are fetched over https; a plain-http JWKS or token URL beyond this machine needs allow_http: true.
  • Refusals are uniform: a stable code, a message, a remediation, a correlation id. No stack traces, no server banners, no backend hop-by-hop headers leak to callers.

The console and Admin API

  • Roles: administrator, editor, viewer; administrator-only operations are checked before any request body is parsed. Importing a configuration, changing the flow hooks and making a change to them live (by publishing, deploying or rolling back the shared configuration) are administrators' acts; so is saving a secret reference (env:, file:, vault:). Request tracing is an administrator's setting, except in Apinx Cloud, where an editor starts and stops the two-minute trace window (headers masked, no response kept); a window with request bodies stays an administrator's.
  • Sessions end after an hour without activity (console.session_idle_timeout) and after twelve hours whatever happens (console.session_ttl); a request extends the idle timer. Changing your password ends your other sessions; an administrator's reset ends them all.
  • Viewers read the configuration and the traffic, but not the configuration as an exportable document, not the bodies callers sent, and not the audit log.
  • Every route of the console port needs a session except liveness, readiness and metrics; the process and gateway configuration dumps need the administrator role, and the gateway configuration is shown with every secret redacted.
  • Five failed sign-ins lock the account for fifteen minutes; a wrong password gets the same answer whatever the account's state, and while the account is locked the right password gets that answer too, so guessing reveals nothing and the lock cannot be waited out with a password already found. Ten failed sign-ins from one client address inside fifteen minutes, across any accounts, answer 429 APX-CP-0028 with Retry-After until the window ends, before any password is checked (Apinx Cloud's sign-in, code, resend and forgotten-password routes share the same rule, and an account is sent at most five emails of a kind an hour at anyone's request). At most eight password checks run at a time (each costs 32 MiB), sign-in takes JSON only, and bodies over 4 MiB are refused rather than cut short.
  • Disabled users cannot sign in and their sessions end.
  • Apinx Cloud ties each console session to the browser and network that signed in. Another browser ends the session at once (audited, the person emailed). A new network, and risky actions, ask for a code emailed to the person. The cookie is __Host-apinx_session, which a sibling host cannot plant. People list and end their sessions under Preferences. See Console sessions in Apinx Cloud.
  • Session cookie HttpOnly, SameSite, and Secure when console.public_url is https or console.secure_cookies is set; CSRF header required on every state-changing request from a cookie session; bearer tokens for scripts.
  • Strict Content-Security-Policy (no inline or evaluated script), frame-ancestors 'none', X-Frame-Options, nosniff, Cross-Origin-Opener-Policy, Permissions-Policy, and Strict-Transport-Security (one year, the console's own name) whenever the session cookies are Secure.
  • Provider sign-in fails closed when the provider's metadata offers no asymmetric signing algorithm; jwt and oauth2 bindings tolerate at most five minutes of clock skew, skip RSA keys under 2048 bits in a key set, and accept at most 64 keys in one.
  • A PostgreSQL connection string without sslmode gets sslmode=require when the server is not this host (pgx's own default, prefer, would fall back to clear text); a loopback address, a socket, or an explicit sslmode is left as written.
  • Optional sign-in through your OIDC provider (Authorization Code with PKCE), role mapping by claim, allowed e-mail domains, just-in-time users, break-glass local administrator.
  • Every change is audited with before and after values; secrets never appear in the audit.

The console assistant

The assistant is off until it is switched on, and is built so that what it can do is limited by construction rather than by its instructions:

  • Nothing that writes. Its tools only read: manual sections, API definitions, upstream settings, shared flows, the flow hooks and defaults, policy descriptions and error codes. It has no web search or fetch tool and nothing that saves, sends, deploys or deletes. A change reaches the draft only when a person clicks Insert into editor or Add to draft, through the same checked Admin API calls as the rest of the console, with that person's role.
  • As the person asking. Every lookup runs with the asker's organization, environment and role; a viewer's assistant sees what a viewer sees.
  • Secrets stay. Before a question, its context or a lookup's result leaves for the Claude API, the server replaces with «redacted» every field marked secret, upstream and callout credentials, keys, passwords, private keys, and every value shaped like a bearer token, JWT, apk_ key or card number, whatever the browser sent. Secret references (env:NAME) pass; their values never do.
  • No traffic. No request, response, header, body, IP address, trace or access-log line is ever sent.
  • Configuration is data. Names, descriptions and jq programs are written by people; the assistant is told to treat them as data, and an instruction hidden in them has no tool to act with.
  • The AI key stays on the server: sealed with the master key at rest (or given in the environment as APINX_ASSISTANT_API_KEY), write-only in the API, and absent from exports, logs, traces, the audit and error messages. Master-key rotation re-seals it.
  • Limits: 1,000 characters a question, 20 questions per person an hour, four lookups per question, 20 messages per conversation, 2,000 tokens per answer, and 32 answers at once per instance. Every question is an audit record (who, conversation, outcome); conversations are kept 30 days and visible only to their author.
  • Nothing is added to the gateway's request path: the assistant runs beside the Admin API, with its own HTTP client and timeouts.

Secrets at rest

Every secret in the configuration (API key pepper, backend credentials, JWT shared secrets, identity-provider client secrets) is encrypted with a data key, itself wrapped by your master key from an environment variable, a file, Vault Transit or a KMS command. Secrets are absent from exports, traces and logs. Rotation of both key layers is supported without downtime and covers every sealed value, the sign-in client secret included. A data key that a rotation replaced is kept for a day and then deleted, once nothing stored is under it. Starting with the wrong master key is refused with a clear message. Several instances over one database must share one configured master key; in cluster.mode: ha a generated key is refused at start.

A secret may also be a reference (env:NAME, file:/path, vault:path#field; on premises only, never in Apinx Cloud, where the environment and the disk are the platform's) resolved on the gateway host when the configuration is applied. References are an operator's choice: only administrators save them, a reference already in place may be kept by anyone, and the resolver never reads the gateway's own APINX_* variables, its master-key or configuration files, or /proc, /sys and /dev.

Verification

Run on every push in CI:

Check What it proves
govulncheck No known vulnerability reachable from the code
16 fuzz targets Every parser reachable from a caller (paths, routing, JSON and XML inspection, JWT, API keys, jq inputs, previews, imports) survives random input without a crash or a broken safety check
OWASP API Security Top 10 suite Every Admin API operation (read from the published description) refuses anonymous and forged sessions; viewers cannot change anything; editors cannot do administrators' work; no secret or hash leaves the API; unknown fields are refused; oversized bodies are refused; set-up cannot be reclaimed; headers, CSP and error bodies are as specified
Race detector, both database engines Concurrency-safe on Linux; the same suites on SQLite and PostgreSQL
Browser suite with accessibility checks Every screen passes WCAG 2.1 A/AA automated checks and fails on any CSP violation

The full report of the last review is docs/SECURITY-REVIEW.md in the repository.

Reporting a vulnerability

Please report privately to the maintainers rather than in a public issue. Include the version (apinx version) and steps to reproduce.