Start a project

Insights · Security & Governance · Deep Dive

Designing AI Systems That Respect Your Data Boundaries

By iVirtualSoft Editorial

Illustration of walled stone compartments with a locked file and a fingerprint gate controlling what data flows onward

A support transcript, a contract draft and a lab result can all end up in the same prompt. Each arrived with rules about where it may go, and none of those rules travel with the text once it is pasted into a request. Keeping data inside its boundary means deciding, per data class and per use case, where it may travel, and enforcing that in code rather than in a prompt.

Short answer: classify first, place inference to match the classification, enforce authorization at retrieval, treat redaction as best-effort, and log and retain as little as you can justify.

Classify before you place anything

You cannot choose an inference location, a redaction rule or a retention period for data you have not categorized. Keep it small: four tiers is usually enough. Public; internal; confidential; regulated (personal, health, financial). Each tier answers four questions: may it leave our environment, may it go to a hosted model, may it be logged, and how long may it be kept.

OWASP's guidance on sensitive information disclosure (LLM02:2025) lists the categories at risk: personal data, financial and health records, confidential business data, security credentials and legal documents. Use it as a prompt for your own tiers, not a replacement. If you process personal data of people in the EU, note that GDPR Article 9(1) prohibits processing special categories, including health data, unless an exception in Article 9(2) applies. That alone often justifies a separate tier.

Two rules make classification practical. It attaches to the data source, not to individual prompts, so a connector inherits the tier of what it reads. And unclassified data defaults to the strictest tier.

Three places inference can run

Each placement costs something. The comparison below is our engineering assessment, not vendor benchmarks, and the gaps between options shift as open-weight models improve.

Placement Cost profile Model quality and choice Latency and operating burden
Provider API Pay per token; no fixed infrastructure Widest choice, including the most capable hosted models Network round trip to the provider; little to operate, but you depend on their limits and outages
Private cloud Higher, and partly fixed (reserved capacity or dedicated endpoints) Narrower: what your cloud offers in your account and region Close to your other systems; you own configuration, quotas and access policy
Self-hosted Highest per unit of quality at low volume; hardware is paid for whether used or not Limited to models you can obtain, license and run Lowest network latency if co-located; you own capacity, patching, scaling, evaluation and on-call

It is tempting to treat self-hosting as the safe default. It gives the strictest control over where data goes, and the only option for fully offline needs. But its operating burden is a risk of its own: an unpatched inference server, or a weaker model that gets more answers wrong, can do more harm than a well-governed API call. A mixed design is normal, with a gateway routing each request to a placement by data tier. The AI gateway explainer covers that routing layer, and the placement options are described on our Enterprise AI page.

The decision matrix

Our rule: pick the least restrictive placement the tier allows, then add the controls that tier requires. Revisit when volume or the data changes.

Data class Default placement Allowed with extra controls Required controls
Public Provider API Any Output validation; basic usage logging
Internal Provider API, on terms that exclude training use Any Scoped keys; metadata-only logs; retention per tier
Confidential Provider API on reviewed terms, or private cloud Provider API only on endpoints with confirmed retention terms Retrieval authorization in code; redaction before egress; access-controlled logs; short retention
Regulated Private cloud or self-hosted Provider API only with a signed processing agreement, region pinning and endpoint-level eligibility confirmed Everything above, plus minimization, tenant isolation by infrastructure, no prompt bodies in logs, and legal review

Two trade-offs deserve to be explicit. Moving regulated data to self-hosting buys control at the price of model quality and an on-call rota, so check that the self-hosted model passes the same evaluations as the hosted one before you switch. And moving confidential data to a provider API buys quality and speed at the price of dependence on terms that can change, so the "confirmed" in the matrix means re-confirmed on a schedule, not once.

Provider terms are endpoint-specific

Read them per endpoint, and re-read them. As of December 2026, the pages we opened say the following.

OpenAI API. OpenAI's data controls page states that data sent to the API is not used to train or improve its models unless you explicitly opt in. Abuse-monitoring logs are retained for up to 30 days by default, unless the law requires longer. Zero Data Retention and Modified Abuse Monitoring require prior approval. Chat completions, responses and embeddings are listed as eligible for zero retention, while features that store application state, such as files, vector stores and batches, are not and retain data until deleted. The page also warns that live-internet web search is not HIPAA eligible and not covered by a BAA, and says to verify BAA coverage per endpoint.

Anthropic. The Anthropic Privacy Center states that, by default, it will not use inputs or outputs from its commercial products to train models, with exceptions such as feedback you choose to submit or data you opt in to share. Its retention article says API inputs and outputs are deleted automatically within 30 days, with exceptions including services with longer retention under your control (such as its Files API), separately agreed terms (such as zero data retention), usage-policy enforcement and legal requirements.

So "zero retention" is a contract and configuration state, scoped to endpoints, not a property of a model. Put the specific endpoints and terms in your data-flow diagram. Under GDPR, Article 28 requires a controller to use only processors "providing sufficient guarantees", with processing governed by a contract (or other legal act) under which the processor acts only on documented instructions from the controller. Whether and how it applies to you is a question for counsel.

How do you enforce access control in retrieval?

At retrieval, in code, before anything reaches the prompt. OWASP's LLM02 entry notes that system-prompt restrictions on output can be bypassed through prompt injection. Its LLM08:2025 entry on vector and embedding weaknesses describes weak access controls exposing embedded sensitive data, and cross-context leaks in multi-tenant setups sharing one vector database. Its listed mitigation is permission-aware vector stores with fine-grained access control and partitioning.

A workable pattern:

  1. At ingestion, store each chunk with its source document ID, tier, owning tenant and the source system's access list or group reference.
  2. At query time, resolve the caller's identity and groups from your identity provider, never from anything the model or client claims.
  3. Apply the permission filter inside the vector query as a pre-filter. Post-filtering top-k results can return an empty or misleading set.
  4. For sensitive tiers, re-check permissions against the source system, because access lists change after ingestion.
  5. Log which chunks were retrieved for whom. OWASP recommends immutable retrieval logs.

Embeddings are not anonymous. OWASP lists embedding inversion, where attackers may recover significant amounts of source information, so classify the vector store at the same tier as its sources.

Redaction is one layer

OWASP lists tokenization and redaction among its LLM02 mitigations, and they help, but they are best-effort. Pattern matching finds structured identifiers such as card or ID numbers far more reliably than names in free text, or context that identifies a person without naming them. Redact before the request leaves your boundary, use reversible tokens held inside the boundary where you must restore values, and measure the miss rate on a labeled sample of your own data. Then design as though some misses get through.

Minimization is the stronger move. GDPR Article 5(1)(c) requires personal data to be "adequate, relevant and limited to what is necessary in relation to the purposes for which they are processed". The cheapest redaction is not sending the field at all.

Logs, retention and isolation

Logs. Record metadata by default: request ID, tenant, model, prompt version, token counts, latency, outcome. Capture prompt and response bodies only for tiers where the matrix allows it. Never log request headers or raw error objects from endpoints that carry regulated data. The prototype-to-production piece covers the tracing side.

Retention. Set it per tier and cover every copy: logs, vector store, caches, conversation history, eval datasets and provider-side retention. GDPR Article 5(1)(e) requires identifiable data to be kept no longer than necessary for the purposes of processing. Deletion must reach embeddings too.

Isolation and region. For sensitive tiers, prefer separate indexes or namespaces per tenant, enforced by infrastructure, with a tenant filter as a second layer. If data must stay in a jurisdiction, pin storage, inference and logs separately and confirm each in the provider's documentation; a region setting for one component does not cover the others.

If you have a use case that sits in the confidential or regulated rows of the matrix, describe the data and the constraint you are working within.

References

  1. OWASP LLM02:2025 Sensitive Information Disclosure
  2. OWASP LLM08:2025 Vector and Embedding Weaknesses
  3. OpenAI API, Data controls
  4. Anthropic Privacy Center, How long do you store my organization's data?
  5. Anthropic Privacy Center, Is my data used for model training?
  6. Regulation (EU) 2016/679 (GDPR), EUR-Lex

Written and reviewed under our editorial standards. Spotted an error? Email info@ivirtualsoft.com.

What should we build together?

Tell us what you’re trying to build, improve or replace. We’ll help shape it into a scoped brief before anyone commits to anything.