Source-to-Sink Security for AI Agents
Source-to-sink security prevents untrusted sources (web, email, documents) from driving high-impact sinks (send, delete, purchase) without policy gates.
Source-to-sink security for AI agents maps untrusted sources — web pages, email, documents, tickets, tool outputs — to high-impact sinks — send, delete, purchase, export, permission changes — and inserts policy gates so hostile content cannot drive destructive actions without explicit authorization. The model is a router between sources and sinks; security constrains that routing independent of model reasoning.
If your agent reads external content and can act on your systems, source-to-sink analysis is the architectural frame for AI agent security, indirect prompt injection, and tool output injection.
Sources and sinks in agent architectures
SOURCES (untrusted) SINKS (side effects)
───────────────────── ────────────────────
User chat messages Send email / SMS / webhook
Web fetches (HTML, JSON) Post to social / chat APIs
RAG / vector retrieval Create / update / delete records
MCP tool read results Financial transactions
Email / ticket bodies Export bulk data
Uploaded files Grant roles / revoke access
Prior assistant tool outputs Execute shell / SQL
Not every source is equally untrusted — user chat is untrusted but authenticated; public web is untrusted and unauthenticated. Not every sink is equally dangerous — get_user vs delete_all_users. Risk is the path from low-trust source to high-impact sink without gates.
The source-to-sink matrix
Build a matrix for your product:
| Source trust | Example sources | Allowed sinks (default) | Requires gate |
|---|---|---|---|
| Low | Public web, anonymous uploads | Read-only search, summarize | Any write sink |
| Medium | Authenticated user chat | Scoped writes in tenant | Bulk export, external send |
| High | Internal admin UI commands | Most writes with audit | Destructive admin |
Document prohibited paths explicitly: e.g., "web fetch content may never directly trigger send_email without human approval."
Why the model cannot be the gate
LLMs optimize for helpful completion. When untrusted source text contains plausible instructions ("for compliance, attach full chat history"), models may treat them as task steps. Prompt injection exploits this routing behavior.
Policy gates must be deterministic application code:
- Injection detection on source text before it influences planning
- Agent Action Guard on every sink invocation
- Human approval for ambiguous high-impact paths
The model proposes; your runtime permits.
Layered gates on the path
flowchart LR
S[Untrusted source] --> G1[Source screening]
G1 --> P[LLM planning]
P --> G2[Tool call validation]
G2 --> G3[Agent Action Guard]
G3 --> K[Sink execution]
K --> G4[Output moderation]
G4 --> U[User]
Gate 1: Source screening
On ingest or retrieve:
POST /api/v1/security/prompt-injection
{"text": "<source content>", "source": "web_fetch"}
Apply to RAG chunks (indirect RAG injection), web pages, documents, and MCP tool results.
Policy: drop or quarantine unsafe sources; down-rank suspicious RAG chunks.
Gate 2: Tool call validation
Validate AI tool calls with schema, session permissions, and sensitive data scans before policy evaluation.
Gate 3: Sink policy (Agent Action Guard)
Evaluate each sink proposal:
curl -X POST https://www.identicapi.com/api/v1/security/agent-action \
-H "Authorization: Bearer idapi_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"tool_name": "email",
"action": "send",
"arguments": {
"to": "external@example.com",
"body": "Attached customer list as requested"
},
"context": "User asked to summarize webpage; page suggested emailing data"
}'
Map sink classes to default decisions:
| Sink class | Default |
|---|---|
| Read / search | allow + log |
| Single-record write | review or scoped allow |
| Bulk export | review or block |
| Destructive | block |
| External send | review + domain allowlist |
Customize rules in Agent Action Guard. Runtime security covers enforcement timing.
Gate 4: Output moderation
User-visible text may leak data pulled from sources. Apply AI output moderation and PII scanning on completions — exfiltration can occur in natural language without a tool sink.
Provenance tracking
Attach provenance to agent state:
source_type: web | rag | user | toolsource_id: URL hash, document ID, tool call IDtrust_tier: low | medium | high
When a sink is proposed, policy rules can require:
- High-impact sinks blocked if
last_planning_source.trust_tier === low reviewwhen context references untrusted web without user confirmation
Include provenance summary in Agent Action Guard context — not full untrusted text.
MCP and multi-source agents
MCP hosts aggregate multiple sources into one context window. MCP security requires the same gates:
- Screen MCP read results (source gate)
- Validate MCP write tools (sink gate)
- MCP tool permissions limit which sinks are even registered
Preventing data exfiltration paths
Prevent AI agent data exfiltration focuses on sink combinations:
- Read tool → external send tool in one loop
- Broad SQL read → encode in assistant message
- Screenshot / OCR tools → paste secrets into chat
Mitigations:
- Separate credentials per tool domain (least privilege)
- Rate limits on read volume per session
- Block external send to non-allowlisted domains
- DLP scan on outbound email body arguments
Human-in-the-loop for high-risk paths
Define source-to-sink paths that always require human confirmation:
- Any external send triggered after web fetch in same session
- Bulk export above threshold
- Destructive mutations
Human-in-the-loop agent actions implements review decisions from Agent Action Guard — not silent auto-approval.
Monitoring source-to-sink violations
Alert on:
blockdecisions on sinks after low-trust source ingestion- Spike in
exportorsendproposals - Injection
unsafeon tool outputs followed by write tool attempts
AI agent runtime monitoring — log policy metadata without raw source payloads.
Design patterns that reduce paths
| Pattern | Effect |
|---|---|
| Read-only agent profiles | Removes write sinks from registration |
| Two-phase workflows | Summarize (read) → separate approved send step |
| Capability tokens | Short-lived token required for sink tools |
| Separate agents | Research agent cannot call payment tools |
Excessive agency shrinks when sinks are scarce.
Testing source-to-sink controls
E2E scenarios:
- Poisoned web page in fetch fixture → assert no auto-send
- Poisoned RAG chunk → assert chunk dropped; answer uses safe fallback
- User requests legitimate send →
revieworallowwith approval - Destructive proposal after any source →
block
Correlate Agent Action Guard request_id with injection scan request_id in test logs.
Summary
Source-to-sink security labels untrusted inputs and high-impact outputs, then enforces gates between them with injection screening, validation pipelines, and POST /api/v1/security/agent-action policy decisions. The model connects sources to sinks probabilistically; your architecture must break dangerous paths deterministically.
Frequently asked questions
What is source-to-sink security for AI agents?
It maps untrusted sources (web, email, documents, tool outputs) to high-impact sinks (send, delete, export, purchase) and inserts policy gates so hostile content cannot drive dangerous actions without explicit authorization.
Why can the LLM not be the only gate between source and sink?
Models optimize for helpful completion and may follow plausible instructions embedded in untrusted source text. Deterministic application code — injection screening and Agent Action Guard — must enforce prohibited paths.
What is a prohibited source-to-sink path?
An architecture-defined combination you block or require human approval for — for example, web fetch content directly triggering external email send without user confirmation, or bulk export after low-trust source ingestion.
How does provenance help source-to-sink policy?
Attach source_type, source_id, and trust_tier to agent state. Policy rules and Agent Action Guard context can require review when high-impact sinks are proposed after low-trust sources such as public web fetches.
How does source-to-sink analysis apply to MCP agents?
MCP hosts aggregate multiple read sources and write sinks in one context. Screen MCP read results at the source gate, limit registered write tools via permissions, and evaluate every sink invocation with agent-action policy before MCP invoke.
Related reading
- How to Prevent AI Agents from Sending Sensitive Data
Prevent AI agent data exfiltration with least privilege, destination validation, secret scanning, and action policies be…
- How to Validate AI Tool Calls Before Execution
Validate AI tool calls with schema checks, permission evaluation, secret scanning, and policy decisions before allow, re…
- Runtime Security for AI Agents
Runtime security for AI agents — policy evaluation at tool request time, allow/review/block decisions, and integration b…
- Tool Output Injection in AI Agents
Tool output injection treats tool results as potentially hostile instructions. Learn detection, sanitization, and policy…