What a DLP sees when data leaves through a prompt
Twenty customers in a spreadsheet. Name, French social security number, IBAN, card number, amount. Someone pastes it into a chatbot and asks “who’s over €3,000?”. That’s the picture everyone has in mind when AI and data leakage come up in the same meeting, and it’s the easy case. Any half-decent DLP catches it.
Data rarely leaves in its original shape, though. It goes out as a screenshot, retyped from a PDF, summarised by some other tool, or minus the header that said “confidential”. I wanted numbers on what a classic detector actually catches in each of those cases.
The test bench
I don’t have a Microsoft 365 E5 tenant to play with, so testing Purview directly was off the table. Instead I went the other way round: read the public definitions of Purview’s sensitive information types and rewrote their logic in Python. This is not Purview. It’s what Purview’s documentation says it does, replayed against data I control.
Three detectors and a keyword list:
- Payment card: 14 to 19 digits, raw or grouped, passing the Luhn check and shaped like a major brand’s numbers. Per Microsoft’s definition, a supporting keyword (“card number”, “cvv2”, an expiry date…) within 300 characters gives high confidence; without one, low.
- French social security number (NIR): 15 consecutive digits, or 13 digits, a space and 2 digits, plus the check key. High confidence with a keyword such as “sécurité sociale” or “insee” in the same 300-character window, medium without.
- IBAN: country code, check digits, groups of four, mod-97 validation. No keyword needed: the checksum alone earns high confidence.
- Keywords: “confidentiel”, “diffusion restreinte”, “ne pas diffuser”, “confidential”.
The card detector boils down to this:
# 14 to 19 digits, raw or grouped with spaces / dashes
CARD_RE = re.compile(r"(?<![\d.])(?:\d[ -]?){13,18}\d(?![\d])")
BRANDS = re.compile(r"^(4|5[1-5]|2[2-7]|3[47]|6011|65|35)")
def cards(text):
out = {}
for m in CARD_RE.finditer(text):
n = re.sub(r"[ -]", "", m.group())
if 14 <= len(n) <= 19 and BRANDS.match(n) and luhn(n):
# confidence comes from what surrounds the number, not the number itself
out[n] = "high" if near(text, m.start(), m.end(), KW_CARD) else "low"
return out
The twenty customers are made up, generated from a fixed seed. Every number passes its checksum, and I verified that with an independent library (python-stdnum) rather than my own code. A test that grades itself doesn’t prove much.
Then eight variants of the same file: raw CSV, the same as a Markdown table, a “human” version where the NIR is written with the spaces you see on French paperwork (2 98 11 56 196 821 59), the CSV in base64, two screenshots run through OCR (Tesseract 5.3; one clean and large, one in an 11-pixel font), and two LLM outputs: the file rewritten as sentences, and a summary for a manager. Claude Code produced the rewrites in non-interactive mode, on the synthetic data only.
What gets caught

Raw CSV and Markdown table: 60 numbers out of 60. Nothing to add; that’s what these detectors are for. Base64: zero. Of course. A detector that doesn’t decode just sees a long run of letters. Whether Purview decodes base64 in pasted text, the documentation doesn’t say, and I’d rather not guess. It’s not what a well-meaning employee does anyway.
The “human” format is more interesting. Cards and IBANs grouped in fours still match; NIRs written the French way drop to 0 out of 20. The documented pattern accepts 15 digits in a row, or a single space before the key, not the layout you’d find on an official letter. The docs mention two internal functions (Func_french_insee and Func_fr_insee) and the second might be more forgiving; without a tenant, I can’t check. If you have one, it’s a two-minute test, and worth running before anyone tells leadership that “DLP blocks social security numbers”.
The screenshots surprised me the other way. On the clean one, OCR returns perfect text and everything is caught. On the small font, 19 out of 20: Tesseract swallowed one semicolon on Inès Bernard’s row, the IBAN and the card number fused into a single 43-character string, and nothing on that row matched anymore. One OCR slip, one whole record gone. On the Purview side, OCR for images exists on endpoints (it has to be enabled); what browser paste evaluation does when the clipboard holds an image rather than text isn’t spelled out.
The result I got wrong
Before running anything, I’d have bet that an LLM rewrite would hurt detection. It went the other way. The “sentences” version scores 20 out of 20 everywhere, and 20 out of 20 at high confidence, versus 3 for the original CSV.

It all comes down to the 300-character window. In the CSV, the keyword “Numéro de carte” appears exactly once, in the header. Each row is about 80 characters long, so only the first three or four rows sit close enough. The other sixteen cards come out at low confidence. The LLM, meanwhile, writes “a pour numéro de carte” in front of every number. It manufactures exactly the context the detector is looking for.
The practical upshot: if your DLP rule only fires on high confidence (a common way to keep noise down), a raw export can go through with three cards flagged out of twenty. Instance count and confidence level matter as much as which information type you picked. And loosening it has a cost too: out of 100,000 random 16-digit identifiers (order numbers, say), 2,430 pass Luhn and a brand prefix. That’s 2.4%, and it’s why low confidence is noisy and why people end up requiring the keyword.
The real gap: things without a format
The LLM’s summary of the customer file scores 0 out of 20. It didn’t lose the numbers; it declined to include them, noting that they had no place in a summary for a manager. Names and amounts went out regardless. That’s personal data too, and no format-based detector sees it. The internal memo is worse. I wrote it for the test: a fake acquisition of Fabrikam by Contoso, a price, an announcement date, a site closure affecting 62 jobs, and a line saying employee representatives won’t be told in advance. The kind of text that’s worth far more than twenty card numbers. On the full memo, “confidentiel” and “diffusion restreinte” sit in the header. On the body alone (the bit someone highlights to ask “can you rephrase this?”), nothing. The LLM summary keeps every sensitive fact (€48M, 62 jobs, the November 3 announcement) and no keyword at all.
A small irony: the English translation kept “CONFIDENTIAL”, and the casual team email the LLM drafted put “confidentiel” in the subject line, with a note about checking who’s on the distribution list. The model handled the label more carefully than a person selecting three paragraphs.
That’s the fundamental limit. Pattern-based DLP protects things that have a shape: numbers, keys, identifiers. A strategy, an acquisition or a layoff plan doesn’t have one. Trainable classifiers and document fingerprinting exist for that, but they’re a different level of effort, and they don’t fare any better on text that has already been summarised somewhere else.
Shadow AI, in logs you already have
If content partly escapes, there’s still a question SOC logs can answer: who uses which service, and how often. I searched SigmaHQ (repository as of October 16, 2026) for a rule on AI assistant hostnames in proxy or DNS logs. There isn’t one; the only rules that mention these tools are about supply chain attacks. Here’s the one I’d use. It passes sigma check with no errors and no issues:
title: Generative AI Chat Or API Service Accessed Through Proxy
id: 3f4d6a52-8a67-4c0e-9a5b-2d1c7e9f0b41
status: experimental
description: |
Detects web requests to the chat interfaces or APIs of public generative AI services.
Meant as an inventory signal for shadow AI rather than an alert: it tells you who uses which service, not what was sent.
references:
- https://learn.microsoft.com/en-us/purview/deploymentmodels/depmod-data-leak-shadow-ai-step1
author: Chabnco
date: 2026-10-17
tags:
- attack.exfiltration
- attack.t1567
logsource:
category: proxy
detection:
selection:
cs-host|endswith:
- 'chatgpt.com'
- 'chat.openai.com'
- 'api.openai.com'
- 'claude.ai'
- 'api.anthropic.com'
- 'gemini.google.com'
- 'generativelanguage.googleapis.com'
- 'chat.mistral.ai'
- 'api.mistral.ai'
- 'chat.deepseek.com'
- 'api.deepseek.com'
- 'perplexity.ai'
condition: selection
falsepositives:
- Sanctioned use of these services. Filter on the approved list before using this rule as an alert.
level: low
It’s low on purpose, and it’s an inventory rule. As an alert it would fire all day for nothing: visiting ChatGPT isn’t an incident. Two caveats. endswith will also match a lookalike domain ending in the same string, which is arguably a bonus here. And without TLS inspection, the proxy only sees the hostname: the rule tells you who, never what.
With Defender for Endpoint, the same idea in KQL, plus one detail that changes the picture: the process that opened the connection.
let ai_hosts = dynamic(["chatgpt.com", "chat.openai.com", "api.openai.com", "claude.ai",
"api.anthropic.com", "gemini.google.com", "generativelanguage.googleapis.com",
"chat.mistral.ai", "api.mistral.ai", "chat.deepseek.com", "api.deepseek.com", "perplexity.ai"]);
let browsers = dynamic(["msedge.exe", "chrome.exe", "firefox.exe", "brave.exe", "opera.exe"]);
DeviceNetworkEvents
| where Timestamp > ago(30d)
| where ActionType == "ConnectionSuccess"
| extend Host = tolower(RemoteUrl)
| where Host has_any (ai_hosts)
// a browser is a person; python.exe talking to an API is a script holding a key
| extend Client = iff(InitiatingProcessFileName in~ (browsers), "browser", InitiatingProcessFileName)
| summarize Connections = count(), Days = dcount(bin(Timestamp, 1d)),
FirstSeen = min(Timestamp), LastSeen = max(Timestamp)
by InitiatingProcessAccountName, DeviceName, Host, Client
| order by Days desc, Connections desc
The query passes Microsoft’s official Kusto parser against the DeviceNetworkEvents schema. That proves it’s valid, not that it returns what you hope for in your tenant. During triage, look first at rows where Client isn’t a browser: a script or dev tool hitting api.openai.com every day means there’s an API key somewhere on that machine, which is a different conversation, close to the one about command-line AI agents.
What Purview can do, according to its docs
I couldn’t test any of this, so everything below comes from Microsoft’s documentation as of October 17, 2026.

On the endpoint. Endpoint DLP has a “Paste to supported browsers” activity: when a user pastes content into a restricted service domain, the pasted content itself is evaluated, regardless of how the source file was classified. That’s exactly our spreadsheet scenario. Supported on Windows, in preview on macOS, and only on onboarded devices. For Edge, Microsoft also documents browser data security that evaluates prompts directly.
In the audit log. Copilot interactions are recorded as CopilotInteraction and included in Audit Standard. Third-party AI apps (the ones seen through network or browser DLP) land under AIAppInteraction, billed pay-as-you-go with 180-day retention. The Messages property describes the exchange (an ID, an isPrompt flag, JailbreakDetected); the docs don’t list the prompt text among the properties. For Copilot, AccessedResources lists the files read along with their SensitivityLabelId, which is probably the most useful field in an investigation.
For inventory. Defender for Cloud Apps has a “Generative AI” category in its app catalog, with a risk score per app. Think of it as the tooled-up version of the KQL query above.
Where I land
Pattern-based DLP does its job on the most common case: someone in a hurry pasting a raw export. That counts for something. But it depends on formatting and on the text around each number far more than a ticked box in a policy suggests, and it’s blind to what matters most to a company: text with no format at all.
If I had to pick where effort goes, I’d start with inventory: who uses what, from which process, how regularly. You can do that with logs you already collect, no extra licence. Next, give people an approved, logged tool, because visible usage beats blocked usage that just moves to a personal phone. Only after that would I fine-tune DLP rules, testing my own detectors against my own formats, spaced-out social security numbers included.
References
- Microsoft Learn, Credit card number entity definition
- Microsoft Learn, France social security number entity definition
- Microsoft Learn, International banking account number (IBAN) entity definition
- Microsoft Learn, Learn about Endpoint data loss prevention
- Microsoft Learn, Audit logs for Copilot and AI applications
- Microsoft Learn, Step 1: Discover AI apps, Prevent data leak to shadow AI
- MITRE ATT&CK, T1567 Exfiltration Over Web Service
- SigmaHQ, Sigma rules repository