Dataflow security for AI agents is about controlling where data can go after an agent has read it, not just what it is allowed to read. Egress controls that hold are enforced outside the model. That means a default-deny network proxy, tools scoped to specific destinations, session rules that tighten once sensitive data is in context, and filtering on anything that leaves. A system prompt that says “never share customer data” is a preference, not a control, and a single prompt-injected email or web page can override it.
The rest of this article covers why agents make exfiltration easier than traditional applications, the four layers of egress control we would put in place, how those map to GDPR, and how to test that the controls actually work.
Why agents turn reading into leaking
A conventional integration has fixed code paths. If an invoice service reads a supplier record, it writes to the ledger and nowhere else, because nobody wrote code to do anything else. An agent chooses its code path at runtime, based on text. Some of that text comes from sources you have no reason to trust: inbound emails, uploaded PDFs, web pages, support tickets, calendar invites and issue comments.
The dangerous combination is well understood by now. Suppose an agent can access private data, ingests untrusted content and can communicate externally. That untrusted content can then instruct it to send the private data out. Each capability is harmless on its own. Together they create an exfiltration path that needs no vulnerability in your code, just a sentence in a document. The OWASP GenAI Security Project puts prompt injection and sensitive information disclosure near the top of its LLM risk list for exactly this reason. Models are getting better at resisting injection, but a good benchmark score is a probability, not a boundary. You design as though the model will eventually be fooled.
The exfiltration channels people forget
Outbound HTTP calls and email are the obvious channels. The ones that get missed are subtler:
- Rendered markdown. A chat interface that auto-loads images will fetch attacker.example/pixel.png?d=… the moment the model outputs it. No tool call is required.
- Query strings on “read-only” fetches. A browsing tool that only makes GET requests can still carry data out in the URL path or parameters.
- Allowlisted but shared domains. Public gists, paste sites, generic cloud storage, form builders and shared documents are writable by anyone. Allowing the whole domain allows the attacker’s bucket too.
- DNS. If the sandbox can resolve arbitrary names, a subdomain lookup becomes a data channel.
- Write tools on third-party SaaS. A ticket comment, a CRM note or a calendar invite with an external attendee is an outbound message.
- Your own telemetry. Prompts and tool results shipped to a tracing or logging vendor are a data flow. It is often the largest one, and it rarely appears in the DPIA.
Four layers of egress control
No single layer holds on its own. The aim is that any one failure still leaves other controls between your data and the outside world. The model might be fooled, a tool might be misconfigured, or a domain might be allowed too broadly. This is the agent-specific version of the map, restrict and audit approach in our piece on dataflow security in AI pipelines.
1. Network: default-deny egress
The agent runtime should have no direct route to the internet. Put it in a container or VM on a network segment whose only way out is a forward proxy with an explicit allowlist of hostnames. Squid, Envoy or your cloud provider’s egress firewall will all do the job. Pin DNS to a resolver you control, and block other port 53 traffic and known DNS-over-HTTPS endpoints. Then be stingy with the allowlist. Allow api.yourcrm.com, not *.yourcrm.com. Never allow a general storage domain unless the storage layer can restrict it to your own buckets.
This layer is crude, and that is its strength. It does not care how clever the injection was: if the destination is not on the list, the request does not leave. It also gives you a single log of every outbound attempt. A denied request from an agent is one of the most useful security signals you will get, so alert on it rather than letting it scroll past.
2. Tools: least privilege by capability
Least privilege for tools means scoping each tool to the narrowest action and destination the job needs, not to the vendor’s whole API. A generic send_email tool that accepts any recipient is an exfiltration primitive. A notify_finance_team tool with a fixed recipient list and a templated body is not. The same applies to HTTP. Replace a general fetch tool with specific ones, such as get_exchange_rate or lookup_company_record, that build the request in code. The model supplies parameters but never the URL.
Split read and write tools and give them different credentials. If your agents use MCP, give each server its own scoped token rather than sharing one broad service account. As MCP adds long-running tasks and distributable skills (covered in MCP turns two), the number of tools an agent can reach will grow faster than any review process.
Keep secrets out of the context window entirely. Credentials injected at the tool layer cannot be echoed by the model. That is the idea behind 1Password’s agentic mode for Claude, where agents log in without ever seeing the secret.
3. Data: let what the agent has touched change what it can do
Static permissions miss the fact that risk depends on session state. An agent that has only read a public pricing page can safely draft an email to a prospect. The same agent, after reading a customer’s account history, should not be able to email an arbitrary external address.
The practical pattern is taint tracking at the orchestration layer, in three steps:
- Label each data source: public, internal, personal or special category.
- Record in session state the highest label the agent has read.
- Have the tool router refuse or escalate external-destination tools once that label crosses a threshold.
Deterministic code makes the decision, not the model. It is the same principle as combining LLM output with rule-based decisions: the model proposes, the rules dispose.
For untrusted content, a quarantine pattern adds another barrier. A model with no tools reads the inbound email or document and extracts structured fields from it. Only that structured output reaches the privileged agent. This does not make injection impossible, but it removes the free-text channel most injections travel through. It also makes the remaining attack surface small enough to reason about.
4. Output: filter and render safely
Everything that leaves passes through a final check: tool arguments, message bodies and anything rendered in a UI. Strip or proxy images and links in rendered output so nothing loads automatically. Scan outbound payloads for things that should never leave through that channel, such as IBANs, PPS numbers, card numbers, API key formats and large base64 blobs.
Treat this layer as a backstop. Pattern matching is easy to evade if an attacker asks the model to encode or paraphrase the data. It catches mistakes and lazy attacks, not determined ones.
Which controls stop what
The table below is the comparison we use when deciding where to spend effort on a given agent. Read the “misses” column as carefully as the “stops” column.
| Control | What it stops | What it misses | Effort |
|---|---|---|---|
| System prompt instructions | Accidental oversharing by a cooperative model | Any successful injection | Minimal |
| Default-deny egress proxy | Calls to unapproved hosts, DNS tunnelling | Leaks via allowlisted, attacker-writable destinations | Low to moderate |
| Capability-scoped tools | Arbitrary recipients and URLs | Misuse of legitimate destinations, such as a CRM field visible to outsiders | Moderate |
| Session taint rules | External sends after sensitive reads | Internal destinations that have external visibility | Moderate to high |
| Output DLP and safe rendering | Pixel exfiltration, obvious identifiers | Encoded or paraphrased data | Low |
| Human approval on external sends | Most remaining cases, if reviewers actually read | Approval fatigue on high-volume flows | Ongoing |
GDPR and agent data flows
Under the GDPR, every place an agent can send personal data is a data flow you are accountable for. Four obligations apply directly:
Article 30 requires a record of processing. Article 28 requires a contract with every processor. Chapter V governs transfers outside the EEA. Article 32 requires security appropriate to the risk.
An agent with open internet access makes all four unanswerable, because you cannot list the recipients. An agent behind a default-deny proxy turns its allowlist into a draft of the recipient list your records need. The security control and the compliance artefact become the same document, which also makes both easier to keep current.
Three flows tend to be underestimated:
The model provider. Prompts containing personal data go to whoever hosts the model, so region, retention and training-use terms all matter. Where those terms are a problem, an EU-hosted or self-hosted model may be the answer.
Observability. Full prompt and tool-result traces in a third-party tool are a copy of your most sensitive data, with its own retention period and its own sub-processors.
Agent memory. An agent that writes summaries to a long-term store is creating new personal data. Those records need a lawful basis, retention rules and a way to honour erasure requests.
Our practical DPIA walkthrough for AI data flows covers how to document all of this in a form a DPO will accept.
Testing that the controls hold
Controls you have not tested are assumptions. The cheapest useful test is a canary run, in four steps.
First, plant a unique fake value in the data the agent can read, such as a made-up customer record with a distinctive email address and account number. Second, feed the agent untrusted content containing an injection that asks it to send that record to an endpoint you control. Third, try every channel you can think of: email, web fetch, image markdown, a ticket comment and a DNS lookup. Fourth, watch both your endpoint and the proxy logs.
Anything that arrives at the endpoint is a hole. Anything blocked at the proxy shows one layer doing its job, and tells you which upstream layer failed to stop it first.
Repeat the run whenever you add a tool, change model version or widen the allowlist. Keep the injection set in version control alongside the agent code so it runs like any other regression test. Model behaviour shifts between versions. The allegations in California’s suit against OpenAI over agent sandbox escapes are a reminder that containment is something you verify, not something you assume.
The same layered thinking applies at small scale. Our write-up on two Claude Code accounts, one home lab and six locks in between is what that looks like when we run it in our own lab.
What we would do first if this were our business
Start with an inventory, not a platform purchase. In a day, list every agent or LLM workflow in production or pilot. For each one, record every tool it can call, every credential it holds and every destination those tools can reach, including the model provider and the logging stack. Look specifically for generic send or fetch tools and for shared credentials, because those are the first things to fix.
In week one, route the riskiest agent through a default-deny proxy and replace its generic tools with scoped ones. In week two, add a session taint rule for external sends and run the canary test. DLP, quarantine models and approval flows all build on top of those foundations. Without the foundations, they are decoration.
This is the work D3X Solutions LABS does. We start by mapping an agent’s real data flows, then design and build the egress, tool-scoping and policy layers around it. We also set up canary tests so your own team can keep verifying the controls after the build is finished. If you are deploying agents that touch customer or financial data and want a second pair of eyes on where that data can end up, book a free 30-minute call using the form below.
Frequently Asked Questions
What is dataflow security for AI agents?
It is the practice of controlling where data can travel once an AI agent has read it, not just which data it can access. In practice that means network egress allowlists, tools scoped to specific destinations, session-aware rules and output filtering, all enforced outside the model so a prompt injection cannot bypass them.
Can a system prompt stop an AI agent from leaking data?
No. Instructions in a system prompt shape a cooperative model’s behaviour, but untrusted content such as an email or web page can override them through prompt injection. Treat prompt instructions as a convenience and put the real controls in the network, the tool layer and the orchestration code.
How do AI agents exfiltrate data without an obvious send tool?
Common channels include auto-loaded markdown images, query strings on read-only web fetches, DNS lookups, and comments or notes written to third-party SaaS tools. Logs and traces sent to an observability vendor are also a data flow that is easy to overlook.
What does least privilege mean for AI agent tools?
It means each tool does one narrow action against a fixed destination, with its own scoped credential, rather than exposing a vendor’s whole API. For example, a tool that notifies a fixed internal team is far safer than a generic email tool that accepts any recipient, and the model should supply parameters, never URLs.
How does GDPR apply to AI agent data flows?
Every destination an agent can send personal data to falls under your record of processing (Article 30), your processor contracts (Article 28), the international transfer rules (Chapter V) and your security obligations (Article 32). A default-deny egress allowlist doubles as the recipient list you need, so agents with open internet access are very hard to make compliant.
How can I test whether my agent’s egress controls work?
Run a canary test: plant a unique fake record in the agent’s data, then feed it an injection asking it to send that record to an endpoint you control through every channel available. Anything that reaches your endpoint is a gap. Repeat after every tool, model or allowlist change.
Want this working in your business?
D3X Solutions LABS builds AI agents and automation that pay back fast. Not sure where to start? A free 30-minute call is enough to find the first thing worth building.
Get in touch






