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_certandssl_keyon 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 accounts | MySQL / MariaDB accounts of raftdb-mysql | |
|---|---|---|
| Who uses them | Native API clients, the Studio, the watcher, replicas, the SQL front-end itself | MySQL and MariaDB clients and drivers |
| Where defined | user and token settings (command line, environment, file) | user lines of mysql.conf (bootstrap administrators), and CREATE USER (stored in a hidden database) |
| Password storage | Salted PBKDF2-HMAC-SHA-256, 100,000 iterations, in memory only: derived at start from the setting | The configured password is kept in the configuration file in clear; CREATE USER accounts keep two double hashes (SHA1(SHA1(pw)), SHA256(SHA256(pw))) |
| Privileges | Roles: readonly, readwrite, admin, control, optionally limited to one database | MySQL privileges at global, database, table and column level |
| Changed with | Editing the settings and restarting | SQL: CREATE USER, ALTER USER, GRANT, REVOKE |
| Replicated in a cluster | No: every node must be started with the same accounts | They 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#
| Step | Done by |
|---|---|
| Is this MySQL user known, is the password right | raftdb-mysql (auth.rs), from the configured verifier or the stored account |
| May this statement run on this database, table, columns | raftdb-mysql (acl.rs), from the parsed statement, before it runs |
| Is this account allowed on the server | raftdb-server, by role and database (auth.rs) |
| Is this node allowed to write | raftdb-server, by fence (epoch and lease) in a cluster |
Defaults that protect you#
raftdb-serverwith no arguments listens on loopback only. Thesingleprofile refuses a non-loopback address.- The first start creates an
adminaccount with a random 192-bit password in a file only its owner can read, rather than an open server.openmust be asked for on purpose. raftdb-mysqllistens on127.0.0.1:3307by 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;
corsandallow-remote-serversare 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-serverlogin 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_TRACElogs statements (with their passwords) and is not an audit tool.