Guide · checked
Is it safe to connect Claude or ChatGPT to your database?
It is safe enough when four things are true: the login can only read, the limits are enforced outside the AI, personal columns are kept back, and you can see what was sent. None of the four is a setting in Claude or ChatGPT. Each comes from your database or from the connector.
Portward wrote this page and makes one of the tools it mentions. Each claim about another company links to the page it came from. Found an error? Write to admin@portward.ai and we'll correct it and update the date.
01The four things
What has to be true before you connect
1. The login can only read
Give the AI its own database login with SELECT and nothing else. Then the database itself refuses a write, whatever the AI or the connector sends. OWASP's guidance for AI tools says the same: give an extension only the permissions it needs.[5] In PostgreSQL:
-- Run as an administrator. Replace the names in angle brackets. CREATE ROLE claude_ro WITH LOGIN PASSWORD '<a new password>'; GRANT CONNECT ON DATABASE <your_db> TO claude_ro; GRANT USAGE ON SCHEMA <your_schema> TO claude_ro; -- Every table and view in the schema, or list only the ones the AI needs: GRANT SELECT ON ALL TABLES IN SCHEMA <your_schema> TO claude_ro; -- Or columns only: GRANT SELECT (id, region, total) ON <table> TO claude_ro; -- Tables the owner creates later: ALTER DEFAULT PRIVILEGES FOR ROLE <table_owner> IN SCHEMA <your_schema> GRANT SELECT ON TABLES TO claude_ro;
What this does not do: it puts no limit on what the login can read. A read-only login that can see every table can still show every table to the AI.
2. The limits are enforced outside the AI
Telling a model to “only read” is a request, not a control. A check inside a connector is better, but it can fail too. The reference Postgres MCP server wrapped each query in a read-only transaction, and Datadog showed that a query carrying a second statement could end the transaction and then write.[6] DBHub's documentation describes its own read-only mode as “a guardrail against accidental and agent-initiated writes, not a permission boundary”.[15] So look for two locks: code that checks the query before it runs, and the login from point 1 behind it.
3. Personal columns are kept back
Whatever a query returns goes into the chat, and the chat goes to the AI company. A column that is kept back before the result leaves the connector is never sent at all. Pick the columns the AI does not need to answer: emails, phone numbers, addresses, dates of birth, notes written by people.
What this does not do: it does not cover what you type into the chat yourself, and a column you leave visible can still identify someone. How to keep personal information out covers the three ways to do it.
4. You can see what was sent
You should be able to look up, after the fact, the query that ran and the rows the AI received. Without a record, you learn about a mistake only if someone notices the answer.
02The AI app
What Claude's and ChatGPT's own settings do, and what they don't
Training settings
On Claude Free, Pro and Max, Anthropic uses chats to improve its models if you “choose to allow us to use your chats and coding sessions to improve Claude”, a privacy setting. The same page says that data “does not include raw content from connectors (e.g. Google Drive), including remote and local MCP servers, though data may be included if it’s directly copied into your conversation with Claude”.[1] For its commercial products, Anthropic says: “By default, we will not use your inputs or outputs from our commercial products (e.g. Claude for Work, Anthropic API, Claude Gov, etc.) to train our models.”[2]
In ChatGPT, the setting is Improve the model for everyone, under Settings, then Data controls. On personal Free, Plus and Pro workspaces “data sharing is enabled by default”, and you can turn it off. “By default, OpenAI does not use content from ChatGPT Business, Enterprise, or Edu workspaces to train its models.”[4]
What these settings do not do: they decide what happens to a conversation afterwards. They do not decide what a connector may read, they do not make a query read-only, and they do not remove a column from a result. Rows the AI receives are still sent to the AI company and handled under its terms. Read both companies' pages yourself; they change.
Connector approvals
Claude's help page warns that custom connectors “allow you to connect Claude to services that haven't been verified by Anthropic”, and advises: “Review Claude's tool approval requests carefully and only click “Allow always” when using a server and tool that you trust to run unsupervised.”[3] An approval prompt shows you that a tool is about to run. It does not check the query for you, and once you allow a tool always, the prompt is gone.
03Two public cases
What went wrong elsewhere, and what would have stopped it
A read-only server that could write
Datadog found that the reference Postgres MCP server's read-only transaction could be ended by a second statement in the same query, after which any SQL ran.[6] The package is now marked “Archived and unmaintained; no security guarantees” on npm.[8] A login that can only read would have stopped the write, and so would a check that allows exactly one statement. What to use instead.
Instructions hidden in the data
In a July 2025 demonstration with dummy data, General Analysis planted instructions in a support ticket. An assistant using the Supabase MCP server with the service_role, which bypasses row-level security, read a private table and copied it into a reply the customer could see.[9] Simon Willison calls the combination of private data, untrusted instructions and a way to send data out the “lethal trifecta”.[10] A login that can only read would have stopped the reply being written. It would not have stopped the read: as the authors put it, “Read-only access still permits reads of data available to the database role.”[9] Keeping the private table from the AI stops that.
04Where Portward fits
What Portward does, and what it does not protect against
Portward is a hosted connector for PostgreSQL and MySQL databases on the internet. On the four points: it refuses an administrator login and asks for a read-only one; it parses each query to exactly one SELECT and runs it in a read-only transaction with a 30-second limit; columns you keep back never reach your AI; and it keeps a history of each query (question and SQL, no time limit) and what your AI was sent, sealed, for 30 days, with a receipt under each answer. The database password is typed in Portward, never in the chat.
What it does not protect against:
- Portward itself. Portward runs the engine that reads your database, so it can technically see what passes through it. Portward holds your account email, your database login (sealed to your engine's key), your rules and notes, the questions and SQL your AI ran, receipts and usage counts, and the AI log of what the AI was sent. Rows pass through your engine to the AI and are not stored by Portward, except in that AI log, which deletes them after 30 days, and in the results panel, which deletes them after 24 hours. Your engine is separate from every other account's. The detail is on the security page.
- The AI company. Every row your AI receives is sent to Anthropic or OpenAI like the rest of the chat.
- A column you left visible. Portward suggests columns whose names look personal. It reads names, not values, so a personal value in a column called
refornotesis yours to catch. - Instructions hidden in your data. Text in a row can still try to steer your AI. Portward limits what that can reach to reads, minus the columns you kept back. It cannot stop your AI repeating what it was allowed to read.
- What you type. Anything you paste into the chat goes to the AI company directly.
- A wrong answer. Your AI can write a query that runs and is still the wrong query. The receipt shows what it was sent, so you can check.
05A checklist
Ask this of any tool, Portward included
- Does the database login have SELECT and nothing else, on only the tables the AI needs?
- What checks the query before it runs, and what happens to a query with two statements in it?
- Where does the database password live: in the chat, in a config file, or with a third party?
- Can a column be kept from the AI, and is that done before the result leaves the tool?
- Is there a record of each query and of the rows the AI received, and for how long?
- Who runs the tool, and what can they see?
- What do your AI plan's training settings say today?
Ways to give Claude access to your database, compared answers these for each option, with sources.
Sources
Each read on . First published .
- [1]Anthropic Privacy Center: Is my data used for model training? (Claude Free, Pro and Max)
- [2]Anthropic Privacy Center: Is my data used for model training? (commercial products)
- [3]Claude Help Center: Get started with custom connectors using remote MCP
- [4]OpenAI Help Center: Data controls in ChatGPT
- [5]OWASP LLM06:2025 Excessive Agency
- [6]Datadog Security Labs: SQL injection in the PostgreSQL MCP server
- [8]npm registry: @modelcontextprotocol/server-postgres, latest version (its deprecated notice)
- [9]General Analysis: Supabase MCP can leak your entire SQL database
- [10]Simon Willison: Supabase MCP can leak your entire SQL database (the lethal trifecta)
- [15]DBHub docs: Read-only mode