A Threat Model for Tool-Using Agents Against Your Data Platform
Content reflects the state as of October 2026. AI tooling and model capabilities in this area change frequently.
An AI agent that simultaneously holds private data access, processes untrusted input, and can trigger external communication is exploitable by design—and no amount of system-prompt wording will fix it.
TL;DR
- Problem: Large language models evaluate instructions and untrusted data inside the same token stream, so indirect prompt injection converts any read-capable agent with outbound network or rendering paths into an exfiltration engine.
- Answer: Break the lethal trifecta outside the model by removing at least one leg—private data, untrusted input, or external egress—per tool session, enforced at an identity-aware policy gateway and database layer.
- Watch out: Read-only database roles and static service accounts do not stop data theft; they only block writes while leaving cross-tenant reads and covert egress channels wide open.
Situation
Engineering teams are wiring autonomous agents and Model Context Protocol (MCP) servers directly into production databases, vector indexes, and observability stores. The initial pattern looks deceptively familiar: deploy an agent runtime, attach a set of database and API tools, grant a service account credential, and rely on a system prompt to keep the model inside operational guardrails.
That architecture treats the LLM as a deterministic application tier, which it is not. Unlike parameterized SQL drivers or typed RPC handlers, an LLM processes developer instructions, user prompts, retrieved database rows, and tool metadata in a single shared context window. When a support triage agent reads a customer ticket from PostgreSQL, searches an internal knowledge base, and posts a summary to Slack or renders a Markdown response in a browser, three capabilities converge in one execution context.
Security frameworks have converged on the same diagnosis. On June 16, 2025, Simon Willison named this combination the lethal trifecta: access to private data, exposure to untrusted content, and an external communication vector. The OWASP Top 10 for LLM Applications (2025) pairs LLM01:2025 (Prompt Injection) with LLM06:2025 (Excessive Agency) as the primary mechanism turning text manipulation into unauthorized system actions. And MITRE ATLAS maps these exact transitions across its 16 tactics—from Initial Access and Execution via crafted inputs, through Collection against internal data stores, to Exfiltration over authorized channels.
The Problem
Current agent deployments fail because teams place the security boundary inside the probabilistic model rather than around the deterministic infrastructure that surrounds it. A tool-using agent interacting with a data platform crosses four distinct trust boundaries on every request, and most architectures leave at least three of them unguarded.
Four hard architectural constraints govern why prompt-level defenses and naive database roles break under adversarial input:
- Zero instruction-data separation in token streams (TB-1 and TB-2). An LLM has no hardware-enforced equivalent of the NX bit or prepared statement parameter binding. Text returned from a database
SELECTquery, a support ticket body, a document chunk in a vector index, or an MCP tool description enters the same attention mechanism as the system prompt. Any untrusted string returned across TB-3 (Data Platform to MCP Server) becomes executable steering logic at TB-2 (Agent Runtime to MCP Server). - Static service credentials create confused deputies (TB-3). When an MCP server authenticates to a database using a single shared service role, the database cannot distinguish a legitimate query on behalf of Caller A from an injected query triggered while processing Caller B’s ticket. Even with
SELECT-only grants, a shared credential exposes every tenant and schema reachable by that role. The MCP specification explicitly warns against token passthrough and static OAuth proxy client IDs without per-client consent precisely because confused-deputy flows bypass caller authorization. - Covert egress exists even without
curlor HTTP tools (TB-4). Blocking outboundfetchtools does not close TB-4 if the agent renders Markdown in a web UI that automatically loads external image URLs (), sends emails, posts to shared webhooks, or triggers DNS lookups from a sandboxed runtime. If a session holds private data and untrusted text, any side channel capable of encoding a few hundred bytes per request completes the trifecta. - Blast radius scales with tool count and latency budgets. Suppose an agent exposes 12 MCP tools across 3 data stores, and an indirect injection payload coerces 1 unauthorized tool call per compromised record. If the gateway enforces no per-caller rate limit or row cap (
LIMIT 50vs. unboundedSELECT), a single poisoned document processed during a batch triage job can sweep thousands of rows before an operator notices an anomaly in billing or audit logs.
How do you let an agent reason over production data platforms without giving an attacker who controls one untrusted string a path to read and exfiltrate the rest of your data?
Options Considered
Teams typically evaluate three approaches when securing tool-using agents against data platforms. Only one eliminates the structural vulnerability.
How the Options Compare
| Option | Enforcement Layer | What It Gets Right | Where It Breaks | Verdict |
|---|---|---|---|---|
| Prompt hardening & delimiters | Inside the LLM context | Low implementation cost; stops naive direct jailbreaks | Fails against indirect injection in DB rows and tool metadata; probabilistic, not auditable | Rejected as a security boundary |
| Read-only DB service role | Database permissions (SELECT only) | Prevents INSERT/UPDATE/DELETE and schema drops | Does not stop data exfiltration; shared role allows cross-tenant reads via confused deputy | Insufficient alone |
| Capability isolation (trifecta-breaking) | Policy gateway + DB identity + egress firewall | Enforced deterministically outside the LLM; bounds blast radius per caller and session | Requires splitting workflows that mix untrusted text with external network calls | Chosen target architecture |
Prompt hardening fails because delimiters like <untrusted_data> are advisory tokens, not parser boundaries. Attackers routinely close XML-like tags inside user-controlled database fields or encode instructions in Base64, Markdown, or JSON keys. Read-only database roles are necessary—an agent performing diagnostics should never hold DROP or UPDATE privileges—but confidentiality breaches happen over SELECT. If an attacker can read customer PII and ship it out over a Markdown image pixel or webhook, write protection does nothing to prevent the breach.
Capability isolation works because it treats the lethal trifecta as an invariant to be broken in infrastructure. Every agent session is tagged at creation with the capabilities it is permitted to combine, and the gateway refuses to mount tools that complete all three legs simultaneously.
Capability-Scoped Agent Architecture
The target-state pattern moves all authentication, authorization, schema enforcement, and egress control out of the LLM and into a deterministic four-plane architecture: Caller Plane, Agent Sandbox, MCP Policy Gateway, and Data & Audit Plane.
Component Responsibilities
- Caller Plane (TB-1): Every human user or upstream batch job authenticates with an audience-bound OIDC or IAM token. Following the MCP specification security requirements, the gateway rejects static shared API keys and prohibits blind token passthrough to downstream APIs.
- Agent Sandbox (TB-2): The LLM runtime holds zero database credentials, zero cloud IAM keys, and no direct route to the public internet. If the session processes untrusted content (tickets, web pages, user-submitted documents), the client UI proxy strips external Markdown image links and clickable tracking URLs before rendering.
- MCP Policy Gateway (TB-2 to TB-3): A centralized gateway mediates every tool discovery and execution call. It pins tool manifests by cryptographic hash so upstream server updates cannot silently mutate tool descriptions (mitigating LLM01 via metadata poisoning). It validates every tool argument against strict JSON schemas, enforces row caps and statement timeouts, and gates any state-changing operation behind an independent Human-in-the-Loop (HITL) approval token.
- Data & Audit Plane (TB-3 and TB-4): Databases sit behind private network endpoints (PrivateLink, Private Service Connect, or private VPC peering) with zero outbound internet routing. The gateway exchanges the caller’s OIDC identity for a short-lived, caller-scoped database role or session context so Row-Level Security (RLS) and schema grants apply to the human caller, not a privileged bot.
Breaking the Trifecta in Policy
Rather than building one monolithic agent that can do everything, platform teams enforce three mutually exclusive session profiles at the MCP Policy Gateway:
- Profile A — Private Data + Untrusted Input (No Egress): Used for internal triage, RAG over user-contributed tickets, and SQL diagnostics. The sandbox has zero outbound network access, no email or webhook tools, and external image rendering is disabled in the UI.
- Profile B — Private Data + Egress (No Untrusted Input): Used for scheduled reporting or deterministic alert dispatch. The agent receives only structured, schema-validated parameters from parameterized queries—never free-text user fields, comments, or web scrapes.
- Profile C — Untrusted Input + Egress (No Private Data): Used for public web research or documentation lookup. The session runs with zero internal database credentials and no access to private VPC endpoints.
# Example MCP Policy Gateway session profile (declarative policy)
session_profile: "internal-triage-no-egress"
trifecta_legs:
private_data: true
untrusted_input: true
external_egress: false
controls:
caller_identity: "oidc_exchange_required"
allow_tools: ["pg_query_readonly", "opensearch_ticket_lookup"]
deny_tools: ["http_fetch", "slack_post", "send_email"]
db_limits:
max_rows: 100
statement_timeout_ms: 15000
require_read_replica: true
output_sanitization:
strip_markdown_images: true
Attacker and Defender Threat Matrix
Mapping concrete attacker techniques against deterministic controls ensures every trust boundary has an owner outside the prompt. The table below aligns each threat with OWASP LLM Top 10 and MITRE ATLAS categories.
| Threat Vector | Trust Boundary Crossed | Attacker Objective (ATLAS / OWASP) | Defender Control (Deterministic) | Verification Signal |
|---|---|---|---|---|
| Indirect injection in DB row or ticket | TB-3 → TB-2 | Hijack next tool call via stored text (OWASP LLM01 / ATLAS Execution) | Isolate session to Profile A (no egress tools); require HITL for writes | Synthetic injection payload in test row triggers zero egress calls |
| Confused deputy on shared DB role | TB-2 → TB-3 | Read another tenant’s rows via prompt-supplied ID (OWASP LLM06 / ATLAS Collection) | Propagate caller OIDC token to scoped DB role + enforce RLS | Cross-tenant query test returns 0 rows under Caller A’s token |
| Covert Markdown image exfiltration | TB-2 → TB-4 | Encode DB rows into  (ATLAS Exfiltration) | Strip external image/link tags in UI proxy + strict CSP img-src 'self' | Proxy strips external image URL; CSP blocks browser fetch |
| MCP tool metadata poisoning | TB-2 | Mutate tool description to trick LLM into leaking tokens (OWASP LLM01) | Hash-pin MCP tool manifests in gateway; block unapproved schema drift | Gateway rejects tool registration when manifest hash changes |
| OAuth proxy token hijack | TB-1 → TB-2 | Reuse static client ID consent flow to steal another user’s token | Per-client explicit consent + strict audience (aud) binding per MCP spec | Token issued for Server A rejected by Server B with HTTP 401 |
| SSRF via remote MCP or fetch tool | TB-2 → TB-4 | Probe cloud metadata (169.254.169.254) or internal subnets (10.0.0.0/8) | Block RFC1918, loopback, and link-local CIDRs at gateway + egress proxy | SSRF probe to metadata IP returns connection refused / 403 |
| Unbounded read DoS on primary DB | TB-3 | Force full sequential scan or lock contention via ORDER BY / LIMIT | Route read tools to replica + enforce statement_timeout + row caps | Query exceeding 15s terminates cleanly; primary CPU unaffected |
How It Rolls Out
Enforcing these boundaries requires a deterministic four-step execution path at runtime and a staged rollout that avoids breaking existing developer workflows.
Runtime Request Flow
- 01 Verify Caller: The client submits an audience-bound OIDC token to the MCP Policy Gateway. The gateway validates the signature, expiration, and
audclaim, and attaches a unique trace correlation ID. Static bearer tokens shared across users are rejected. - 02 Drop One Leg: The gateway evaluates the session profile. If the workflow must ingest untrusted text (such as a customer ticket or web document) alongside private database records, the gateway strips all egress tools (
http_fetch,send_email,webhook_post) from the tool manifest exposed to the model for that session. - 03 Gateway Execution: When the model invokes a permitted tool, the gateway validates arguments against a strict JSON schema, exchanges the caller’s identity for a short-lived database credential (or sets the session role), and executes against a read replica with
statement_timeoutand row caps. Any state-changing tool call pauses for an out-of-band HITL approval token. - 04 Sanitize and Log: Before returning results to the user interface, an output filter strips external Markdown image tags and unapproved external links. The gateway writes a structured audit record linking the OIDC principal, tool name, manifest hash, and database role—while redacting bind parameters and raw PII rows.
Phased Rollout and Rollback Gates
- Phase 1 — Inventory and Classification: Catalog every agent, MCP server, database credential, and outbound network path. Tag each workflow with its active trifecta legs. Gate: Zero production agents running with undocumented static admin credentials. Rollback: N/A (read-only discovery).
- Phase 2 — Gateway Mediation and Manifest Pinning: Route all agent-to-tool traffic through the MCP Policy Gateway with hash-pinned tool definitions and per-caller OIDC validation. Gate: 100% of tool calls carry a caller principal and trace ID in audit logs. Rollback: Bypass gateway only for pre-approved emergency break-glass runbooks with time-bound expiry.
- Phase 3 — Database Identity and Replica Routing: Replace shared service accounts with caller-scoped roles (IAM DB auth or short-lived OIDC-mapped roles), enable RLS on multi-tenant tables, and pin read tools to replicas. Gate: Cross-tenant access tests return zero rows; primary DB CPU impact from agent queries is zero. Rollback: Revert specific tool to a scoped read-only replica role if IAM token exchange latency exceeds SLA while keeping RLS active.
- Phase 4 — Egress Lockdown and UI Sanitization: Enforce Profile A/B/C separation, block RFC1918/metadata SSRF targets, and deploy UI Markdown image stripping plus Content Security Policy (CSP) headers. Gate: Red-team indirect injection suite achieves 0% exfiltration across all four channels. Rollback: Temporarily allowlist specific internal webhook domains in Profile B while keeping Profile A egress-locked.
In Practice
I have not run a multi-cloud agent fleet at hyperscale personally, so every architectural control in this threat model is derived from documented system behavior and published specifications rather than private incident metrics:
- Lethal trifecta mechanics (Pattern A — Documented Analysis): Simon Willison’s June 16, 2025 analysis documents how real-world coding, email, and database agents have repeatedly been exploited by combining private data access, untrusted input, and external communication—and argues that avoiding the combination, by removing one of the three legs, is the structural fix.
- Protocol-level confused deputy and SSRF controls (Pattern A — Specification): The MCP security best practices forbid token passthrough (servers must not accept or forward tokens not issued for them), call for token audience validation, require per-client user consent when a proxy server uses a static OAuth client ID, and recommend that clients fetching OAuth metadata block requests to private and loopback address ranges to limit SSRF.
- Database enforcement behavior (Pattern B — System Mechanics): PostgreSQL, MySQL, and cloud-managed data platforms enforce
GRANT, Row-Level Security, andstatement_timeoutdeterministically at the connection and query-planner layers. When a gateway maps an OIDC caller to a distinct database role and routes reads to a replica, an indirect prompt injection inside a row cannot escalate privileges beyond what that human caller already holds in SQL.
Where It Breaks
Even a well-designed capability-isolated architecture has operational failure modes. Treating the gateway and egress controls as infallible without monitoring these seams creates new blind spots.
| Condition | Breaks How | Detect | Mitigate |
|---|---|---|---|
| Workflow genuinely needs all 3 legs | A user wants an agent to read an untrusted ticket, look up private billing data, and email an external vendor | Session policy blocks tool mounting or teams bypass the gateway | Split into two isolated jobs: Job 1 summarizes/proposes; human approves; Job 2 sends structured payload via Profile B |
| DNS or side-channel egress left open | Agent sandbox blocks HTTP but allows DNS resolution (*.attacker.tld) or renders clickable links with query params | Egress DNS logs show high-entropy subdomain queries; UI click-throughs to unknown domains | Run sandbox with internal-only DNS resolver; disable external link/image rendering in client UI |
| Tool manifest updates unreviewed | Upstream third-party MCP server pushes a new tool description containing hidden instructions | Manifest hash mismatch alert in gateway; sudden spike in unexpected tool-call arguments | Pin tool versions by SHA-256 hash; require security review before promoting manifest changes |
| Audit logs capture raw SQL binds and rows | Central logging pipeline ingests unredacted PII or secrets returned by diagnostic queries | DLP scanner flags PII patterns in log sink | Log caller principal, tool ID, row count, and latency; redact query literals and result payloads before shipping |
| HITL approval fatigue | Operators rubber-stamp every write prompt because low-risk reads or frequent steps trigger modals | Approval latency under 1 second across dozens of consecutive prompts | Reserve HITL strictly for irreversible mutations and cross-boundary exports; keep read-only diagnostics frictionless |
Key Takeaways
- Treat the LLM as an untrusted, probabilistic orchestrator: Never place authorization, tenant isolation, or SQL safety solely inside system prompts or XML delimiters.
- Break the lethal trifecta outside the model: Every tool session must drop at least one of private data, untrusted input, or external egress—enforced by the gateway and network, not by model instructions.
- Eliminate shared database service accounts: Propagate caller OIDC identity through the MCP gateway to scoped database roles and Row-Level Security so a compromised session cannot become a confused deputy.
- Close covert egress channels: Blocking
curlis not enough; strip external Markdown images, enforce strict CSP headers, and block metadata/RFC1918 SSRF targets. - Pin tool metadata like executable code: An MCP tool’s name and description sit in the model’s instruction path; hash-pin manifests and treat unapproved changes as supply-chain drift.
What to Do Next
- Problem: Tool-using agents that combine private database access, untrusted text ingestion, and outbound communication are vulnerable to indirect prompt injection and silent data exfiltration.
- Solution: Deploy an identity-aware MCP policy gateway that enforces capability-isolated session profiles, caller-scoped database roles, and strict egress/UI sanitization outside the LLM.
- Proof: Run a synthetic indirect prompt injection test containing a Markdown image exfiltration payload and a cross-tenant ID lookup; verify zero outbound requests and zero cross-tenant rows in audit logs.
- Action: Inventory your active agent and MCP tool deployments this week, tag each session with which of the three trifecta legs it holds, and remove outbound network or external rendering from every session that reads both private data and untrusted text.