Give the store's reader only the columns a module declares readable, never a secret, so a query cannot read the controller's signing key (hq issue 337)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds postgres, sent nowhere; no bus step; 2 wait(s) for a person; every machine composes with the change as it did without (4 of 4 …
mesh/repo-check pass: its merge-check.sh passed

mesh_store_reader held pg_read_all_data, so every caller of mesh-store.query
and postgres_query could read every column the store holds: the signing key
nodes trust, sealed secrets, password hashes. The reader now holds no role;
each minute, on every database, its memberships are revoked and its grants
brought to what the consumer's contribution lists under readable, minus any
column or table whose name says it holds a secret. Before a statement runs,
the reader's own session is asked which secret columns it can read and the
statement is refused if any; a statement naming a known secret table is
refused before it is sent.
This commit is contained in:
jochen
2026-10-08 21:43:15 +02:00
parent 7b307a06b7
commit 4f44bf1eb5
9 changed files with 1215 additions and 19 deletions
@@ -65,7 +65,17 @@ func Tools(pg *Client) []stdio.Tool {
return []stdio.Tool{
listTool(pg, "postgres_list_databases", "List the databases on the postgres server, with their on-disk size."),
queryTool(pg, "postgres_query", "postgres_query",
"Run a read-only SQL query against a named database, as a login that can read every table and change nothing."),
"Run a read-only SQL query against a named database, as a login that changes nothing and reads only the "+
"columns the database's module declares readable — never a key, secret, token or password (hq issue 337). "+
"postgres_reader_grants says what it may read."),
{
Name: "postgres_reader_grants",
Description: "What the store's reader — the login every query runs as — may read in each database, as the last " +
"pass made it: the columns each module declares readable, what was refused because its name says it holds a " +
"secret, what was declared but is missing, what was revoked, and any secret column it can still read " +
"(exposed; queries there are then refused). Names only, never values. (r)",
Run: func(map[string]any) (any, error) { return pg.LastReaderReport(), nil },
},
{
Name: "postgres_retire_database",
Description: "Take one database out of service on purpose: rename it to <name>_deleted_<date> and lock its owner's login. " +
@@ -93,6 +103,7 @@ func Tools(pg *Client) []stdio.Tool {
},
},
listTool(pg, Seat+".databases", "Every database the store holds, with its on-disk size."),
queryTool(pg, Seat+".query", "query", "One read-only statement against one database the store holds."),
queryTool(pg, Seat+".query", "query", "One read-only statement against one database the store holds, reading only what that database's module "+
"declares readable and never a key, secret, token or password (hq issue 337)."),
}
}