Security

Security overview

The security model of Raft DB in one page: who can connect, how they prove who they are, what they may do, and what is not protected.

TLS exists for the MySQL, MariaDB, SQL Server and PostgreSQL client connections, and nowhere else. Configure ssl_cert and ssl_key on the front-end to turn it on; without them, and on every other link, passwords, tokens and data travel in clear text: the native binary protocol, HTTP and the Studio, UDP, replication between nodes, the messages between watchers, and the watcher's webhooks and error reports. Keep those ports on a loopback address or a private network you control, or put each link inside a tunnel (SSH, WireGuard). See TLS and encryption.

Two account systems#

Raft DB has two separate places where accounts live, because it has two kinds of front door.

raftdb-server accountsMySQL / MariaDB accounts of raftdb-mysql
Who uses themNative API clients, the Studio, the watcher, replicas, the SQL front-end itselfMySQL and MariaDB clients and drivers
Where defineduser and token settings (command line, environment, file)user lines of mysql.conf (bootstrap administrators), and CREATE USER (stored in a hidden database)
Password storageSalted PBKDF2-HMAC-SHA-256, 100,000 iterations, in memory only: derived at start from the settingThe configured password is kept in the configuration file in clear; CREATE USER accounts keep two double hashes (SHA1(SHA1(pw)), SHA256(SHA256(pw)))
PrivilegesRoles: readonly, readwrite, admin, control, optionally limited to one databaseMySQL privileges at global, database, table and column level
Changed withEditing the settings and restartingSQL: CREATE USER, ALTER USER, GRANT, REVOKE
Replicated in a clusterNo: every node must be started with the same accountsThey live in an ordinary (hidden) Raft DB database; they are not tested in a cluster, and the front-end of another node sees a change at its next login

The SQL front-end acts on the server as one raftdb-server account (raftdb_user) whatever MySQL user is connected. The server therefore sees all SQL traffic as that account; the privilege checks of MySQL accounts are made by the front-end, before statements reach the server. Anyone who can reach the server's own port with that account's password bypasses them.

What is checked where#

StepDone by
Is this MySQL user known, is the password rightraftdb-mysql (auth.rs), from the configured verifier or the stored account
May this statement run on this database, table, columnsraftdb-mysql (acl.rs), from the parsed statement, before it runs
Is this account allowed on the serverraftdb-server, by role and database (auth.rs)
Is this node allowed to writeraftdb-server, by fence (epoch and lease) in a cluster

Defaults that protect you#

  • raftdb-server with no arguments listens on loopback only. The single profile refuses a non-loopback address.
  • The first start creates an admin account with a random 192-bit password in a file only its owner can read, rather than an open server. open must be asked for on purpose.
  • raftdb-mysql listens on 127.0.0.1:3307 by default and refuses to start without a user.
  • The watcher's status page listens on loopback only.
  • Fatal-error reports go nowhere unless you set a URL or a command.
  • The Studio's page is served with a strict content policy; cors and allow-remote-servers are off.

What is not protected#

  • Traffic on every link except the front-ends' client connections with TLS configured.
  • A failed login on the MySQL side has no delay and no lockout; the raftdb-server login answers a failure after a fixed 250 ms, which slows guessing but is not a lockout.
  • Authentication randomness (salts, tokens) comes from the operating system's randomness through SipHash over a counter and the clock; a vetted CSPRNG is still to be added before wider exposure.
  • Data at rest: files are not encrypted. Use disk encryption.
  • Accounts in a cluster are not replicated.
  • There is no audit log of logins or statements. RAFTDB_MYSQL_TRACE logs statements (with their passwords) and is not an audit tool.

Pages in this chapter#