Skip to content

fix: discourage host-filesystem access in raw-SQL tool descriptions - #410

Merged
stoallan merged 2 commits into
mainfrom
als/mcp-sql-host-boundary
Sep 8, 2026
Merged

stoallan merged 2 commits into
mainfrom
als/mcp-sql-host-boundary

Conversation

@stoallan

@stoallan stoallan commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What

Appends a shared HOST_BOUNDARY_NOTE to the descriptions of the two raw-SQL tools — execute_sql and apply_migration — and a matching one-line reminder in the server instructions, discouraging the model from reading server-side files or running OS commands via SQL (COPY … FROM '/path', COPY … FROM PROGRAM, pg_read_file, pg_ls_dir, lo_import).

Why

Cut tripwire noise on the managed fleet. LLMs driving the MCP attempt host-filesystem reads via SQL, and the tripwire fires on the attempt — it records that the SQL ran, not whether it succeeded — so every probe generates alert noise regardless of outcome. Discouraging the model from making the attempt reduces the volume at the source. This is the exfil-OUT counterpart to the injection-IN guidance already present (AI-794 / wrapWithUntrustedDataBoundary).

Design

  • On the tool descriptions, not only server instructions. Per the 2026 MCP spec, instructions rides on the optional server/discover response and isn't guaranteed to be injected; a client cannot invoke a tool without ingesting its description — so the description is the reliable delivery vehicle. The server-instructions line is added too, as opportunistic defense-in-depth.
  • Both raw-SQL tools. apply_migration forwards arbitrary SQL too; these two are the only raw-SQL entry points.
  • A shared constant (HOST_BOUNDARY_NOTE) to keep the two descriptions from drifting, mirroring the existing wrapWithUntrustedDataBoundary factoring.
  • Deployment-neutral wording. The text names no deployment context — it's true everywhere. This matters because the same mcp-server-supabase also ships to self-hosted Studio, where a "Supabase-managed infrastructure" rationale would be false (the operator owns the host). No self-hosted benefit is claimed; the goal is purely managed noise.

FYI (per review)

ChatGPT snapshots/freezes MCP tool descriptions + instructions, so this needs a plugin resubmission to take effect there — tracked on the Supabase side, no action here.

Testing

String-concat append to two tool descriptions + one instructions bullet (type-trivial). No test asserts the raw-SQL description text (the untrusted user data assertions target the result wrapper), and the instructions test compares against the exported constant, so it stays in sync. Local suite not run — CI validates format/typecheck/tests.

🤖 Generated with Claude Code

@stoallan
stoallan requested a review from a team as a code owner September 3, 2026 18:57
@coveralls

coveralls commented Sep 3, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 34176164896

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.1%) to 96.404%

Details

  • Coverage decreased (-0.1%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3562
Covered Lines: 3452
Line Coverage: 96.91%
Relevant Branches: 526
Covered Branches: 489
Branch Coverage: 92.97%
Branches in Coverage %: Yes
Coverage Strength: 60.26 hits per line

💛 - Coveralls

…erver instructions)

LLMs driving the MCP server attempt to load the host's local filesystem into
the customer database via SQL (COPY FROM '/path', COPY FROM PROGRAM,
pg_read_file, pg_ls_dir, lo_import). These fail at the DB layer (the project's
Postgres role isn't a superuser), but the server offers no guidance that the
host boundary exists.

- Primary (reliable): a shared HOST_BOUNDARY_NOTE appended to the two raw-SQL
  tool descriptions (execute_sql, apply_migration). A client cannot invoke a
  tool without ingesting its description, whereas the server `instructions`
  ride on the optional `server/discover` response and aren't guaranteed to be
  injected. Factored into one constant to prevent the two from drifting.
- Defense-in-depth: a terse host-boundary line in the server `instructions`,
  for clients that do inject them (mirrors the existing dual-placement of the
  untrusted-data / injection warning).

This is the exfil-OUT counterpart to the injection-IN guidance already present
(AI-794 / wrapWithUntrustedDataBoundary).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@stoallan
stoallan force-pushed the als/mcp-sql-host-boundary branch from a085927 to 704eb33 Compare September 3, 2026 19:04
@mattrossman mattrossman added the publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/ label Sep 3, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@supabase/mcp-server-postgrest@80953e4
pnpm add https://pkg.pr.new/@supabase/mcp-server-supabase@80953e4
pnpm add https://pkg.pr.new/@supabase/mcp-utils@80953e4

commit: 80953e4

@Rodriguespn Rodriguespn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Allan, this looks good — clean approach, and I've verified the note lands on exactly execute_sql + apply_migration and the instructions line ships on initialize. One thing I'd like before we merge:

The clause ("shared Supabase infrastructure; its host filesystem and OS are not the user's") is accurate for hosted/mgmt-api, where the alerts came from, but the same string ships to self-hosted Studio (here), where the user owns the host, and there it's actually load-bearing, since installs predating the superuser removal connect as supabase_admin, where these primitives genuinely succeed.

So I'd make the wording deployment-neutral so it's true everywhere:

const HOST_BOUNDARY_NOTE =
  " Never read server-side files or run OS commands via SQL (e.g. `COPY ... FROM '/path'`, `COPY ... FROM PROGRAM`, `pg_read_file`, `pg_ls_dir`, `lo_import`) — load external data from the client side instead.";

And in server.ts:

-- The project database runs on shared Supabase infrastructure; its host filesystem and OS are not the user's. Do not read server-side files or run OS commands via SQL.
++ SQL runs on the project's database server. Never read server-side files or run OS commands via SQL.

Instruction and examples unchanged, only the rationale. Keeps the single shared constant, no per-platform branch, no drift.

Two small nits, non-blocking:

  1. qualify the "role isn't a superuser" line in the PR body (true for hosted, not for old self-hosted installs),
  2. Note in the PR that ChatGPT snapshots/freezes tool descriptions + instructions, so it needs a plugin resubmission to take effect there. No action from your side needed, this one is on us. Also, low risk since the MCP connection on Chatgpt is serverless and (hopefully) sandboxed by OpenAI

…ack)

Per review: the same mcp-server-supabase ships to self-hosted Studio, where the
"shared Supabase infrastructure / not the user's" rationale is false (the user
owns the host, and pre-superuser-removal installs connect as supabase_admin
where these primitives succeed). Drop the deployment-specific rationale; keep
the imperative + examples, which are true everywhere. Single shared constant
unchanged — no per-platform branch, no drift.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@stoallan

stoallan commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks Pedro — good catch. Applied the deployment-neutral wording verbatim (dropped the "shared Supabase infrastructure / not the user's" rationale from both HOST_BOUNDARY_NOTE and the server.ts line; kept the imperative + examples, single shared constant). I also reframed the PR body around the actual goal — cutting managed tripwire noise (the alert fires on the attempt, so success/deployment don't matter) — and dropped the "role isn't a superuser" line entirely rather than qualifying it, since it was both inaccurate for self-hosted and beside the point. Kept your ChatGPT-snapshot note as an FYI. Ready for another look.

@stoallan
stoallan requested a review from Rodriguespn September 8, 2026 01:18

Copy link
Copy Markdown
Contributor

Confirmed — the applied wording matches exactly what I proposed: HOST_BOUNDARY_NOTE is deployment-neutral, shared across execute_sql and apply_migration, and the server.ts instructions line drops the hosted-only rationale. Approving.

@Rodriguespn Rodriguespn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2: verified. HOST_BOUNDARY_NOTE is a single shared constant appended to both execute_sql and apply_migration descriptions, deployment-neutral (no "shared Supabase infrastructure"/"not the user's" language), keeps the imperative and all four examples (COPY ... FROM '/path', COPY ... FROM PROGRAM, pg_read_file, pg_ls_dir, lo_import). server.ts guideline line is now deployment-neutral: "SQL runs on the project's database server. Never read server-side files or run OS commands via SQL." Only the two expected files touched, no per-platform branching, no wording drift between the two tool descriptions. Addresses my round-1 feedback. Approving.

@stoallan
stoallan merged commit 641ed1e into main Sep 8, 2026
7 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Sep 8, 2026
@stoallan
stoallan deleted the als/mcp-sql-host-boundary branch September 8, 2026 13:49
barryroodt pushed a commit that referenced this pull request Sep 17, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-server-supabase: 0.13.0</summary>

##
[0.13.0](mcp-server-supabase-v0.12.0...mcp-server-supabase-v0.13.0)
(2026-09-17)


### ⚠ BREAKING CHANGES

* **mcp:** confirm destructive SQL via elicitation and rename
costConfirmation option
([#408](#408))

### Features

* add --http local HTTP entry to mcp-server-supabase
([#401](#401))
([ff063b4](ff063b4))
* **management:** add v2 api client
([#419](#419))
([02ca542](02ca542))
* **mcp:** confirm destructive SQL via elicitation and rename
costConfirmation option
([#408](#408))
([c9c4e3f](c9c4e3f))
* support skip_elicitations in the local HTTP server
([#434](#434))
([9442e82](9442e82))
* URL-mode secret collection for create_edge_function_secret
([#412](#412))
([fb88629](fb88629))


### Bug Fixes

* discourage host-filesystem access in raw-SQL tool descriptions
([#410](#410))
([641ed1e](641ed1e))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-preview Runs `publish-preview` workflow to publish preview packages via https://pkg.pr.new/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants