Background
CrateDB is an open-source distributed SQL database for storing and analyzing large amounts of data in near real time. It is PostgreSQL-compatible and built on Lucene. A cluster is made of several nodes that store and query data together. Applications talk to it with ordinary SQL over its HTTP endpoint or over the PostgreSQL wire protocol, so standard Postgres clients and drivers work.
CrateDB has a SQL privilege system. Administrators create users and grant each one rights, for example reading one table but not another. Deployments can use this to separate tenants who share one database.
The nodes of a cluster also talk to each other over a second, internal transport protocol. It carries cluster operations such as sharing cluster state or decommissioning a node, normally on its own port. This traffic is meant for trusted peers on a private network. Version 4.8.0 added a tunnel mode that carries the same protocol over the PostgreSQL port, for logical replication, where one cluster subscribes to another.
Terms used below:
- Wire protocol is the byte-level format a client and server use to communicate.
- Privilege check is the code that asks “may this user run this statement on this table?“.
- Trust boundary is the line between code that must treat its input as untrusted and code that may assume its caller is trusted.
Summary
An ordinary database account can request a protocol switch on its PostgreSQL connection and reach the internal transport dispatcher. That dispatcher assumes it is serving a trusted cluster peer and does not apply the SQL layer’s role checks.
The proof of concept authenticated a user restricted to one table, confirmed that SQL denied access to another tenant’s data, then used the tunnel to retrieve cluster metadata and invoke node decommission. The account moved from a constrained SQL session to administrative operations without another credential or access to the separate transport port.
How the Vulnerability Works
Imagine a building with a front desk and a staff-only corridor behind it. Visitors are checked at the desk, and their badges only open the doors they are allowed through. Staff inside the corridor are trusted, so the doors there have no locks. The flaw is a door on the visitor side that says “switch to the staff corridor” and does not check whether you are staff.
In CrateDB the front desk is the SQL layer, where every statement is checked against the user’s privileges. The staff corridor is the internal transport dispatcher, which assumes every message comes from another cluster node and does no per-user checking.
The PostgreSQL connection handshake accepts a startup property named CrateDBTransport. After the user has logged in with a normal password, that property makes the server remove the PostgreSQL handlers from the connection and install the internal transport dispatcher in their place. Authentication proved who the caller is. Nothing asked whether that caller should be allowed to act as a cluster peer.
Normal client: login -> SQL statements -> privilege checks -> data
This bug: login (restricted user) -> "CrateDBTransport" -> raw internal actions -> no privilege checksFrom there the attacker’s crafted client sends internal actions directly. Examples from the proof are fetching the full cluster state, which includes other tenants’ table definitions, and asking a node to decommission itself. A normal SQL tool cannot do this, and a user who is denied access to another tenant’s table by SQL has no such limit on the tunnel. This is a missing authorization bug (CWE-862). A feature designed for trusted servers was reachable by any account that could log in.
Prerequisites
The attacker needs a valid database account and network access to the PostgreSQL listener. The test setup enabled host-based authentication and used a restricted password-authenticated user, so the result was not an unauthenticated default-configuration shortcut.
The connection requests the CrateDBTransport startup property and then speaks the internal protocol after authentication. A crafted client can send this property even if ordinary database tools do not expose it. No authorization to create a logical replication subscription was required in the test.
Attack Path
- STARTRestricted database user
- STEP 01Authenticate with the transport startup option
Password authentication identifies the caller but does not grant internal peer privileges.
MITIGATION Authorize the protocol switch separately
- STEP 02PostgreSQL handlers are replaced by internal transport
- STEP 03Send unchecked cluster actions
MITIGATION Enforce privileges at internal action dispatch
- STEP 04Read cluster metadata or decommission a node
Root Cause
PostgresWireProtocol.finishAuthentication checks the startup property and can call switchToTransportProtocol. This removes the PostgreSQL decoder and handler and installs the internal transport dispatcher on the authenticated channel.
The transport assumes a protected cluster network. Its handlers do not independently enforce the SQL privilege model. Checks in the analyzer and AccessControlImpl are bypassed when a client sends an action directly through the tunnel.
The feature was introduced for subscription and replication traffic in 4.8.0. That intended use has privilege requirements, but the startup-property path did not enforce an equivalent boundary. Database login established the caller’s identity, then the protocol switch gave that caller the standing of a trusted internal peer.
Validation
The tests used the official 6.4.5 image with a single node and two tenant tables. The restricted account could query its own table but lacked access to the other tenant’s table and cluster information through SQL.
| Operation as the restricted user | Expected boundary | Recorded result |
|---|---|---|
| SQL read of another tenant’s table | Deny missing privileges | DQL permission error |
| SQL access to the system schema | Preserve role restrictions | Access unavailable |
| Tunnel request for cluster state | Apply equivalent access checks | Full metadata response |
| Internal node decommission | Require administrative authorization | Action accepted and SQL service stopped |
The response contained markers for the other tenant’s table and column definitions. Decommission caused an administrative side effect, not just acceptance of a transport frame. The sequence passed twice from clean containers.
Impact
The demonstrated effects are cross-tenant metadata disclosure and unauthorized node shutdown. Cluster state includes table definitions, settings and repository metadata. Stored repository credentials can be exposed where those settings contain them, but the test’s markers do not prove that every deployment stores secrets there.
Unchecked dispatch also makes internal state-changing operations reachable outside the SQL privilege layer. The runtime proof used decommission. It was not a test of every internal write action or a direct dump of all table rows.
Remediation
The published advisory lists 6.4.7 and 6.5.1 as patched releases. Upgrade the appropriate branch and restrict database and cluster listeners to intended clients.
Authorization must cover the protocol switch and internal actions, not just SQL statements. Regression tests should attempt the tunnel with a restricted account and verify that SQL denials cannot be bypassed by the equivalent internal operations.