Skip to content

fix(safe-mode): classify grid browse sentinels as reads - #4397

Merged
datlechin merged 4 commits into
mainfrom
fix/tagged-browse-classified-write
Nov 22, 2026
Merged

datlechin merged 4 commits into
mainfrom
fix/tagged-browse-classified-write

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • QueryClassifier graded the opaque grid browse/search/count sentinels five engines build (BIGQUERY_BROWSE:/_COMBINED:/_FILTER:/_SEARCH:, SPANNER_BROWSE:, ELASTICSEARCH_SEARCH:, TYPESENSE_SEARCH:, ETCD_RANGE:/ETCD_COUNT:) as .write: BigQuery and Spanner had no classifier case, and the Elasticsearch, Typesense and etcd cases parse an HTTP verb or command, not the tag.
  • At Read-Only Safe Mode the gate denies an effective write, so MCP browse_table and the grid's Fetch All failed with "Cannot execute write queries" on these engines (macOS: BigQuery MCP browse_table blocked in Read-Only Safe Mode #4385, reported on BigQuery).
  • Recognize each engine's read sentinel as .safe, the way memcached, bigtable, qdrant, weaviate and firebase already do. Only an exact registered tag prefix reads as a read; real SQL, real writes and destructive statements keep their tier.
  • Also read etcd's ETCD_REFUSAL: marker as a read, so a refused filter surfaces its real error instead of a write denial (memcached already does this with MEMCACHED_REFUSAL:).
  • No authorization widened: ExternalStatementGate.privateRequestRefusal still refuses these tags from outside the app (tier-independent), and no real write or destructive statement changes tier.

Test plan

  • New QueryClassifierNonSqlTests.bigQueryTiers / spannerTiers, and additions to etcdTiers / elasticsearchTiers / typesenseTiers: each tag reads as a read, while SELECT/INSERT/DROP keep safe/write/destructive. Fail on main, pass here.
  • New driverBrowseMarkersReadAsReads pins every browse/search/count marker in ExternalStatementGate.driverRequestMarkers to .safe, so a future unrecognized read marker fails the test.
  • verify.sh build; verify.sh test QueryClassifierNonSqlTests.

Fixes #4385

BigQuery, Spanner, Elasticsearch, Typesense and etcd build grid browse/search as
opaque tagged requests; the classifier graded them .write, so Read-Only blocked
browse_table and the grid's Fetch All. Recognize them as reads. A BigQuery or
Spanner tag carrying a __RAW__ filter still grades .write, so it cannot bypass
Read-Only.
…ssified-write

# Conflicts:
#	apple/TablePro/Core/Utilities/SQL/QueryClassifier.swift
@datlechin
datlechin merged commit f2f1b26 into main Nov 22, 2026
9 of 10 checks passed
@datlechin
datlechin deleted the fix/tagged-browse-classified-write branch November 22, 2026 00:15
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.

macOS: BigQuery MCP browse_table blocked in Read-Only Safe Mode

1 participant