Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.

Security

Model

  • A fresh database has no users and is open: anyone who can reach an endpoint can do anything. This keeps local development frictionless.
  • Creating the first user turns authentication on for every endpoint and makes that user an administrator. From then on every connection must authenticate before any operation other than a ping.
  • Users have roles; roles have privileges on tables. Privileges are checked per statement, before execution, on the native protocol, the PostgreSQL endpoint, Studio and the CLI’s remote mode. A process with filesystem access to the database directory (the CLI in embedded mode, holadb users) is always an administrator: protect the directory.
  • Authentication is re-checked on every request, not once per connection. A connection opened while the database was open is cut off (28000 on the PostgreSQL endpoint, Unauthorized on the native one) as soon as the first user exists; a user whose roles change sees the new privileges at the next request; a dropped user’s session ends at its next request, on every endpoint, including after AUTH.json was restored from a backup.

Users and roles

CREATE USER ann WITH PASSWORD 'at-least-8-characters' [ROLE readonly, app];
ALTER USER ann WITH PASSWORD 'new-password';       -- admins, or ann herself
DROP USER [IF EXISTS] ann;                          -- the last admin cannot be dropped
CREATE ROLE app;  DROP ROLE app;
GRANT app TO ann;  REVOKE app FROM ann;
GRANT SELECT, INSERT ON orders TO app;
GRANT ALL ON ALL TABLES TO app;
REVOKE UPDATE ON orders FROM app;
SHOW USERS;  SHOW ROLES;  SHOW GRANTS [FOR ann];

Built-in roles (fixed): admin (everything), readwrite (SELECT, INSERT, UPDATE, DELETE on all tables), readonly (SELECT on all tables).

Privileges: SELECT, INSERT, UPDATE, DELETE, DDL (create, drop and alter tables and indexes), ADMIN (everything, including user management, engine-level operations and shutdown). A privilege is granted on one table or on ALL TABLES. UPDATE/DELETE with a WHERE also need SELECT. SHOW TABLES and transaction control need nothing. Privileges are re-resolved at the next request after any change to users or roles: a grant or revoke applies to live sessions at their next statement. On the PostgreSQL endpoint a statement the user may not run is refused at Parse (before Describe could reveal columns, and before a bind error could reveal whether the table exists), with SQLSTATE 42501.

Offline: holadb users <dir> create|passwd|drop|grant|revoke|list|roles. Passwords never go on the command line (--password <p> is refused: it would show in process listings); use --password-stdin or the HOLADB_PASSWORD environment variable.

Passwords

Passwords are never stored or logged. Each user has a SCRAM-SHA-256 verifier (PBKDF2-HMAC-SHA-256, 50,000 iterations, random 16-byte salt). Authentication is SCRAM-SHA-256 on both protocols: the password never crosses the wire, and the server proves it holds the verifier (a rogue server cannot harvest passwords). An unknown user gets the same response as a wrong password, and the SCRAM challenge it receives carries the same iteration count and salt length as a real user’s. Minimum length 8, maximum 1024. All randomness (salts, nonces, Studio tokens) comes from the platform CSPRNG (getrandom); if it is unavailable the operation fails rather than falling back to a weaker source.

Login failures are backed off per user and client address: 250 ms after the first failure, doubling with each consecutive failure up to 30 s; a success resets it. Inside the window a login of that user from that address is refused before any exchange, and again at the point where the password proof would be evaluated (Busy natively, 28000 on PostgreSQL), so exchanges started before a failure do not get evaluated after it; one proof per user and address is evaluated at a time. Twenty failures from one address inside 30 s, whatever the user names, block that address for 30 s. Consequences to know: a client that fails on purpose can keep one user name from logging in from its own address (for example root from 127.0.0.1); it cannot keep other users or other addresses out. There is no permanent account lockout. Password hashing is PBKDF2-HMAC-SHA-256 with 50,000 iterations (SCRAM); user names and passwords are compared as given (no Unicode normalisation), so use the same form everywhere.

With users defined, a connection that has not authenticated within --handshake-timeout-ms (default 10 s) of being accepted is closed, whether it is silent or sends a byte now and then; a refused connection (the limit of --max-connections is reached) is answered away from the accept loop. A PostgreSQL connection holds at most 1,024 named prepared statements and as many portals.

Network

TLS

--tls-cert PEM --tls-key PEM serve TLS (rustls: TLS 1.2 and 1.3, no unsafe code) on both endpoints:

  • native protocol: a client that starts a TLS handshake gets TLS, one that sends a plaintext frame gets plaintext — unless --require-tls, which refuses plaintext with an Unauthorized error frame;
  • PostgreSQL protocol: SSLRequest is answered with S and the connection upgraded, so sslmode=require / verify-ca / verify-full work with psql and libpq drivers; with --require-tls a plaintext startup is refused with 28000;
  • over TLS, SCRAM is bound to the server certificate (SCRAM-SHA-256-PLUS, tls-server-end-point): a man in the middle with a valid certificate still cannot relay a login. psql negotiates it automatically (channel_binding=require to insist); the Rust, Python and TypeScript SDKs and holadb-migrate always bind over TLS; a TLS client that announces binding support but does not bind is refused.

Clients always verify the server certificate chain and host name: against a CA file when given, the system / Mozilla roots otherwise. There is no “insecure” mode and no silent fallback to plaintext: a client asked for TLS either gets verified TLS or an error. SDK URLs: holadbs://host:port with ?ca=/path/ca.pem and ?servername=name; the Rust client Client::connect_tls; holadb-migrate honours sslmode and sslrootcert in the PostgreSQL URL (require always verifies, like verify-full).

Bootstrap and rotation: issue the server certificate for the host name clients will use (localhost for a local setup), from a private CA whose certificate you distribute to clients as ca.pem, or from a public CA. Keep the key 0600. To rotate, write the new files and restart the server (the files are read at start); clients that trust the CA need no change, clients that pin the old certificate must receive the new one.

Without --tls-* both endpoints are plaintext: bind them to 127.0.0.1 or a private network. Query text and results are in clear on a plaintext connection; credentials never are (SCRAM).

Limits

Each endpoint admits at most --max-connections concurrent connections (default 256); the next one is refused deterministically (Busy on the native endpoint, 53300 on PostgreSQL) instead of queueing or exhausting the process. A statement still collecting rows after --statement-timeout-ms (default 30 000; 0 disables) is cancelled (57014 / statement timeout), and the session continues. Before a connection has authenticated, a frame larger than 64 KiB (native) or a startup packet larger than 10 000 bytes / a pre-authentication message larger than 64 KiB (PostgreSQL) is refused from its length alone, so an anonymous peer cannot make the server allocate.

Files

Every file HolaDB creates for a database, a backup, a write-ahead-log archive or a restored database is created 0600, and every directory 0700 (Linux / Unix), whatever the process umask: they hold table data, log records and password verifiers. Files that existed before keep their mode; if you copy a backup with other tools, keep the modes. AUTH.json and the audit log are 0600 as well.

Slow-statement warnings and audit records carry the statement with every string literal replaced by '?' (passwords included); numbers are kept. The table and column names of a statement do appear in the log.

What a user can see: any authenticated user can list every table with its row count (SHOW TABLES) and the roles and their grants. Table-level privileges govern reading and writing rows, not knowing that a table exists.

holadb users … --password-stdin reads the password from standard input and cannot switch the terminal’s echo off: pipe it in or use HOLADB_PASSWORD. A password inside a SQL statement given to holadb query (CREATE USER … PASSWORD '…') is part of the command line: use holadb users or the shell instead.

Studio

Studio has no login of its own: it uses the credentials it was started with for every request. The URL names the user only (holadb studio holadb://user@host:port); the password comes from the HOLADB_PASSWORD variable, --password-file <file> or --password-stdin. A URL that contains a password is refused, and the credentials are tried once at start. Studio listens on a loopback address only and refuses any other: to use it from another machine, forward the port (for example ssh -L 7480:127.0.0.1:7480 host). A holadbs:// URL connects to the database with TLS (--tls-ca <file> for a private authority). The page is served with a content security policy that allows only its own script and style. Every launch mints a random token, embedded in the page and required in the X-HolaDB-Studio header of every /api/ request, so a cross-site page or form cannot drive it. A request whose Host is not Studio’s own address (localhost, 127.0.0.1, [::1] or the bound address, with or without the port) or whose Origin is foreign is refused with 403: a page on another name that resolves to Studio’s address (DNS rebinding) gets nothing, not even the page. Anyone who can open the page on that machine runs SQL with Studio’s credentials: start it with a user that has only the privileges the work needs.

Management endpoint

/health, /ready and /metrics (--metrics ADDR) answer loopback peers only unless --metrics-allow-remote is given, and then without authentication: put it behind your own access control. Without that option a request must name the endpoint by a loopback name or address in its Host header. A request head has two seconds as a whole; when sixteen requests are in progress the oldest is cut off, so stalled connections do not turn the probes into errors.

Test hooks

The fault-injection hooks the test suites use (HOLADB_FAULT_* variables) are compiled into test builds only. A release build ignores those variables: the code that would read them is not in the binary.

Audit

--audit-log PATH records logins, failures, denials, user and role changes, schema changes and shutdowns as JSON lines. See Observability.

Reporting

Report a suspected vulnerability privately, as the repository’s SECURITY.md describes. Do not open a public issue for it.