Skip to content

Data Security

Mohammad Rasoul Kazemi edited this page Nov 26, 2026 · 2 revisions

Data Security

This page answers four questions about the data: what is encrypted, where secrets live, what is hashed, and who can read or write what. The wider security design is in Security Model; cross-cutting concepts are in Architecture Crosscutting Concepts. Nothing here is a certification; the limits that still hold are on Limitations and Known Issues.

What is encrypted

Data Protection
Connections between PostgreSQL instances Every managed instance runs with ssl = on (TLS 1.3, the server certificate, ssl_ca_file the cluster CA, ssl_crl_file the revocation list). pg_hba.conf starts with hostssl ... cert rules for each server, and the sharding extension's outgoing connections use sslmode=verify-full.
Server-to-server control-plane traffic The internal HTTP API runs with mutual TLS under the cluster CA (ECDSA P-256), on its own port, authenticated by client certificate only, with a revocation list.
Panel and REST API The panel listens on loopback by default; for other addresses use TLS (see Configuration).
Ledger publication Off by default. With --ledger-publication-tls-cert and --ledger-publication-tls-key it serves TLS; without them it is plain HTTP and the console warns. Its content is public by design and is protected by signatures, not secrecy.
Ledger signing key files PBKDF2-HMAC-SHA256 and AES-256-GCM, when --ledger-key-passphrase-file is set. Without a passphrase file the key files are in clear text, like the CA key, and kingresd logs a warning.
Anchor credentials Files <ledger-keys-dir>/anchor/<target id>.json with the same sealing as the signing keys.
Staged transfer files (table and database exports, uploads) Sealed segment by segment with AES-256-GCM under a per-file key that is wrapped by a master key kept outside the staging directory (-transfer-key-file, default <data-dir>/transfer.key). A staged file can be read and downloaded only by the role that made it.
Data at rest in PostgreSQL files The sources describe no encryption at rest of table or WAL files. A cold copy of /var/lib/kingres holds the CA key and the service credentials and must be treated as a secret.

Where secrets live

Secret Location Never in
Certificate authority key <data-dir>/pki/ca.key, mode 0600, on the leader; sealed copies exist only when escrow is on (next row) PostgreSQL, API answers
Escrow copies of the CA key Off until switched on. When on, the leader seals the CA key and the revocation list to every server that hosts a ready standby of the map group, so a new leader can go on issuing certificates. A server that holds a copy can become the certificate authority, so its disk is as sensitive as the leader's PostgreSQL, API answers
Master key of the transfers <data-dir>/transfer.key (option -transfer-key-file), never inside the staging directory the staging directory, API answers
Server private keys the server that generated them (server.key, 0600); only the public key and the certificate are stored in kingres_cp.server the system database
Service role password <data-dir>/service-credentials, mode 0600; service connections use the instance's unix socket TCP traffic, logs
One-time setup token <data-dir>/setup-token, mode 0600, only while the node is uninitialised; only the file name is logged logs
User and panel passwords not known to the cluster: roles are synchronised as SCRAM-SHA-256 verifiers computed in kingresd; a panel account is a PostgreSQL role logs, audit log
Cluster secret of the sharding extension table kingres.cluster_secret on each node (forced row level security, no privilege for any role, not dumped by pg_dump); a superuser, and whoever can read the node's files, WAL or a base backup, can read it. kingres.rotate_secret() replaces it on every node in one two-phase transaction the catalog snapshot every user can read, logs (the statement that installs it is not logged with its argument)
Ledger server signing keys encrypted files under --ledger-keys-dir (default <data-dir>/ledger/keys), mode 0600 in a 0700 directory, on the leader and on the servers that run shard group 0, or an external signer program PostgreSQL, task rows, logs, audit, API answers
Passphrase of the key files a file, mode 0600, named by --ledger-key-passphrase-file the environment, the command line
Client private keys (ledger attestations) the client's own custody; the server never sees them everything on the server
Public keys, checkpoints, tiles, events kingres_cp and the publication; public n/a

Back up the key directory and the passphrase separately, off the cluster (Backup Restore and PITR).

What is hashed

What How
Ledger rows, transactions, blocks, chain identity SHA-256 over tagged inputs in RFC 6962 trees (hash format version 1); see Data Model Ledger
Ledger transparency logs SHA-256 tiles of height 8, signed checkpoints (Ed25519, C2SP signed notes)
Key ids ledger_client_key.key_id is the first 16 bytes of the SHA-256 of the public key; ledger_signing_key.fingerprint is the SHA-256 of the public key in hex
Anchors TSA and OpenTimestamps receive the SHA-256 of the checkpoint text; ledger_anchor.payload_sha256 stores it
Node-to-node sessions the token kingres_shard.forward_token is HMAC-SHA-256(secret, "kingres-forward-v2" NUL role NUL database NUL target node id), checked in constant time
Distributed transaction names a tag of the first 16 hex digits of an HMAC of the name with the cluster secret, so the extension resolves only prepared transactions that carry a valid tag
Passwords SCRAM-SHA-256 verifiers
Time-partition policies timepart_policy_seal.fingerprint seals what a policy says, so a row restored from a dump is not trusted
Columnar chunks a CRC-32C of every stored chunk and of the stripe footer (error detection, not security)

Who can read or write

  • The ledger tables can be written only by the extension's code; the guard refuses every other statement, whatever the role inherits or owns, except a superuser acting as itself with kingres_ledger.allow_manual_write, which leaves a record. Ledger tables other than blocks are not readable by PUBLIC (ledger_entry and ledger_client_key are among those revoked); ledger_blocks is readable by PUBLIC so block headers can be exported. Read functions for the publisher (ledger_head, ledger_blocks_entries) are granted to the service role.
  • A database can be dropped together with its ledger by every role that has the privileges of its owner or can SET ROLE to it; ledger_status lists such roles.
  • The panel roles are kingres_admin > kingres_ops > kingres_readonly > kingres_stats; every operation in openapi.yaml names the minimum role (x-required-role). Anything that changes keys, targets, settings, client keys or policy needs kingres_admin.
  • A hot standby can verify the ledger, check digests and build and check proofs; it cannot enable tables or build blocks.
  • Every administrative action through the REST API is written to the audit log; the audit file and the kingresd log never contain statement text, passwords or tokens. Credentials of anchor targets are never in an audit entry. See Monitoring and Alerts.
  • Within one cluster every server is fully trusted by every other (the control-plane README says so in plain words).

Privacy of the publication

The publication holds hashes only (design 4.9). A third party learns that a chain exists (its chain_id), the number of blocks, the time of each block, the number of transactions per block and the previous-block hash chain, so it learns when the database is busy and roughly how busy, and from the number of chains of one aggregate the number of shard groups of a database. It does not learn table names, user names, row contents, row hashes, the database name (hidden in the aggregate id) or shard group ids. An operator who does not want the activity pattern published keeps the listener off and exports bundles on demand.

Sources

Clone this wiki locally