AI data loss prevention for agents and LLM traffic

Formal's AI DLP sits where agents and AI apps send data out: on laptops, in Kubernetes pods and in your VPC. Policies redact sensitive text before the prompt reaches the model provider, block tool calls that carry a token, and keep API keys at the proxy so agents never hold them.

policy · git tokensexample
# response rule: Agents may not put credentials in commands
AGENT  claude-cli   maya@acme.com
#      Run: git clone https://x-access-token:ghs_FAKEFAKEFAKEFAKEFAKEFAKE@github.com/acme/app.git
BLOCK  llm  Agents may not put credentials in commands

The problem

Why do security teams need AI data loss prevention?

A coding agent opens a file to debug a script, and the next request to the model provider carries those lines back as a tool result. Nothing was attached, uploaded or emailed, so a DLP rule that watches files and mail has nothing to fire on, and the provider console shows an API key rather than the person or agent behind the request. AI data loss prevention (AI DLP, also called GenAI DLP or LLM DLP) puts the check on that request.

  1. Files and pasted PII in prompts

    An agent reads a file and its next request carries the contents to the model provider. A support app sends tickets to an LLM API. Neither is a file transfer or an email your existing DLP inspects.

  2. Secrets in tool-call arguments

    The model returns a command and the agent runs it. When the agent writes $GITHUB_TOKEN into a Git URL, the shell expands it and the real token goes out.

  3. Allowed hosts as exfiltration paths

    “Going from 0.0.0.0/0 to an allowlist felt like progress, until we realized every allowed domain is still an exfiltration channel.”
    Kevin Qiu, Lead Security Engineer, Latent Health
today · no policy on the pathexample
01
claude-cli · mayatool_result customers.csv to api.anthropic.comALLOWED
02
claude-cli · mayagit clone https://x-access-token:$GITHUB_TOKEN@github.com/acme/app.gitALLOWED
03
git · child of claude-cligit push to an allowed hostALLOWED

# Without AI DLP, all three go through, and the prompt logs keep a copy nobody protects.

Definition

What is AI data loss prevention (AI DLP)?

AI data loss prevention (AI DLP)noun

AI data loss prevention (AI DLP) inspects what leaves an organization through AI traffic: the prompt, the files and tool results an agent reads into its context, the tool calls a model sends back, MCP tool parameters and the connections an agent’s processes open. It redacts, blocks or logs sensitive values before they reach a model provider or another host.
  • Not the same as AI-driven DLP

    Some vendors say DLP for AI or generative AI DLP. The term has a second meaning: AI-driven DLP, where machine learning classifies content inside a classic DLP product for email, endpoints and SaaS. That’s a detection method rather than a new channel, and it isn’t what this page covers.

  • Checks in the proxy that carries the requests

    On a macOS or Linux laptop, Transparent Mode hands an agent’s LLM connections to the Formal Endpoint, and in Kubernetes the Endpoint sits in each Pod as a sidecar. Server-side apps call a Connector in your VPC. Both evaluate the same policies at the session, request and response stages (LLM resources).

  • What leaves, not what's stored

    The AI gateway is the control point for LLM traffic: capture, identity, spend and Insights. Data masking, part of data security for AI, covers values that databases return to a reader.

Leak paths

Where does LLM data leakage happen?

LLM data leakage happens on six paths for a coding agent, and only the first involves someone typing. Each needs a check at a different point: before the request leaves, before the agent runs a command, or on the connection a child process opens.

  • Prompts

    Text a person types or pastes: a support ticket, a stack trace with a customer’s email in it.

    Before the request leaves
  • Files and tool results

    When an agent reads a file, the contents go back to the provider as a tool_result part of the next request. Passages a RAG pipeline retrieves leave the same way (RAG vs MCP).

    Before the request leaves
  • Tool-call arguments

    The model returns a command, and the command can carry a credential. When an agent writes $GITHUB_TOKEN into a Git URL, the shell expands it, so the real token ends up in the command line while the tool call only shows the variable name.

    Before the agent runs it
  • MCP tool parameters

    A tool call sends whatever the agent put in tool_params to the MCP server, including servers nobody reviewed.

    Before the server gets it
  • Child processes

    An agent starts git, curl and package managers, and their connections go to hosts other than the model provider. A destination allowlist doesn’t close this path, because the allowed hosts still accept data.

    On the connection
  • The prompt logs

    Whatever inspects this traffic also stores it, so the log becomes another copy of every prompt.

    In the log

Of the LLM security risks OWASP ranks, these fall under LLM02:2025 Sensitive Information Disclosure, and its mitigations include pattern matching to detect and redact confidential content before processing.

How it works

How to roll out AI DLP

Docs for each step: LLM resources, network rules, policy evaluation and log schemas.

  1. Step 1 of 4

    Create LLM resources

    Register each provider API whose requests you want checked, such as api.anthropic.com, as an LLM resource in the Control Plane or with Terraform.

    LLM RESOURCESexample
    • api.anthropic.com as an LLM resource✓
    • each other provider API you check✓
    • managed in the Control Plane or Terraform✓
  2. Step 2 of 4

    Intercept agent and app traffic

    Turn on Transparent Mode and write a network rule that matches known agents. Apps on servers point at a Connector in your VPC.

    INTERCEPTEDexample
    • claude-cli · maya@acme.comAGENT
    • git, spawned by claude-cliAGENT CHILD
    • support app · your VPCCONNECTOR
  3. Step 3 of 4

    Write redaction and block policies

    Add request rules that rewrite sensitive values and response rules that block tool calls with credentials. Start each one in Dry-run.

    REQUEST AND RESPONSE RULESexample
    • tool_result with 123-45-6789MASKED
    • tool_call git clone with ghs_ tokenBLOCKED
    • new rule, logged onlyDRY RUN
  4. Step 4 of 4

    Review findings and protect the logs

    Check blocked and rewritten requests and Insights in Logs, then add log schemas that encrypt prompt content before Formal stores it.

    LOGSexample
    • blocks and rewrites reviewed✓
    • LLM02 Insights forwarded to the SIEM✓
    • log.llm.messages encrypted✓

Policy example

AI DLP policy example: redact SSNs in prompts and tool results

PII redaction is the control to try first, because the agent keeps working. This request-stage policy from the policy evaluation docs rewrites the outgoing body when a text or tool result part contains a US Social Security number.

  • The tool_result check covers the file case: an SSN in a CSV the agent opened arrives as a tool result and matches the same way typed text does
  • Once one part matches, rewrite applies regex.replace to the whole HTTP body, earlier turns of the conversation included, so the replacement has to keep the JSON valid. [REDACTED-SSN] does; a replacement containing a quote or a backslash would break the request
  • The enforcement docs recommend a body rewrite over blocking the session when the goal is redaction. We’d go further: a blocked session mostly teaches people to paste the same text into a tool you don’t see
  • Start in Dry-run, which logs what the policy would do without enforcing it, and compare the bodies in the logs before you set it to Active
  • The limit is the pattern. LLM PII detection here is a regular expression: it finds 123-45-6789, not 123 45 6789 or a number split across two lines, and every new data type is one more expression to write and test
Redact sensitive prompt text ›
redact-ssn.regorego
package formal.v2

import future.keywords.if
import future.keywords.in

ssn_pattern := `\b\d{3}-\d{2}-\d{4}\b`

request := {
  "action": "rewrite",
  "body": regex.replace(input.http.body, ssn_pattern, "[REDACTED-SSN]"),
  "reason": "Redact SSNs from LLM request messages",
} if {
  input.resource.technology == "llm"
  some msg in input.llm.messages
  some part in msg.content_parts
  part.type in {"text", "tool_result"}
  regex.match(ssn_pattern, part.text)
}

Coding agents

DLP for coding agents and AI developer tools

DLP for coding agents has to cover what an agent sends without anyone typing it: file contents it reads into the next prompt, the commands the model returns as tool calls, the connections its child processes open, and its git push. Each leaves the laptop as an HTTPS or SSH connection from the agent’s process tree, so the policy starts from the process. The Endpoint recognizes 22 AI agents and coding tools, by code signature on macOS and by process name on Linux, and connections no rule selects pass through untouched. No enterprise browser or extension is involved: the Endpoint terminates the agent’s TLS with a local Formal CA, and on macOS writes the CA variables into Claude Code’s settings (Transparent Mode). Controls on what an agent may run, beyond the data it sends, are on AI coding agent security.

Prompt redaction

Redact what the agent read before it reaches the model

A request-stage rewrite swaps each matching value in text and tool_result parts for a placeholder in the request Formal forwards, so the provider never receives it and the session continues.

  • Coverage: typed text and the file contents the agent read, both checked by the same rule
  • In production: Gusto put the Formal HTTP Connector between Salesforce and its LLM provider’s API. Formal Satellites identified PII and PHI in support tickets, and the Connector masked it before the request left. Implementation took 5 days
Gusto case study ›
claude-cli · tool_resultexample
maya@acme.com> Read customers.csv
namessn
Ana Ruiz[REDACTED-SSN]
Tom Berg[REDACTED-SSN]
2 rows · policy redact-ssnMASKED
Credential injection

Keep the key on the Connector

The stronger fix for keys you control is not having them on the laptop. With credential injection, the Endpoint forwards the request to a Connector with the developer’s Formal identity, and a Native User adds the real key there, so the agent’s environment has no key to leak.

  • Injection: the Native User sends the key from the Connector’s environment as a bearer token in Authorization: Bearer
  • Scope: the Stripe guide allows only balance, charge and customer reads for a payments-engineers group and blocks every other request
  • Clients: curl still targets https://api.stripe.com, and .env files and shell profiles hold no Stripe key
  • Anthropic key: our post on proxying Claude Code does the same for the Anthropic key, and the Claude Code page covers the setup
stripe · keep keys off laptopsexample
maya · curlGET api.stripe.com/v1/balanceALLOWED
native user stripe-api-keyAuthorization: Bearer <STRIPE_API_KEY>TOKEN INJECTED
maya · curlPOST /v1/refunds: This Stripe request is not allowedBLOCKED
Agent egress

Data exfiltration prevention for AI agents

The agent process itself is rarely what moves the data out. A git push, a curl or a package publish started from its shell does, to a host that’s often on the allowlist. Network rules on the Endpoint select flows by process, so a policy can treat the agent’s curl differently from the same command in the engineer’s own terminal.

  • Process tree: on macOS, process.has_agent_ancestor is true for a known agent and every process it spawns, matched by code signature; on Linux, the agent flags match process names
  • Recipe: in the Codex Desktop recipe, Codex Desktop and its children may send classified LLM traffic and reach named MCP resources, while its built-in search, and browsers it launches, are blocked
  • Pushes: block agent git pushes to sensitive repositories over SSH and HTTPS, while clones and fetches keep working
  • MCP: request-stage policies block or rewrite a tool call by input.mcp.tool_name and tool_params. The response stage supports only allow and encrypt, so Formal doesn’t mask what an MCP server returns (MCP resources). A local stdio server the agent starts itself never reaches the proxy
  • Related: which tools agents may call is the MCP gateway’s job, and which hosts they may reach is the secure web gateway‘s, with background in egress filtering and SSL inspection
MCP gateway ›
policy · codex-desktop-egressexample
codex desktopllm traffic to the model providerALLOWED
codex desktopmcp web-search-mcpALLOWED
codex desktop/backend-api/codex/alpha/search: use an approved MCP serverBLOCKED
Detection

OWASP LLM02 findings for what policies miss

A policy catches only what someone wrote a rule for. Formal’s Insights engine reviews new LLM traffic every 15 minutes against the OWASP Top 10 for LLM Applications (2025), and LLM02 is the category for secrets or personal data sent to a model. Insights never change anything on their own.

  • Findings: each names the entity and the log events behind it, and goes to Datadog, Splunk, Amazon S3, Google Cloud Storage or Azure Blob Storage with your other logs
  • Assessments: Assessments score each tool call for risk and for how well it matches what the user asked, and a response policy can block when input.assessment.risk crosses a threshold. Only LLM responses with tool calls get those scores
  • Next rule: a recurring LLM02 finding is usually the cue for the next pattern rule
AI gateway: capture, Insights and spend ›
insights · llmexample
every 15 mininsightsnew LLM requests and responses checkedALLOWED
LLM02claude-cli for mayaSensitive Information Disclosure finding sent to the SIEMREVIEW

Policy example

Secrets in coding agent tool calls

Secrets tend to leave in a different place from PII. The model returns a tool call, such as a Bash command, and the agent runs it, so the check belongs on the response, before the command executes. The Git tokens guide blocks any LLM response whose tool-call arguments contain a GitHub token prefix or a URL with credentials.

  • The first pattern works because GitHub prefixes each token type: ghp_, github_pat_, gho_, ghu_, ghs_ and ghr_
  • The second exists because of shell expansion. An agent that writes x-access-token:$GITHUB_TOKEN@ never puts the token in its tool call, so the prefix check sees nothing, but the URL still has the shape of a URL with credentials
  • The rule matches common formats, and some secrets slip through. The guide is upfront about what gets past it: tokens Git reads from a credential helper or a script file, and variables expanded anywhere other than a URL
  • For intercepted connections, the Endpoint records the command line of the connecting process and its ancestors, as-is. Formal redacts the Authorization header Git sends but not the command line, which is why the guide adds a log schema that encrypts command lines and tool-call inputs on the device
Protect Git tokens in command lines ›
protect-git-tokens.regorego
package formal.v2

import future.keywords.if
import future.keywords.in

credential_patterns := [
  `\b(gh[opsur]_|github_pat_)[A-Za-z0-9_]{20,}`,
  `https?://[^\s/@:]+:[^\s/@]+@`,
]

passes_credential(call) if {
  walk(call.input, [_, value])
  is_string(value)
  some pattern in credential_patterns
  regex.match(pattern, value)
}

response := {
  "action": "block",
  "type": "block_with_formal_message",
  "reason": "Agents may not put credentials in commands",
} if {
  input.resource.technology == "llm"
  some call in input.llm.tool_calls
  passes_credential(call)
}

Logs

Prompt logs are sensitive data too

The proxy that redacts a prompt also writes it to the activity log, and that log can hold more than the provider received.

  1. Find every copy

    For HTTP bodies, Formal stores received and sent, the body before and after policies run, so the value a rewrite removed is still in the received copy. LLM content appears twice more, under log.llm and log.request.http.llm.

  2. Encrypt, drop or truncate the paths

    Log schemas act on log.llm.messages, response_messages, tool_calls.input and events.data, plus the copies nested under the HTTP request.

  3. Scope the schema

    A log.source condition limits a schema to Endpoint or Connector logs.

  4. Or drop prompts entirely

    To remove prompts from the logs instead, use a single drop path on log.llm.messages.

  5. Set input retention on LLM resources

    Log schemas don’t apply to retained policy inputs. With Policy Evaluation Input Retention on, Formal keeps each input in full for the period you set, between 0 and 30 days (logs docs). Retention can be set per resource, so you can keep it short, or at 0, on LLM resources.

Comparison

AI DLP vs traditional DLP

Traditional DLP watches files, email, devices and SaaS storage. AI DLP watches the requests agents and AI apps make. Neither replaces the other. The usual objection to proxy-based DLP for LLM traffic is that it only sees what crosses a proxy. That’s true, which is why the Endpoint lives on the device: on macOS and Linux laptops, a coding agent’s provider calls and the processes it starts are on the path without a base URL change, and anything the network rules don’t select passes straight through, unlogged. Keep your existing DLP for USB, email and SaaS, and put AI DLP where prompts and tool calls leave.

Traditional DLPFormal
Prompts and file contents sent to a model providerOnly if it inspects provider API traffic inlineRequest-stage redaction or block on proxied LLM traffic
Tool calls returned by the modelOnly if it parses the provider's response formatResponse policy blocks the call before the agent runs it
MCP tool parametersOnly if it parses MCP requestsRequest-stage block or rewrite
Connections from an agent's child processesOnly if it ties connections to the agent's process treeNetwork rules by process, children included
API keys used by agentsScans for keys in the content it inspectsCredential injection: the key stays on the Connector
USB, clipboard, print, screenshotsEndpoint DLPNot covered
EmailEmail DLPNot covered
How a sensitive value is foundBuilt-in detectors, often with ML classifiersRegular expressions you write in Rego policies
File and image contentsContent inspection, with OCR in some productsNot documented: policies run on text and tool results
Employee AI use in the browserBrowser extension or enterprise browserNot documented
SaaS data at restSaaS or data security scanningNot covered
Windows laptopsWindows endpoint agentNot yet: no Transparent Mode on Windows
MCP server responsesn/aAllow or encrypt only, no masking

Works with

Works with the agents and apps that send your data

The same DLP policies on laptops, in pods and on servers. Coding agents keep calling their provider: on macOS and Linux, Transparent Mode hands the connection to the Endpoint first, with no base URL change. Agents and services in a Pod get the Endpoint as a native sidecar. Server-side apps call the Connector’s hostname, such as https://anthropic.<connector-hostname>/v1/messages. Findings go to your SIEM.

LLM resources docs ›

In production

Implementation
5 days
Requests secured
100K+
Businesses
300K+
Employees
2,400
“Formal Satellites simplified ensuring any PII or PHI entities between Salesforce and our LLM provider were automatically detected and masked, without needing detailed data structure knowledge.”
Ian Wardell
Data Privacy Lead, Gusto
Read the Gusto story ›

FAQ

Questions about AI data loss prevention

Buying and fit

Is AI DLP the same as AI-powered DLP?

No. AI DLP, also sold as LLM DLP or GenAI DLP, is DLP for AI traffic: it inspects prompts, tool calls and agent egress. AI-powered or AI-driven DLP uses machine learning to classify content inside a traditional DLP product. One product can do both, so ask two separate questions when you compare them: which AI traffic does it actually see, and how does it detect a sensitive value.

Is DLP outdated?

No. Endpoint, email and SaaS DLP still cover USB drives, attachments and files at rest, and Formal doesn’t. The new channel is API traffic: agents send data in requests to model providers and MCP servers, which a file or email rule never inspects. Run both, with AI DLP at the point where prompts and tool calls leave.

Does DLP stop shadow AI?

Only for the AI tools whose traffic passes through a control. DLP can redact or block what goes to a tool it sees, but it doesn’t tell you which tools exist. Formal Endpoint finds MCP servers and Claude Code skills outside your Catalog in intercepted traffic and queues them for review, covered on shadow AI detection.

AI agents

Can my DLP stop code leaving through AI tools?

Not if it watches files, email and devices. Source code reaches the model provider inside an HTTPS request, as the tool_result of a file the agent read. Formal sees that request on proxied LLM traffic, but a regular expression can’t tell your code from anyone else’s. DLP for coding agents therefore controls where code may go: network rules keep an agent on the LLM resources and MCP servers you approved, and a policy blocks agent pushes to sensitive repositories. Redaction handles the secrets and PII inside the code.

Product

Can AI DLP work without storing employee prompts?

Formal has to read a prompt to check it, but it doesn’t have to keep it. A log schema with one drop path on log.llm.messages removes prompts from the logs, or encrypt paths keep them unreadable without your key (log schemas). The HTTP received and sent bodies need their own paths. Log schemas don’t apply to retained policy inputs, so set Policy Evaluation Input Retention to 0 days on LLM resources if no copy may be stored.

Does AI DLP work on Windows laptops?

Not with Formal yet. The Windows Endpoint has no Transparent Mode or network rules so far, and LLM resources don’t support formal connect, so LLM traffic from Windows laptops isn’t inspected today. Apps on any operating system can still route their LLM traffic through a Connector (Windows docs).

Can AI DLP catch every secret?

No. A pattern can’t reliably recognize a secret with no fixed shape, such as a database password, so AI DLP rules work best on prefixed formats. If your own services issue tokens with a fixed prefix, add it to the credential patterns next to GitHub’s. Anything without one is better handled by keeping it off the device, which is what credential injection does.

Stop sensitive data at the proxy

AI DLP for coding agents and AI apps, with every redaction and block logged under the person who sent it.