Source code in AI tools: what is actually at risk
Developers paste code into AI assistants all day. A function that does not compile, a stack trace, a slow SQL query. It is productive, and banning it is useless: anyone who is banned will use it on their phone or on a personal account.
The right question is not "how do we stop it". It is "what, inside that code, should not leave the company".
What is actually at risk
A code snippet is rarely a secret on its own. The risk lives in three things that travel with it.
1. Credentials and keys inside the snippet
This is the most common case and the most serious. The person copies a configuration file to ask "why does this not connect" and takes along the database password, the payment API token, the certificate's private key. They do not even notice; they were looking at the error, not at line 14.
A credential that entered a prompt has to be treated as exposed. Rotating the key is the answer, and to rotate it you need to know it went out.
2. Proprietary logic
The pricing algorithm, the fraud detection rule, the calculation that sets the product apart. This is the risk executives imagine first, and it exists, but it is smaller than it looks: the pasted snippet is almost never the whole system, and the tool's vendor may or may not train on what it receives. Even so, the policy has to say which tool is approved for this, and the report has to show whether practice follows policy.
3. Customer data in fixtures and examples
Tests use data. When a developer copies a failing test, they copy the fixture: and the fixture, very often, was built from a real database export. Real CPFs (the Brazilian individual taxpayer ID), real emails, real balances. The code is harmless; the test data is not.
This is where a security problem becomes a data protection problem. Personal data of customers went to a third party, possibly outside the country, with no legal basis. Under the LGPD, the Brazilian data protection law, that is an international transfer (articles 33 to 36); GDPR treats it the same way.
Allowing the productivity and still catching the secret
The design mistake is treating "source code" as a category to block. That punishes legitimate use and does not protect what matters. The design that works separates the layers.
Source code in observe. The category exists and is counted, so the report shows which tools developers use and how often. No warning, no block. The engineering team keeps working.
Credentials in warn or block. The classifier looks, inside the pasted text, for secret patterns: API keys, tokens, connection strings with passwords, private key blocks. When it finds one, it acts on that category, not on the code category. The developer who pastes a clean function sees nothing; the one who pastes the configuration file with the password gets the warning before the paste goes through.
Customer data by exact match. The company sends its list of customer CPFs and emails; the server keeps only digests made with HMAC and a key belonging to that customer, and discards the text; the agent tells "looks like a CPF" apart from "is one of our customers' CPFs". The fixture with real data triggers this category; the fixture with invented data does not. That is the difference between a useful alert and noise the team learns to ignore.
All of this happens on the machine. The pasted code is classified locally and discarded; what goes up to the server is categories and counts. A monitoring tool that shipped the code to the vendor's cloud would be a second leak, and no engineering team would accept that.
A policy for developers, a policy for finance
The same monitoring tool has to accept different policies per group, because the risk is different.
| Category | Developers | Finance |
|---|---|---|
| Source code | Observe | Observe |
| Credential | Block | Block |
| CPF, bank details, Pix key | Warn | Warn or block |
| Your customers' data | Warn | Block |
| Approved tools | Coding assistant and corporate chat | Corporate chat only |
Pix is Brazil's instant payment system, and the table is illustrative. What it shows is that, for the developer, customer data usually arrives by accident (a fixture), and a warning solves it: the person sees it, removes the test data and pastes only the code. For finance, customer data is the very material of the job, and the border with AI needs to be harder.
The tools change too. Developers need coding assistants, which the company should explicitly classify as approved or tolerated. A report that shows "use of a non-approved tool" across all of engineering, because nobody classified the coding assistant, helps no one.
Three things to do first
- Ask the engineering team which assistants they use, and classify them in the catalog before measuring. Without that, the report shows noise.
- Search the repository's fixtures for CPFs with a valid check digit, or whatever real identifiers your country uses. If there are any, replace them with generated data. That reduces the risk before any monitoring.
- Turn on warn for credentials inside AI tools. It is the mode that teaches without getting in the way.
How Detecti.ai treats code
In Detecti.ai, source code is a category like the others, with its own enforcement mode, and credential is a separate category with its own. Classification happens on the machine, and the text does not go up. The only exception is evidence retention, which ships turned off: if the customer turns it on, the text the policy interrupted is kept encrypted with a key only the customer holds. Each tool in the catalog of 135 can be marked approved, tolerated or not approved, and that is how the company separates the authorized assistant from the personal account. Start with the free pilot.
Read next
- Who trains models on what you paste: how to read an AI vendor's privacy policySeptember 24, 2026 · 4 min
- Deploy the agent with your RMM in an afternoon: a walkthrough for MSPsSeptember 22, 2026 · 5 min
- Coverage: why "zero events" does not mean zeroSeptember 15, 2026 · 5 min