A security-hardening pass on the write-safety gate and the HTTP transport, from a full-repo
audit. Read the breaking changes first — the HTTP transport now requires a token.
Security fixes
-
A dry-run can no longer permanently commit via a stacked statement. Previously,
execute_write_query(sql="DELETE FROM t; COMMIT;", dry_run=true)sent both commands over
the driver's simple-query protocol; the embeddedCOMMITended the dry-run's wrapping
transaction before it could roll back, so the change was committed for real while the tool
reportedrolled_back: true— bypassing the wholemode → dry-run → yolo → user_consent
gate. The write path now rejects multi-statement SQL before executing. -
Dry-run grants are scoped to the MCP session. A dry-run preview under one session no
longer authorizes a commit of the identical statement from a different client. Under the
httptransport a single server process serves many clients; a grant made by one is now
invisible to the others.stdio(one client per process) is unaffected. -
The
http/SSE transport now requires authentication. It previously served every tool,
includingexecute_write_query, on127.0.0.1:8000with no credential — any local process
could drive writes. Every request must now carryAuthorization: Bearer <token>; the token
is minted on first start, printed to the terminal, and persisted owner-only at
~/.db-conn-mcp/http-token. Requests without a valid token get401; requests whoseHost
header isn't loopback get403(a DNS-rebinding defense).stdiois unaffected.
Breaking / Behaviour changes
-
--transport httpclients must now send an auth token. After upgrading, an HTTP/SSE
client that worked before will get401 Unauthorizeduntil you configure it with the
headerAuthorization: Bearer <token>, where<token>is printed at server startup and
stored at~/.db-conn-mcp/http-token. Clients connecting from a non-loopbackHostare
refused with403.stdioclients (the default) need no changes. -
execute_write_querynow rejects SQL containing more than one statement. If you relied
on sending several;-separated statements in one call, split them into separate calls;
you will otherwise get a sanitizedValueError(Multiple SQL statements are not allowed; submit a single statement.). Semicolons inside string literals, dollar-quoted bodies, and
comments are fine — only actual statement boundaries are rejected.