Skip to main content

Security

Zerq is designed for enterprise environments where security, compliance, and auditability are requirements — not afterthoughts.

Encryption at rest​

All sensitive credential values are encrypted using AES-256 before storage in MongoDB. The encryption key is provided via the ENCRYPTION_KEY environment variable and never stored in the database.

This means that even with direct database access, credential values (API keys, passwords, certificates, connection strings) cannot be read without the encryption key.

Encryption in transit​

All gateway traffic should be served over HTTPS (TLS 1.2+). For production deployments:

  • Terminate TLS at the ingress layer (nginx, AWS ALB, etc.)
  • Use certificates from Let's Encrypt or your internal CA
  • Enable HTTP Strict Transport Security (HSTS) headers

Authentication layers​

Zerq has separate authentication for each surface:

SurfaceAuthentication method
Management UI / APIOIDC (OpenID Connect) via Keycloak or any OIDC provider
API GatewayClient profiles: token, JWT, OIDC, or mTLS
Developer PortalMagic link email authentication
MCP GatewaySame as API Gateway client profiles
MCP ManagementSame as Management API (OIDC)

What the Developer Portal exposes​

Developer portal users are external API consumers, so portal responses are built from a public view of each collection (name, description, base path, last update) and of each published endpoint (name, description, path, methods, path and query parameters, request and response schemas and examples, example status code, streaming). Upstream URLs, target paths, collection and proxy headers, credential IDs, transformations and workflow definitions stay in the management API, and the portal's OpenAPI download leaves out upstream headers without resolving env-var values.

Rich-text descriptions​

Proxy (endpoint) descriptions are rich text, stored as HTML. The management console (collection page, proxy review step) and the Developer Portal (endpoint details) sanitize a description every time they show it, so markup stored through the API cannot run in a reader's browser:

  • Kept: what the description editor produces: paragraphs, headings, lists, quotes, code, line breaks, bold, italic, underline, strikethrough, highlight, text colour and alignment, links, and images.
  • Links must be absolute http, https, mailto or tel URLs; they open in a new tab with rel="noopener noreferrer". Other links (for example javascript:) lose their target and stay as text.
  • Images must come from an http(s) URL or an embedded data:image/... (PNG, JPEG, GIF, WebP, AVIF, BMP); other images are dropped.
  • Removed: scripts, event-handler attributes (onerror, onclick, ...), frames, forms and form controls, svg, math, style and link elements, embedded objects, ids and data-* attributes, classes other than the editor's own, and every inline style except text colour, highlight colour and alignment.

The stored value is not rewritten: the management API returns the description as it was saved. Any other client that renders a description as HTML must sanitize it too.

Role-based access control (RBAC)​

The management API enforces four roles. They are separate tiers, not a hierarchy: each route accepts the roles of one tier only, so a person needs every tier they use (map the same identity-provider role into several of the variables if that is what you want).

RolePermissions
Viewer (OIDC_VIEWER_ROLES)Read-only access to configuration, request logs and metrics. Credential secret values are never returned
Modifier (OIDC_MODIFIER_ROLES)Create, update, and delete resources; run workflow tests; reveal stored credential secrets for editing (audited)
Auditor (OIDC_AUDITOR_ROLES)Read and export audit logs and verify their integrity (and nothing else)
Admin (OIDC_ADMIN_ROLES)Delete single request log and AI log entries (audited). Admin does not include the other tiers

Credential secrets (passwords, API keys, client secrets, private keys, connection strings, profile tokens) are write-only for every role. Only the modifier role can reveal a stored value (POST /api/v1/credentials/:id/reveal, POST /api/v1/clients/:clientId/profiles/:id/credentials/reveal), and every reveal is audited. See Credential visibility by role.

Roles are assigned in your OIDC provider (Keycloak) and validated from JWT claims on every management request. A user with only the Auditor role can review all audit logs but cannot modify any configuration.

IP allowlisting​

Each client Profile can define an IP allowlist. Requests from IPs not in the allowlist are rejected with 403 Forbidden.

Supports:

  • Individual IPs: 192.168.1.100
  • CIDR ranges: 10.0.0.0/24
  • Multiple entries (comma-separated)

mTLS (Mutual TLS)​

For the highest security client authentication, use mTLS. The client presents a certificate during the TLS handshake, which Zerq validates against a configured CA certificate.

mTLS provides:

  • Cryptographic client identity (cannot be spoofed)
  • No shared secrets — uses PKI
  • Certificate expiry enforcement
  • Recommended for machine-to-machine in regulated environments

OIDC profiles can additionally require RFC 8705 certificate-bound access tokens — the bearer token itself is cryptographically tied to the caller's certificate, so a stolen token can't be replayed without the matching private key. This is separate from the mtls auth type above and requires authorization-server support (e.g. Keycloak's "OAuth Mutual TLS Certificate Bound Access Tokens" client setting).

→ See Authentication Methods · OIDC certificate-bound tokens

Secrets from environment variables​

Credential values can reference environment variables using $ENV_VAR_NAME syntax:

API Key: $PAYMENTS_API_KEY
DB Password: $DB_PASSWORD

The reference string is stored in the database; the actual value is resolved at runtime from the gateway's environment. This enables:

  • Integration with secret managers (HashiCorp Vault, AWS Secrets Manager, Kubernetes secrets)
  • Secrets never appear in database backups or UI exports
  • Rotation by updating the environment variable and restarting the gateway

Env-var backed collection headers are resolved only when the gateway sends a request upstream. OpenAPI exports show them as a ${VAR} reference and never contain the value.

Credential rotation​

API tokens for client profiles can be rotated at any time from the management UI:

  1. Open the Profile
  2. Click Rotate Token
  3. The old token is immediately invalidated

For certificates and OAuth2 credentials, update the credential record with the new value.

Rate limiting as a security control​

Rate limits protect your backend from abuse, DoS, and runaway scripts:

  • Short-term rate limits prevent burst attacks
  • Long-term quotas prevent sustained over-usage
  • Per-client enforcement ensures one bad actor can't affect others

Audit trail​

All platform configuration changes are recorded in the audit log:

  • Who made the change (actor identity from OIDC token)
  • What was changed (resource type, resource ID)
  • When (timestamp)
  • From where (IP address)
  • What was submitted (request body)

No role can change or delete audit entries through the API or console. Only retention (AUDIT_LOG_RETENTION_DAYS) removes them, and changes made directly in the database break the hash chain. Deleting a request log or AI log entry (admin role) is itself recorded in the audit log.

Security hardening checklist​

For production deployments:

  • Generate a unique, random 32-byte ENCRYPTION_KEY
  • Use TLS everywhere (gateway, management API, MongoDB, Redis)
  • Run the gateway process as a non-root user
  • Use Kubernetes network policies to restrict pod-to-pod traffic
  • Set up MongoDB authentication and TLS
  • Configure Redis with a password and TLS
  • Set CORS_ALLOW_ORIGINS to your specific frontend domains (not *)
  • Enable IP allowlists on client profiles for sensitive APIs
  • Use mTLS for machine-to-machine clients in regulated environments
  • Rotate encryption keys and tokens on a schedule
  • Review audit logs regularly
  • Set up alerting on 4xx/5xx rate spikes (potential attacks)
  • Configure log retention to meet compliance requirements