Blocking AI Agents from Unloading PHI with COPY INTO Through the Snowflake MCP Server
No single control stops an agent from unloading PHI through a Snowflake MCP server. Restrict roles, stages and storage integrations in Snowflake so unloads have few valid destinations. Then enforce policy at the MCP tool call, where the SQL statement can be inspected before it reaches Snowflake. Block COPY INTO unloads to external locations, allow ordinary reads, and record every decision as evidence for HIPAA 164.312(b) audit controls.
What each decision looks like at runtime
- 1
1. Intercept
The agent's SQL tool call is captured with the agent identity, tool name and submitted statement.
- 2
2. Evaluate
The statement is parsed, split and checked against policy, including the destination.
- 3
3. Block
COPY INTO unloads to external stages or inline URLs are refused before reaching Snowflake.
- 4
4. Allow or redact
Permitted reads proceed, with redaction applied where policy requires it.
- 5
5. Escalate
Ambiguous or sensitive operations are held for human approval.
- 6
6. Record
The decision, policy version and context are written as evidence.
Evidence to capture for HIPAA 164.312(b) audit controls
- Agent identity and the user or session it acted for
- MCP server and tool name
- Submitted statement, with PHI-bearing values handled according to your retention policy
- Decision: allow, redact, block or escalate
- Policy name and version that produced the decision
- Timestamp and target location, if one was specified
How an agent ends up running an unload
A Snowflake MCP server typically exposes one or more tools that run SQL on the agent's behalf. If a tool accepts free-form statements, the agent can submit anything the connected role is allowed to execute. That includes COPY INTO <location>, which writes query results to a stage or a cloud storage location instead of returning them to the caller.
The agent does not need to be malicious. A prompt that asks it to export a cohort for analysis, a poisoned document that carries instructions, or a plan the agent builds itself can all produce an unload statement. Because the data leaves through a storage write, nothing returns to the agent for you to inspect afterward.
It helps to enumerate the paths before designing controls:
- Direct unload to a named external stage that the role can use.
- Unload to an inline storage URL written into the statement.
- A multi-statement payload where the unload follows a harmless SELECT.
- Unload nested inside a procedure or task that the role may call or create.
- A sequence in which the agent first creates a stage, then unloads to it.
What Snowflake configuration does, and where it stops
Start with the platform. The role the MCP server connects as should hold only the privileges the agent's job needs: read access to specific views, no ability to create stages, and no usage on external stages. Least privilege removes whole classes of paths, including the create-a-stage-then-unload sequence.
Account parameters add a second layer. PREVENT_UNLOAD_TO_INLINE_URL addresses unloads to URLs written directly in a statement, and REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION requires stage operations to go through a storage integration. Together with a storage integration that is scoped to approved locations, they constrain where data can go.
The gap is that these controls describe permitted destinations, not the agent's behavior. If an approved stage exists and the role can use it, an unload to it is valid as far as Snowflake is concerned. Snowflake also does not record why the agent issued the statement or which tool call carried it. Configuration is necessary, but it cannot tell you what the agent attempted, and it cannot refuse a statement on the basis of the request that produced it.
Adding a decision point at the MCP tool call
The tool call is the last place where the statement is still just text and the agent's identity and tool context are known. A policy decision there can inspect the statement before it executes and refuse it. The design pattern has four parts.
First, classify statements by parsing them, not by matching strings. Normalize case, whitespace and comments, then identify the statement type. COPY INTO with a location target is an unload. COPY INTO a table is a load and should be judged separately.
Second, split multi-statement input and evaluate every statement. A single allowed SELECT must not carry a second statement through. Treat nested constructs, such as calls to procedures that could unload, as requiring their own rule.
Third, evaluate the target, not just the verb. Inline URLs, named stages and stage references are all destinations. For PHI-bearing data, the default for an external target should be block.
Fourth, fail closed. If the statement cannot be parsed with confidence, do not pass it on. Return a clear refusal to the agent so it can report that the action was not permitted.
- Parse and classify each statement.
- Split multi-statement SQL and evaluate each part.
- Resolve the destination: inline URL, named stage or other location.
- Block external unloads by default; fail closed on parse errors.
Governance, tradeoffs and next steps
Layering has costs. Tight roles and stage restrictions can slow legitimate analytics, and a strict statement policy will occasionally refuse something a person would approve. Escalation for human approval is the usual release valve, but it needs an owner and a response expectation. Evidence that contains submitted statements may itself contain PHI, so apply the same access control and retention rules to it that you apply to the data.
Scope matters too. HHS says a covered entity or business associate may use a cloud service to store or process ePHI if it has a business associate agreement with the provider and otherwise complies with the HIPAA Rules, and that it should understand the provider's environment to conduct its own risk analysis. Extend that analysis to the AI agent data path, including any intermediary that handles agent traffic.
Restricting agent access to health information can also raise a separate question. A proposal published in December 2025 would revise the information blocking definitions of access and use to include autonomous AI systems. Information blocking exceptions are voluntary, and practices are assessed case by case, so involve compliance counsel when you define agent restrictions.
Trussed runs in production with healthcare and pharma organizations, enforcing policy in the path and producing audit-ready evidence mapped to HIPAA. It deploys self-managed in the customer cloud, with configurable retention and data residency. Whatever tooling you use, test the design against each path listed above, including inline URLs, named stages and multi-statement input, before agents touch PHI.
Three layers between an agent and an external stage
Account and role configuration
Limits what the Snowflake role behind the MCP server can do.
Stage and storage integration limits
Narrows where an unload could land, even if a statement is issued.
MCP tool-call policy
Inspects each statement in the execution path and decides before execution.
Enforce policy on agent SQL before it reaches Snowflake
See how tool-call enforcement blocks unloads and produces audit-ready evidence for each decision.
Explore Agent and Tool-Call EnforcementHow does your AI governance program compare?
See where your program has gaps in less than 2 minutes.