Every bank and insurer we talk to has the same two sentences queued up: “We love what the model can do. Security will never let us ship it.” They are usually right, not because the model is dangerous, but because the default data path around a hosted model violates half a dozen controls at once. This guide walks the path end to end and shows where the leaks are and how to close each one.
Where data actually leaks
A leak is any point where regulated data crosses a boundary it is not permitted to cross. In a naive LLM integration there are four:
- The request itself, customer data sent to a third-party endpoint that may retain or train on it.
- Logs and traces, prompts and responses written to observability tooling that was never scoped for PII.
- The vector index, embeddings and source text pooled into one store that ignores who may read what.
- The output, an answer surfaced to a user who was not entitled to the underlying document.
Treat every one of these as in-scope for your data-protection review from the first commit. Retrofitting masking and access control after a proof-of-concept is how pilots die in security review.
Zero retention, or self-host
There are two defensible postures for the model call. The first is a hosted frontier model under an enterprise zero-data-retention (ZDR) agreement, where the provider contractually does not store or train on your inputs. The second is a self-hosted open-weight model running inside your own perimeter, where the question of provider retention never arises. Which you choose is a risk and performance trade-off, not a vendor loyalty decision.
# Pick the posture explicitly; never let a default endpoint decide for you.
def build_client(risk: RiskTier) -> ModelClient:
if risk >= RiskTier.PHI:
# highest-sensitivity paths stay in-perimeter
return SelfHostedClient(endpoint=settings.VLLM_INTERNAL_URL)
# everything else uses a zero-retention enterprise endpoint
return HostedClient(
endpoint=settings.ENTERPRISE_ZDR_URL,
retention='none', # contractually enforced, verified in DPA
)Mask before inference, not after
The single most important control is to strip or tokenize identifiers before the text ever reaches the model. Masking after the fact is theatre, the data already left your boundary. A detokenization map held in your environment lets you restore entities in the final answer without the model ever seeing them.
def redact(text: str) -> tuple[str, dict]:
spans = detector.find(text) # names, SSNs, accounts, MRNs
mapping = {}
for i, s in enumerate(spans):
token = f'[ENT_{i}]'
mapping[token] = s.value # kept in-perimeter only
text = text.replace(s.value, token)
return text, mapping
def restore(answer: str, mapping: dict) -> str:
for token, value in mapping.items():
answer = answer.replace(token, value)
return answerKeep the token→value map in your own store with the same retention rules as the source document. It is as sensitive as the raw PII, because it reverses the masking.
Access control belongs on retrieval
If you add a retrieval step (and most financial assistants do), the index must respect the same entitlements your identity provider already enforces. The cleanest pattern is to attach an ACL to every chunk at ingestion and filter on the caller's claims at query time, so a user can never retrieve a document they could not open in the source system.
What an auditor needs to see
SEC and FINRA oversight do not require that you never use AI, they require that you can reconstruct what happened. For every generated output, record the (masked) input, the sources retrieved, the model and version, and the exact spans the answer was grounded in. Store it immutably. When a reviewer asks “why did it say that,” you can answer with evidence instead of a shrug.
- Masked input and a hash of the original.
- Retrieved source ids, pages, and spans.
- Model identifier, version, and decoding parameters.
- Final output and the citations binding it to sources.
The short version
LLMs pass security review when the data path is boring: nothing sensitive leaves the perimeter unmasked, retrieval respects entitlements, and every answer is reconstructable. None of this is exotic, it is disciplined plumbing. That plumbing is exactly what we build for regulated teams, and it is what we pressure-test on an architecture review.
Need this architecture deployed into your private cloud?
Book a 30-Minute AI & RAG Architecture Review →