Skip to content

fix(macos): stop masked values reaching MCP and the assistant, and finish the audit's partial fixes - #4178

Merged
datlechin merged 2 commits into
mainfrom
fix/audit-wave-2-macos
Nov 10, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/audit-wave-2-macos

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Fixes from the 2026-11-10 code audit (wave 2) for the macOS app: masked values leaking to external callers (AI-01), and what wave 1 (#4174) left partly done.

Masking for MCP, the assistant, Claude Agent, AppleScript and Shortcuts

  • PostgreSQL, MySQL/MariaDB and local SQLite report which table column each result column reads (PluginColumnOrigin, additive PluginKit change, kit 43). Results for external callers are masked by that origin and by name; traced origins only add masking.
  • An origin is trusted only when it names a user table. A column with no trusted origin, one read from a system schema or catalog, statistics view or SQLite shadow table, or from a statement a driver distrusts (MySQL derived tables, CTEs and executable comments; SQLite compounds and VALUES) is masked whole on a connection with rules.
  • On a connection with rules: server error text is replaced by the error code and a fixed sentence; MySQL-family plans are masked; dashboard session and slow-query text is withheld; history entries the app wrote from row data return a fixed sentence and are left out of searches; browse and export of a system table are masked whole.
  • The assistant's result context, the row inspector pane, Fix with AI and AppleScript tab results go through the same external masking.
  • Known limits, also for the docs page: a column under another name (views, copies), inference through WHERE, ORDER BY, timing or error codes, text clients or other sessions typed, engines that cannot trace columns (ClickHouse, Redis, CockroachDB, Redshift, registry drivers, SQLite over SSH), system tables kept inside a user container there, KingbaseES system schemas other than sys_catalog and sys (not measured), column names, and the person's own screens.

Drivers

  • MySQL BIT: import, Table Transfer, Object Copy and Data Compare write the number, converting between MySQL's number and PostgreSQL's or DuckDB's bit string. Table Transfer reads the source catalog before its stream opens.
  • PostgreSQL: bit, varbit and interval oids are named from the built-in table, so a fresh session's stream header no longer calls them unknown.
  • Redis: a new hash, list, set or sorted set row whose key exists is refused (built under a staging key in the same slot, then RENAMENX), instead of writing into that key.
  • SurrealDB: an edit keeps the type a field held when read, unless the field has a declared type.
  • MySQL and MariaDB sessions set TCP keepalive (60 s idle, 10 s interval, 3 probes), so a lost reply fails in about 90 s instead of hanging for two hours.
  • SQLite: PRAGMA data_version is allowed in the read-only scope, so FTS5 tables can be read there.

Editor, edits, sessions

  • Saving, closing, switching tabs, AppleScript, Save as Favorite and quit read the editor's pending text on documents over 500,000 units.
  • Parameters glued to a keyword (LIMIT:n, IN:ids) are bind parameters again; LIMIT:n becomes LIMIT $1, not LIMIT$1.
  • A pasted blank cell takes the column's default, '' in a NOT NULL text column without one, else NULL.
  • A database switch that has to reconnect is refused while the connection holds a transaction.
  • A full fetch after an expired token removes local copies of records it proves were deleted on the server.
  • Claude Agent's Ask Once approval lasts across chat turns until Forget, Revoke, Delete or Disconnect. Grant rows name the client.
    • Widened on purpose: before, each turn's token deleted its own approval, so Claude Agent asked again every message. Now one approval covers later turns of that connection. Only the agent's own mint carries the flag, and its token stays read-only and limited to the chat's connection.
  • A structure save that fails part way lists the statements that stayed applied; one inside an open transaction says a rollback undoes them.

Keychain

  • With Sync Passwords on, a read returns the newer of the synced and local copies; with it off, this Mac's own copy first.
  • The connection form no longer rewrites secrets the user did not change.

Tests changed on purpose

  • SwitchDatabasePooledConnectionTests.reconnectingSwitchReportsTheTransactionItEnded removed: the switch is now refused.
  • MaskingBridgeTests fixture reports origins; MaskingPolicyTests.externalUntracedColumnIsMasked expects whole masking; externalTableRuleMatchesTheOriginTable became externalTableRuleMatchesAnyTracedRelation.
  • SQLiteColumnOriginsTests.compoundSelectHasNoOrigins and valuesRowsHaveNoOrigins expect an all-nil list.
  • RedisStatementGeneratorTests.hashInsertKeepsJSONValues, RedisCommandParserAppStatementTests.insertsStayTyped: collection inserts are staged.
  • TableTransferServiceTests: the stub reports per-column types and records catalog and stream order.
  • KeychainItemScopeTests.readPrefersTheSelectedItem replaced by readReturnsTheNewerItem.

Not done here

  • GE-04: later edits to a row still run at its first edit's position; ordering them needs an edit log and per-row statement runs.
  • DL-02: temp tables and SET values lost on a reconnect are not reported; no driver can report them yet.
  • CS-04: the old synced iCloud Keychain copy of a Local only connection's secrets is kept, since deleting it removes it from other devices.

Test plan

  • verify.sh: build, AllPlugins, the PluginKit ABI check (additive, kit 43, minimum 19), the Unit plan, TableProCore package tests, an iOS build with its affected suites, lint and both catalogs.
  • New suites include PostgreSQLColumnOriginsTests, MySQLColumnOriginsTests, SQLiteColumnOriginsTests, MaskingExternalOverlayTests, PluginColumnOriginsTests, ImportDataSinkAdapterBitColumnTests, RedisCollectionInsertTests, MySQLSocketKeepaliveTests, SQLEditorPendingTextTests, SyncFullFetchDeletionTests, StructureRebuildPartialFailureTests, ClaudeAgentGrantSubjectTests.
  • The masking attacks were reproduced against scratch PostgreSQL 17, MySQL 8.4 and MariaDB 13 servers by the reviewers. Nothing else ran against a live server.
  • Reviewed in several rounds by Claude agents that did not write the change. AI-01, AI-03 and the Keychain changes had the security lens.

@datlechin
datlechin merged commit 90e6cd6 into main Nov 10, 2026
11 checks passed
@datlechin
datlechin deleted the fix/audit-wave-2-macos branch November 10, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant