Skip to content

fix(ios): stop capped reads downloading the rest, apply query timeouts and refuse unreadable SSH host keys - #4179

Merged
datlechin merged 2 commits into
mainfrom
fix/audit-wave-3-ios
Nov 11, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/audit-wave-3-ios

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Fixes from the 2026-11-10 code audit (wave 3) for the iOS app, plus the SSH host key fix in the macOS app.

Row cap (IO-04)

  • MySQL: a lone read that passes the row cap is stopped with KILL QUERY (wave 2's killer) and the rest drained, instead of downloading every remaining row. The Mac's capped-read rule decides: one statement, a read. CALL, ... RETURNING and every write read to their end.
  • TiDB, Databend and servers before 5.0 still drain, since a kill there drops the session or does not exist.
  • SQL Server: a lone plain read aborts at the cap through the same rule; any other batch reads on, so a later write or COMMIT still runs.
  • A MySQL result that exactly fills the cap no longer says rows were left out.
  • Each capped read with rows left opens a second login for the kill; the next statement on the session waits for it.

Long text (IO-06, partly)

  • Text over 4 KB in a SQL Server, Oracle or DuckDB table can be loaded in full, edited and copied, by key.
  • Query results still hold the 4 KB preview: a key-based load reads the stored column, not what the SELECT projected.

Query timeout (IO-07)

  • PostgreSQL and Redshift set statement_timeout, Oracle uses the shared core's deadline, SQL Server sets LOCK_TIMEOUT (the Mac's mapping, which bounds lock waits only).
  • With no timeout set, iOS applies none; the Mac falls back to its 60 s default.
  • Redis, DuckDB and SQLite are unchanged: the Mac applies nothing to the first two, and on iOS SQLite's would become a lock wait Stop cannot end.

Memory trim (IO-08)

  • After a low-memory trim the page range names the rows still shown.
  • The "Results trimmed" notice ends with its page.

SSH host keys (IO-11, macOS and iOS)

  • A host key file that exists but cannot be read or decoded is an error, never an empty store: a changed key was offered as a new server to trust, and trusting rewrote the file with that one host.
  • One parser, KnownHostsFile in TableProSSHTransport, for both apps. Lines it cannot parse are kept on write; a host named only by such a line is refused.

Not done here

  • IO-06 for query results: needs a memory budget in every driver and a model change.
  • IO-09 and IO-10 (architecture).

Test plan

  • verify.sh: macOS build, HostKeyStoreTests, KnownHostsFileTests, 24 iOS suites (185 tests) and the driver suites again after review (55 tests), lint, both catalogs.
  • New: MySQLRowCapTests (row-streaming fake server: kill at the cap, DELETE ... RETURNING and CALL read to the end), MSSQLRowCapTests, LazyCellKeyTests (DuckDB end to end), NativeDriverQueryTimeoutTests (PostgreSQL fake server), KnownHostsFileTests, and cases in HostKeyStoreTests (both apps), HostKeyVerifierTests and DataBrowserViewModelTests.
  • Not run against live SQL Server, Oracle or MySQL servers: the SQL Server abort at the cap and Load full value on SQL Server and Oracle are unchecked there.
  • Reviewed by a Claude agent that did not write the change, with the security lens on IO-11.

@datlechin
datlechin enabled auto-merge (squash) November 11, 2026 01:38
@datlechin
datlechin merged commit 2955cd6 into main Nov 11, 2026
11 checks passed
@datlechin
datlechin deleted the fix/audit-wave-3-ios branch November 11, 2026 07:37
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