A common question comes up frequently in security teams: “We blocked ChatGPT, so why is internal data still leaking?” Despite deploying URL blocking, DLP regex, and employee training, leak incidents continue. When the root cause is traced, the problem is not what employees type into their browsers—it is the officially approved internal AI agent that holds broad OAuth scopes to Drive, SharePoint, and internal databases while calling LLMs. Policies that only block consumer LLM websites can no longer explain governance.
Existing AI blocking policies all assume ‘human’ behavior. Consumer LLM domain blocking, prompt payload regex, and endpoint keyloggers are all designed to catch the moment an employee types or pastes something in the browser. Officially approved agents, however, operate through a different path. They receive tokens through OAuth flows, connect directly to company data stores via standard interfaces such as MCP, and their permissions are indistinguishable from a person accessing data individually. When full Drive read access is granted once to an agent service account, the agent can perform legitimate work like ‘contract review’ while simultaneously pulling HR evaluations and undisclosed financial data from other folders into the LLM context.
Why blocking alone is not enough—the real leak path is ‘delegated permissions’
To close this gap, AI agent permission governance must be redesigned around ‘agent identity’ rather than ‘human input.’ The core is ① minimum scope per agent, ② service accounts separated by work unit, ③ proxy-based token-level DLP and bidirectional logs—operating these three axes simultaneously. Enforcing only one axis lets leaks route around through another path, and organically combining minimum-privilege scope, dedicated identity, and bidirectional audit logs is what field practitioners agree creates real effectiveness.
From the blocking policy’s perspective, there is no signal to distinguish whether the call is legitimate work traffic or a data exfiltration attempt. As a result, even the most sophisticated enterprise DLP creates a situation where incidents cannot be traced after the fact. The center of gravity in governance must shift from ‘where is it called from’ to ‘whose credentials delegated which scope.’
Scope—Slice AI agent permissions down to the work unit
The first area to address is the Drive, SharePoint, and RDB IAM policies. When an agent receives a task such as ‘review Company A’s contract,’ dynamic scopes should be granted so that only the folder and table mapped to that ticket are read- and writable. AWS Bedrock Agents limits the call context through IAM session policy and encrypts model invocation logging with KMS for retention. Azure AI Foundry and Google Vertex AI Agents similarly require, as a standard, managed inference endpoints with an explicit Zero Data Retention option, where data is inferred only within the customer tenant.
# Enforcing per-agent scope via LiteLLM Proxy policy headers (Illustrative Example, not official spec)
# In production, replace with IdP group and IAM role mapping
curl -X POST http://litellm.internal/v1/chat/completions \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "X-Agent-Scope: drive:folder/CONTRACT-2026-Q4-A" \
-H "X-JIT-TTL: 900" \
-d '{"model":"claude-3-5-sonnet","messages":[{"role":"user","content":"Summarize the key clauses of the Company A contract"}]}'
Scope should be cut not at the ‘agent ID’ level but at the ‘work ticket ID’ level. A short TTL of 15 to 30 minutes is granted, and the design ensures automatic revocation after expiration. Each time the same agent receives a new task, new temporary credentials must be issued. The pattern of granting a large OAuth scope at once and narrowing it later makes post-incident response nearly impossible. The immediate-revocation pattern covered in AI Agent Identity Separation: 5 Steps to Immediate Revocation is the starting point for this stage.
Identity—Separate service accounts by work and integration unit
Even when scopes are sliced finely, if it is unclear ‘whose permissions’ they are being invoked under, post-hoc traceability breaks. If the same agent handles HR, sales, and engineering integrations all together, audit logs cannot separate which data went out under whose authority. The standard pattern is to issue dedicated service accounts for agents at the IdP (Okta, Entra ID) level, and to maintain a separate workload identity for each integration and project.
Session tokens must record the calling principal, work ticket, and expiration time, and this information flows to the LLM gateway and is automatically joined with downstream logs. Human accounts and agent accounts must follow clearly different lifecycles. Human accounts are revoked at termination, but agent accounts must have their tokens recalled as soon as a task ends. Separating identity naturally follows when applying the workload identity federation and periodic key rotation principles from the 90-day zero-trust roadmap emphasized in the MFA limits and bypass response article.
Audit—Combine the LLM gateway with enterprise DLP
The third axis is bidirectional logging. All outbound traffic to OpenAI, Anthropic, and Google APIs is funneled through gateways such as LiteLLM Proxy, Portkey, and Cloudflare AI Gateway for token-level inspection. Not only prompts but also responses must be retained as logs on the same gateway, so that post-hoc reproduction of “which data was sent to which external LLM in what form” is possible. Enterprise DLP solutions such as Microsoft Purview DLP, Palo Alto Networks AI Security, and Harmonic Security detect PII, customer code, and internal hostname patterns in front of this gateway.
| Gateway | Deployment | Key features | Suitable environment |
|---|---|---|---|
| LiteLLM Proxy | Self-hosted | OpenAI-compatible API, multi-model routing, token-level DLP hooks | Multi-cloud, Kubernetes-friendly |
| Portkey | SaaS + self-hosted | Observability, fallback, A/B routing, policy engine | LLM workflow standardization |
| Cloudflare AI Gateway | SaaS | DDoS protection, caching/cache invalidation, Workers integration | Cloudflare ecosystem-dependent organizations |
# LiteLLM config excerpt (Illustrative Example, not official spec)
model_list:
- model_name: claude-3-5-sonnet
litellm_params:
model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
aws_region_name: ap-northeast-2
aws_session_token: os.environ/JIT_AGENT_TOKEN
litellm_settings:
drop_params: true
request_timeout: 30
success_callback: ["prometheus", "s3"]
failure_callback: ["slack"]
general_settings:
drop_params: true
master_key: os.environ/LITELLM_MASTER_KEY
Unidirectional auditing that only collects prompts without logging responses is the most common anti-pattern. Even when an actual data leak occurs, it cannot be proven after the fact that “internal data was included in the external LLM response and returned.” Response logs must also be retained, but a retention policy must be set to automatically expire and cryptographically erase after 30 to 90 days to also address GDPR and personal information protection law compliance. Both LiteLLM and Portkey can stream logs to S3, GCS, and BigQuery, so folding them directly into an existing SIEM pipeline is the way to reduce operational burden.
Endpoint and network secondary/tertiary defense layers
If the three axes are the first line of defense, enterprise browsers, EDR, and CASB form the secondary and tertiary defense layers. Microsoft Edge for Business, Chrome Enterprise Premium, and Prisma Access Browser classify the generative AI site category and block personal account logins. EDR solutions such as CrowdStrike and SentinelOne trigger blocks and alerts when unknown agent harnesses (AutoGPT variants, local LLM clients, etc.) are installed. SaaS CASB solutions (Microsoft Defender for Cloud Apps, Netskope) track the flow of Drive shared links into AI workflows.
The key value of this layer is ‘visibility into bypass paths.’ Even when the agent is not an officially approved one covered by first-line controls, it catches the moment an employee installs a local LLM client on their laptop or signs up for a Shadow AI SaaS with a company email. It does not prevent leaks on its own, but it becomes the baseline that distinguishes legitimate traffic defined by first-line controls from abnormal traffic. Combined with zero-trust NAC, calls to the gateway from devices whose posture does not meet requirements can be rejected entirely, serving as a safety net for first-line controls.
Vendor governance and legal review
Separate from technical controls, AI vendors must be explicitly named as sub-processors in contracts, and the Zero Data Retention option must be made mandatory. Standard clauses should include a provision that inputs and outputs from LLM API calls are not used for vendor training, a 72-hour incident notification obligation, and an audit log delivery obligation. AWS Bedrock, Azure OpenAI Service, Anthropic Enterprise, and Google Vertex AI all offer explicit ZDR options, but even when calling the same model, the retention policy differs by API key type (e.g., a general API key versus an Enterprise tenant key), so operations and legal teams must review together.
Operational limits and common anti-patterns
Five anti-patterns frequently seen in the field are summarized below. If even one of these is missing, post-incident response is effectively impossible.
| Anti-pattern | Actual impact | Correct pattern |
|---|---|---|
| Granting full Drive read OAuth to an agent then narrowing it later | Cannot reproduce which folders were accessed post-hoc | Ticket-level Just-in-Time scope |
| Bypassing security review citing only work efficiency | Shadow AI spreads, responsibility unclear | Mandatory security team approval gate |
| Business unit alone decides on AI tools | No catalog, duplicate introduction | Internal AI catalog + central governance |
| Direct LLM API call without a proxy | Loss of token-level DLP and cost visibility | LLM gateway standardization |
| Collecting only prompt logs | Cannot prove response data leakage | Request/response bidirectional logs + retention |
On the cost side, additional infrastructure costs arise from introducing the LLM gateway and managed inference endpoints. LiteLLM Proxy is at the container cost level when self-hosted, but as traffic grows, Redis and Postgres backends must also be operated. Portkey and Cloudflare AI Gateway start with SaaS pricing, but cost increases linearly for large-scale log retention. Bedrock, Foundry, and Vertex themselves also apply per-token billing, so controlling token usage through scope minimization directly equates to cost optimization. In terms of cross-team collaboration, the RACI where the security team defines only scope policy and agent developers automate it through IaC has the fewest conflicts.
What to do right now
- Build an inventory of AI agents operating in-house, and map the OAuth scopes each agent holds to the connected data stores.
- Check network logs for one week to see if there is any traffic directly calling OpenAI, Anthropic, or Google APIs, and add firewall rules to force-route all of it through the LLM gateway.
- Pilot-deploy LiteLLM Proxy or Portkey scoped to one workflow, and verify that bidirectional logs for prompts and responses are delivered to S3 or SIEM.
- Issue dedicated service accounts for agents from the IdP, and reorganize them into groups and policies separate from existing human accounts.
- Create a quarterly agent permission audit process, and reflect in IaC the automatic revocation of unused scopes, expired tokens, and accounts linked to departed employees.
The essence of in-house AI security ultimately boils down to the question, “How far, under whose authority, and for how long should data be entrusted?” As the field’s concerns discussed in the original thread show, blocking policies alone can no longer explain governance. Splitting AI agent permissions across the three axes—scope, identity, and logs—and building a structure that combines at least six detailed controls (dynamic IAM, dedicated SAs, bidirectional proxy, token DLP, temporary credential revocation, storage encryption) on top of that three-axis governance is the most realistic starting point for bringing data leak incidents into a post-hoc traceable state.
Source
This article was written after checking the following original thread: r/AskNetsec — How do you let staff use AI without company data leaking out?

