How Do Enterprises Stop Claude Code and AI Coding Assistants From Leaking Source Code?
Enterprises stop AI coding assistants leaking source code by pairing tool controls with DLP that sees code leave. Learn the 4 leak paths and 6 controls that work.
.jpg)
Key Takeaways:
- Enterprises stop source code leaking through AI coding assistants by combining controls on the tool, such as approved accounts, read limits, and network limits, with data loss prevention (DLP) that sees code leaving through the developer.
- Code leaves through four paths: the assistant's normal calls to its model provider, developers pasting code into chat tools and personal accounts, agents running commands and tools, and retained transcripts and logs.
- Anthropic, GitHub, and OpenAI say their business plans don't train models on customer code by default. That settles training, not exposure.
- ORION Security classifies source code and secrets, traces copied code back to the repository it came from, and tells approved AI accounts from personal ones in supported AI tools.
Stack Overflow's 2025 Developer Survey found that 84 percent of respondents use or plan to use AI tools in their development process. Engineering teams can keep those assistants while security knows what code moved, where it came from, and where it went.
How Source Code Leaks Through AI Coding Assistants: 4 Paths
Source code leaves through four paths. The assistant sends files and context to its model provider as part of normal use. Developers paste or upload code into chat tools, sometimes on personal accounts. Agents run commands and tools that can move code elsewhere. And transcripts, logs, and retained prompts become extra copies of the code.
The Assistant Sends Code to Its Provider by Design
An assistant sends the open file, nearby files, and the developer's prompt to a model. That's expected. The questions are which provider, which account, how long the data is kept, and whether it trains anything.
Developers Paste Code Into Chat Tools and Personal Accounts
No tool setting governs this path. A developer copies a function out of the IDE and pastes it into a chat assistant, or into a coding tool signed in to a personal account, as Samsung engineers did with ChatGPT. Most of these pastes are accidents of convenience, and a test key often rides along.
Agents Run Commands, Tools, and MCP Servers
Coding agents read files, run shell commands, and call tools through Model Context Protocol (MCP) servers. A poisoned README, issue, or dependency can carry instructions that turn an agent against the repository it's working in, which is how prompt injection becomes a leak path. Our guide to Claude Code security walks through that threat model for one agent, and DLP for AI agents covers the wider problem.
Transcripts, Logs, and Retained Prompts
Every session leaves copies. Providers keep prompts for a set period, and Anthropic's data usage page says Claude Code stores session transcripts locally in plaintext for 30 days by default. A transcript holding a function is a copy of that function.
Do AI Coding Assistants Train on Your Source Code?
Not on business plans, by default. Anthropic, GitHub, and OpenAI say their business and enterprise offerings don't train models on customer code unless the customer opts in. That settles training, not exposure: prompts are still retained for a period, local session files keep copies, and personal accounts often sit under consumer terms.
Here's what each publisher says about its own terms. Anthropic says it doesn't train generative models on code or prompts sent to Claude Code under commercial terms, unless the customer chooses to provide data for model improvement, and keeps commercial data for 30 days as standard. GitHub's Copilot policy page says it doesn't use Copilot Business or Copilot Enterprise customer data to train AI models. OpenAI's Codex pricing page lists no training on business data by default for its Business plan.
Consumer plans differ. Since April 24, 2026, GitHub says it may use interactions from its Free, Pro, Pro+, and Max plans for training unless the user opts out, and Anthropic leaves the choice to the account holder on its consumer plans. Company code worked on in a personal plan falls under that plan's terms.
Private Model Routes and Zero Data Retention
Some companies send coding assistant traffic through their own cloud account instead of the vendor's. Claude Code can run through the AI platforms of AWS, Google Cloud, and Microsoft, and Anthropic offers zero data retention to qualified Claude for Enterprise accounts, enabled per organization. Neither route changes what a developer can paste elsewhere, which our guide to DLP for Claude covers across Claude's other surfaces.
The 6 Controls That Stop AI Coding Assistants Leaking Source Code
Enterprises combine six controls: approved accounts and model routes, limits on what the assistant can read, settings locked centrally, sandboxing with restricted outbound network access, secrets kept out of the workspace, and an allowlist for MCP servers and extensions. Each one narrows what the tool can do. None of them reads what the code is.
| Control | What it stops | Where it stops |
|---|---|---|
| Approved accounts and model routes | Code going to a provider or plan the company hasn't approved | A developer using a personal account or a different tool |
| Limits on what the assistant can read | The assistant pulling sensitive files into its context | Indirect access, such as a command that reads the file for it |
| Managed settings | Developers loosening permissions on their own machines | Tools and machines outside central management |
| Sandboxing and outbound network limits | Commands sending data to unknown hosts | Approved hosts, and anything copied out by hand |
| Secrets kept out of the workspace | Live credentials ending up in prompts and context | Test keys and secrets already committed to code |
| An allowlist for MCP servers and extensions | Unvetted tools reading or sending repository content | Approved tools that behave badly |
Approved Accounts and Model Routes
Buy business seats and require single sign-on. That puts the assistant's own traffic under business terms. It does nothing for a developer who opens a second tool on a personal account.
Limits on What the Assistant Can Read
Most assistants let administrators exclude files or folders from what the tool reads. GitHub's own content exclusion documentation says it isn't a substitute for operating-system permissions or other access controls, and that agents might not detect indirect file access.
Settings Locked Centrally
Assistants that support managed settings let security set permissions, approved tools, and network rules once, so a developer can't loosen them locally. Claude Code's own built-in controls, and where they stop, are covered in our Claude Code security guide.
Sandboxing and Outbound Network Limits
A sandbox with outbound traffic limited to approved hosts keeps a hijacked command from sending a repository to an unknown server. It doesn't stop a developer's paste into a browser tab.
Secrets Kept Out of the Workspace
Keep live credentials in a secrets manager, not in files the assistant can read, and keep scanning commits. GitGuardian's State of Secrets Sprawl 2026 found Claude Code-assisted commits showed a 3.2 percent secret-leak rate, against a 1.5 percent baseline across all public GitHub commits, and says the gap shouldn't be read as a simple tool failure.
An Allowlist for MCP Servers and Extensions
Each MCP server or extension can read what the assistant reads and send it elsewhere. Approve them like any software that touches source code, and remove the rest.
Can DLP Stop AI Coding Assistants From Leaking Source Code?
Partly. DLP sees code leaving through the developer: a function pasted into a chat tool, a file uploaded to a personal account, a repository copied somewhere unmanaged. It adds little on the approved assistant's own calls to its provider, which a gateway governs. The test is whether it knows which repository the code came from.
Keyword patterns struggle with code. A function has no account number to match, so pattern-based DLP either misses it or flags every snippet. What works is DLP that classifies code as code and judges the destination. Endpoint DLP covers the device side, and our roundup of AI DLP platforms compares approaches.
Following Code From the Repository to the Prompt
Here's how one afternoon looks to a tool that judges each event on its own:
| What happened | What a single-event log shows |
|---|---|
| A developer opens the payments repository in the corporate IDE | Normal repository access |
| They copy an authentication function that includes a test key | A clipboard event, if anything |
| They paste it into a coding assistant signed in to a personal account | A paste of text with no known origin |
Read together, those lines are one story: proprietary code with a credential left a corporate repository for a personal AI account. A tool that connects the sequence can judge the paste by where the code came from. A tool that can't sees three events, and none of them looks wrong.
Approved vs Personal Accounts
Many coding tools serve business and personal accounts through the same app, so blocking by tool either stops approved use or lets personal use through. DLP that reads the signed-in account can treat the two differently, as we explain in personal vs corporate ChatGPT accounts.
How to Roll Out AI Coding Assistant Controls in 4 Stages
Start by listing which coding assistants and accounts developers already use. Approve one route per tool and lock its settings. Monitor where code moves before enforcing anything. Then warn on risky paths, block only the narrow ones, and test that the controls hold against the paths you mapped.
- Inventory tools and accounts. List the assistants, extensions, and MCP servers in use, and whether each runs on a business or personal account. AI usage monitoring can build the first version of that list.
- Approve a route and lock settings. Choose the tools, buy business seats, set data terms, and push managed settings. Keep existing required controls running while the new ones are validated.
- Monitor code movement. Watch where code goes before blocking anything, so you learn which moves are normal work.
- Warn, block narrow paths, and test. Warn on risky moves and ask for a reason. Block only where the code and destination clearly don't match, such as a repository with credentials going to a personal account. Then test each path from the inventory.
The goal is that engineers keep their assistants. How to prevent AI data leaks applies the same approach company-wide.
How ORION Security Protects Source Code Across AI Coding Tools
ORION Security classifies source code and secrets as they move and traces copied code back to the repository, file, or project it came from. Through its browser extension and endpoint sensor on Windows and macOS, it sees code pasted or uploaded into supported AI tools, tells approved from personal accounts, and can coach, warn, or block where it has coverage.
It classifies proprietary code beyond generic patterns and identifies credentials, tokens, and keys inside files, code fragments, and prompts. That sits next to secret scanning and code security tools rather than replacing them.
ORION Security's own code and secrets example shows the pattern from the table above. An engineer copies authentication code with a non-production test credential from a corporate repository into a personal Cursor account. The user is authorized and the snippet is small, but the destination is a personal, unmanaged AI account, so the prompt is paused, the user is coached, and the workflow is redirected.
Some responses happen at the moment of the paste or upload, such as coaching the developer or pausing the prompt. Others support review afterward: the connected trace shows the repository, the person, and the destination. Teams decide where warnings become blocks.
Customer experience. On G2, Igor D., an IT security team leader at a mid-market company, wrote on August 24, 2026 that ORION Security's classification flags "sensitive material inside things like source code or internal documents," where many older tools only match structured personal and payment data. A reviewer at a small e-learning company wrote on October 30, 2026 that one area where it shines is "detecting secrets being shared into AI tools."
Interested in ORION Security? Learn more.
Frequently Asked Questions
Can an ignore file keep source code away from an AI coding assistant?
It helps, but it isn't a security boundary. Exclusion files and settings tell the assistant what not to read, and an agent running a command can still reach the file another way. Use them with operating-system permissions and keep sensitive code out of repositories the assistant works in.
Can AI coding assistants leak API keys and other secrets?
Yes. Keys in environment files, config, or test code end up in the assistant's context and in anything a developer pastes elsewhere. Keep live credentials in a secrets manager, scan commits, and watch for credentials in code that's copied out of the IDE.
How do you stop developers using personal AI accounts for company code?
Give them an approved business account first, so there's no reason to use a personal one. Then use controls that read the signed-in account and warn or block when company code heads to a personal one.
What if source code can never leave the company?
Run the model where the code already lives. Some teams use a private cloud route under their own account, and some self-host models for the most sensitive repositories. Either way, the paste path still needs DLP.
Should enterprises ban AI coding assistants?
No. Bans push developers to personal accounts on unmanaged tools, which is a riskier path. Approve the tools, set the terms, and watch where code moves.
Is secret scanning enough to stop source code leaks?
No. Secret scanning finds credentials in commits and files. It doesn't see proprietary code without a secret in it, and it doesn't see a paste into a chat tool. Run it alongside DLP that classifies code and knows where it's going.

