# Security

TLS, isolation, credentials, IP allowlists, two-factor authentication, roles, API keys, audit logs and how to report a vulnerability.

## Encryption in transit

- Every client connection uses TLS 1.2 or newer. Plaintext connections are refused. See [TLS](/docs/connect#tls).
- The database hosts present a wildcard certificate for their region, such as `*.us-east.db.keeldb.com`. PostgreSQL 17 direct TLS (`sslnegotiation=direct`) is supported.
- From the proxy to your database, traffic stays on KeelDB's private cluster network, where database traffic between servers is encrypted with WireGuard. The cluster's own control traffic (etcd and the Kubernetes API) uses mutual TLS.
- The console, REST API and MCP server are served over HTTPS.

## Isolation

**Today:** until we open Dedicated servers, Dedicated databases run on our shared servers with vCPU and memory reserved for them, and share that server's disk encryption key, as Free and Launch databases do (see [Plans and billing](/docs/plans-and-billing#dedicated)). The Dedicated item below describes Dedicated once its servers are open.

[//]: # "TODO(integrator): remove the Today paragraph in the commit that turns PLATFORM_LIVE.dedicatedServers on at G-8."

- **Dedicated** databases run on virtual servers of their own (in US East, at AWS in Northern Virginia), created for them and destroyed when they are deleted. No other database is ever scheduled on those servers: KeelDB's provisioner labels and taints each server for its database, and a server cannot change those marks itself. Each Dedicated database's disks are encrypted, each volume with a data key of its own that is destroyed with the volume, and its backups go to an Amazon S3 bucket that only its own access key can reach. While a Dedicated database runs on [reserved capacity](/docs/plans-and-billing#reserved-capacity) on a shared server, until its own servers are ready, it has CPU cores reserved for it alone and its own storage volume, but it shares that server and its disk encryption key with Free and Launch databases, as described for them below.
- **Free and Launch** databases run on shared servers. Each runs as its own PostgreSQL cluster with its own CPU and memory allocation, and a database and its branches share a Kubernetes namespace that holds no other customer's databases. Their disks sit on encrypted storage with one key per server. Each of them, branches included, archives its backups into a storage bucket of its own, which only a temporary access key of its own can reach; KeelDB renews that key before it expires and keeps the account's own key out of every database's namespace.
- A network policy denies all inbound traffic to that namespace except from inside it, from KeelDB's connection proxy and worker, from the cluster operator, and from metrics collection.
- Databases are never exposed directly to the internet. All client traffic goes through the KeelDB proxy, which routes by hostname.
- There is no superuser access. Your `<database>_owner` role owns your database and can read all statistics views (`pg_read_all_stats`).
- Internal roles (`postgres`, `streaming_replica`, `cnpg_pooler_pgbouncer`, `keel_admin`, `root`) can't log in through the proxy.

## Database credentials

- Each database (and each branch) gets its own password: 32 random letters and digits, generated by KeelDB.
- Passwords are stored encrypted with AES-256-GCM and shown only on request, to members whose role can view credentials. Every reveal is written to the [audit log](#audit-log).
- **Rotate a password** with **Rotate password** on the database's Overview page, or:

```bash
curl -X POST https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/operations \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "rotate_password"}'
```

A new password is generated and the old one stops working immediately. Update your apps' connection strings right after. Rotation works in any database state.

## IP allowlist

Restrict which addresses can connect to a database:

- Up to 50 entries per database, each an IPv4 or IPv6 address or a CIDR range, for example `203.0.113.4` or `198.51.100.0/24` (addresses reserved for documentation; use your own servers' addresses).
- An empty list allows all addresses. Passwords and TLS still apply.
- The proxy checks the client address before authentication, on the direct, pooler and read-only hosts. Changes apply within seconds.
- Branches copy their parent's allowlist when they are created.
- The console SQL editor, the REST `query` endpoint and the MCP `run_sql` tool are not subject to the allowlist. They are protected by your console role or API key instead. On Free they connect through the proxy with a short-lived ticket that only KeelDB's console can sign; on the other plans they connect over KeelDB's internal network.

Set it in the database's **Settings**, or replace the whole list with the API:

```bash
curl -X PATCH https://keeldb.com/api/v1/databases/k7m2x9qa4pz1 \
  -H "Authorization: Bearer $KEELDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ip_allowlist": ["203.0.113.4", "198.51.100.0/24"]}'
```

Send `[]` to clear it.

## Brute-force protection

If one IP address fails to authenticate 20 times within 10 minutes, the proxy blocks new connections from that address for 15 minutes. An IPv6 client counts as its whole /64 network, the block a single host is usually given. Blocked clients see `too many failed authentication attempts from your IP address; try again later`.

During a large attack from many addresses, the proxy may also block new clients from the attacking network (an IPv4 /24 or an IPv6 /48) that have not failed themselves. Those clients see `too many failed authentication attempts from your network; try again later`. Clients from other networks are never blocked by someone else's failures.

## Accounts and two-factor authentication

- Sign-up requires a verified email address. Passwords must be 10 to 128 characters.
- Sessions expire after 14 days of inactivity. **Settings, Security** lists your signed-in devices and lets you sign them out. Changing or resetting your password signs out your other sessions.
- **Two-factor authentication (2FA)**: turn it on under **Settings, Security** with any authenticator app. You also get single-use backup codes in case you lose the device.
- **Require 2FA for an organization**: owners can require 2FA for every member under **Settings, Organization** (you must have 2FA on your own account first). Members without 2FA are sent to set it up when they open the console, and every action other than viewing is refused until they do.
- A GitHub, Google or trusted-device sign-in asks for no code. On an account with 2FA on, such a session can read, and is asked to confirm a code under **Settings, Security** before it does anything else.
- The 2FA requirement also covers API keys: a key created by a member without 2FA can only read (`db.read`) until that member turns 2FA on. Other requests with it fail with `403 forbidden`, and the error says why. **Settings, Organization** lists those keys before you turn the requirement on and while it holds.

## Roles and permissions

Each member of an organization has one role.

| Permission | Owner | Admin | Developer | Billing |
| --- | --- | --- | --- | --- |
| View databases, metrics, backups, insights and activity | Yes | Yes | Yes | Yes |
| Create databases, change settings, branch, restore, restart, back up, fail over, cancel sessions | Yes | Yes | Yes | No |
| Delete databases | Yes | Yes | No | No |
| View connection strings, rotate passwords, run SQL, browse the schema | Yes | Yes | Yes | No |
| Create and revoke API keys | Yes | Yes | Yes | No |
| Invite and remove members, change roles | Yes | Yes | No | No |
| Payment methods and invoices | Yes | Yes | No | Yes |
| Organization settings, including the 2FA requirement | Yes | No | No | No |
| Open support tickets | Yes | Yes | Yes | Yes |

- Invitations can grant admin, developer or billing. Only an owner can make someone an owner or change an owner's role, and every organization keeps at least one owner.
- Invitations expire after 7 days.

## API keys

- Keys look like `keel_` followed by 40 random characters. The full key is shown once, when you create it. KeelDB stores only a SHA-256 hash and shows the first 12 characters so you can tell keys apart, along with when each was last used.
- **A key acts with a role.** When you create a key you choose its role (owner, admin, developer or billing), never more than your own, and you can tick fewer permissions: `db.read` (read databases, metrics, backups and jobs), `db.write` (create and change databases, branches, snapshots and settings), `db.delete` (delete databases and snapshots, turn off deletion protection; with Free on its new storage, also restore a deleted database) and `db.credentials` (reveal connection strings, rotate passwords, run SQL, read logs). Every key keeps `db.read`, because the CLI and assistants look a database up before and after they change it. A request outside them fails with `403 forbidden`.
- **A key never outlives its creator's rights.** Each request is also limited by the role its creator holds at that moment: if their role is lowered, their keys narrow at once, and when they are removed from the organization, leave it or delete their account, their keys are revoked. When an organization requires two-factor authentication, the keys of a member without it can only read.
- Create one key per integration (CI, Terraform, an AI assistant), so you can revoke one without breaking the others. Revocation takes effect immediately.
- Keep keys in a secrets manager or your CI's secret store. Never ship them in client-side code or commit them to a repository.
- An organization can have up to 25 active keys. Each key is rate limited to 120 requests per minute. See [Rate limits](/docs/api#rate-limits).

## Audit log

Each database's **Activity** tab shows its audit log: every change, who made it (a team member, the API, KeelDB, or KeelDB staff) and when. Entries are kept for 400 days.

Recorded events include creation and deletion, setting and plan changes, branches, credential reveals, SQL runs (the statement's length, its first command and a keyed hash, never its text, which can hold passwords and data), cancelled or terminated sessions, operations such as restarts, failovers and password rotations, storage growth, sleep and wake-ups, and availability incidents. Organization-level events such as API key creation and revocation, membership changes, changes to the 2FA requirement and billing events are recorded too.

## Reporting a vulnerability

Email **security@keeldb.com** with a description and steps to reproduce. Please give us reasonable time to fix the issue before disclosing it, and don't access or modify other customers' data while testing.
