← The book

Chapter 8 — Data Protection

Free sample chapter from the forthcoming book Enterprise AI Architecture (arriving early 2027).

Get notified at launch

A support engineer needs three sentences of context, so she pastes the customer record into a chat window.

No source code left the building this time. No secret was typed.

But the record had a name, a diagnosis, and an account number.

The chat window belonged to someone else's server, in a jurisdiction no one had checked.

The data wasn't stolen. It was sent — by policy, one field at a time, to a place it was never allowed to go.

Nothing was hacked.

The architecture just never asked the data where it was permitted to be.

Where this chapter sits: Human Approval (Ch 6) then AI Policies (Ch 7) then Data Protection (Ch 8) then Data Quality (Ch 9)
Where this chapter sits — Part III opens here. Chapter 7's data-usage policy stops being a rule on paper and becomes a physical guarantee: encryption, tokenization, masking, secure pipelines, and residency are the mechanisms that make "restricted data never reaches an ungoverned model" true, not just written down.

Purpose

Define the five control families that keep sensitive data safe as it moves through an AI pipeline — ingestion, embedding, retrieval, prompt assembly, the third-party model-API boundary, and back — and show precisely where each one sits relative to the trust boundary established in Chapter 5. The chapter's discipline is simple to state and hard to build: treat the call to any model provider as a border crossing, not an internal function call, and architect every control family around that fact. Policy says what data may go where; this chapter makes that physically so.

Executive Summary

In an AI system, the highest-risk moment isn't a database breach — it's the ordinary, successful API call to a model provider that was never supposed to see that data in the first place.

Figure 8.1 — the AI pipeline as a trust boundary
Figure 8.1 — Each stage of the pipeline is a place a control family acts, but only one stage is the border crossing the whole chapter defends: the call to a third-party model.

Running Examples

Two programs at Northwind Holdings — the fictional insurance and financial-services group introduced in Chapter 5 — thread through this chapter, because data protection is easiest to reason about against a concrete shape of workload rather than an abstract one.

Prior Authorization — cleared in minutes, not days. Northwind Holdings' clinical prior-authorization workflow, introduced in Chapter 6, runs on a PHI-scoped, private-cloud deployment with a signed Business Associate Agreement (BAA), an immutable, timestamped audit trail, and grounding restricted to approved clinical guidelines and plan policy. It is the spine for this chapter's treatment of encryption-in-use (confidential computing for a regulated inference workload), data residency (why private-cloud, not a public multi-tenant endpoint), and audit-log retention under HIPAA.

Sanctions and Adverse-Media Screening. Northwind Holdings' financial-crime team runs a screening workflow over cross-border entity data — names, geographies, relationships — pulled from external adverse-media sources, with provenance and citations on every match and an immutable audit trail for examiners, the kind of counterparty and claimant screening a large commercial insurer runs routinely on large or cross-border risks. It is the spine for tokenization and masking of PII during triage, secure-pipeline lineage (where did this evidence come from, and who touched it), and cross-border transfer mechanics whenever screening data or vendors sit outside the analyst's jurisdiction.

Read Prior Authorization wherever this chapter discusses encryption-in-use, residency, and HIPAA-grade audit retention. Read Sanctions Screening wherever it discusses tokenization or masking of entity data and secure-pipeline lineage across jurisdictions.

What Data Protection Covers Here — and Isn't

This chapter is not general data-protection 101. Encryption and access control are assumed baseline competence, not news. It is specifically about the new trust boundaries an AI pipeline introduces: the embedding as a semi-reversible representation of source text, the vector store as a comparatively immature access-control surface, the third-party model API as a border crossing, and the training or fine-tuning corpus as a place data can be permanently memorized.

Classical data protectionAI-pipeline data protection
What's the sameEncrypt at rest and in transit; least-privilege access; classify data by sensitivityAll of it — this chapter assumes it, does not re-teach it
What's genuinely newEmbeddings as a reconstructible representation; vector stores as a new access-control surface; model-API calls as data leaving the perimeter; training corpora as permanent memory
Where the risk movesThe database and the networkThe retriever, the prompt, and the third-party inference call
Which control family answers itEncryption, IAM, DLPEncrypted/access-controlled indexes, tokenization and masking at query time, residency enforcement at the routing layer

Key Principles

The model-API call is the trust boundary, not the database. Every control in this chapter exists to decide what is allowed to cross it. This is the same discipline Chapter 5 built around the gateway pattern, applied one layer down: a database breach is a known, bounded incident with an established playbook; a routine, successful prompt to a third-party model that was never supposed to see that field is a quieter and more common failure, and it produces no alert at all unless something is built to look for it.

Reversible and irreversible controls solve different problems. Tokenization — reversible, vaulted — serves processes that need the real value back under audit. Masking — typically irreversible — serves training corpora and public logs that never should get it back. Treating the two as interchangeable defaults is how a reversible surrogate ends up in a permanent training set, or an irreversible mask ends up blocking a legitimate downstream lookup.

Encryption at rest is necessary and now insufficient. Embeddings, model weights, and prompt or trace logs are new artifacts that classical encryption programs often miss entirely, because the program was written before those artifacts existed. An encryption inventory that lists databases and object storage but not the vector index or the trace store is not out of date by accident — it was simply never asked the question.

Residency is enforced at the routing layer, not the legal department. A jurisdiction rule that isn't a machine-checked gate on the inference call is a policy, not a control — the same discipline Chapter 7 applies to any other data-usage rule. A memo that says "EU customer data stays in the EU" protects no one if the inference router has no way to know, at request time, where the customer or the endpoint actually is.

Encryption — At Rest, In Transit, In Use

The three familiar states extend into the pipeline with two AI-specific additions: embeddings and vector indexes need the same encryption-at-rest discipline as the source documents they were built from, and encryption-in-use has become achievable through confidential computing — hardware-enforced GPU trusted-execution environments that keep model weights and data encrypted even in VRAM, with cryptographic attestation that the enclave is running the code it claims to be running. For the Prior Authorization workflow, this is the difference between "we trust the cloud provider's operational controls" and "we can prove, cryptographically, that no one — including the cloud provider's own operators — read the clinical record during inference."

Encryption layerWhat it protectsWhat it does not protect
At restDatabases, object storage, embeddings, vector indexes, model weights on diskData once decrypted for processing; a compromised key
In transitData moving between services, including the call to a model APIData at either endpoint once it arrives
In use (confidential computing)Model weights and data during inference, even from a privileged operator or a compromised hostApplication-layer logic errors; a poorly scoped prompt; anything outside the enclave boundary
Figure 8.2 — encryption layering with key-management overlay
Figure 8.2 — At rest, in transit, and in use are three different rings of protection, each keyed separately by the enterprise KMS so that compromise of one key does not unlock the others.

Embeddings Are Not Anonymous

A vector embedding looks like a harmless list of floating-point numbers, and that appearance has led more than one architecture review to treat "we only stored the embedding, not the text" as a compliance answer. It isn't. A growing line of embedding-inversion research shows partial-to-substantial reconstruction of source text from vector representations alone, including recent few-shot inversion attacks demonstrated against commercial embedding APIs, with no defense yet established as reliably effective across the board. For the Sanctions Screening workflow's entity-relationship vectors — names, geographies, and the relationships between them — the practical implication is direct: those vectors carry meaningfully reconstructible information about real people and entities, not an anonymized fingerprint of them.

Tokenization, Format-Preserving Encryption, and Masking

Four mechanisms cover most of what an AI pipeline needs, and each answers a different question about whether — and how — a value needs to come back.

Tokenization replaces a value with a surrogate that looks arbitrary and is reversible only through a lookup in a governed vault. It is the right choice when a downstream process needs the real value back under audit — an analyst confirming a flagged entity, a claims system reconciling a payout.

Format-preserving encryption (FPE) — standardized by NIST as FF1 and FF3-1 in SP 800-38G — produces a value of the same format and length, reversible with a key rather than a vault lookup. It is useful precisely where a downstream system's schema validation would reject a token but can accept a same-shape encrypted value. One caution belongs here in bold: FF3 itself was broken and formally deprecated after its initial standardization — a pointed argument against rolling a custom scheme in-house, and a reminder to track NIST guidance rather than freeze it at first implementation.

Static masking permanently transforms a corpus — the right and irreversible-by-design choice for fine-tuning and evaluation data, because training data can be memorized, and a model that memorizes a masked value has memorized nothing sensitive.

Dynamic masking applies at query time, in front of a retriever or tool call, varying by the requester's authorization. It is the mechanism that lets the same underlying record show a full field to an authorized case reviewer and a masked one to a general support agent.

Figure 8.3 — tokenization, FPE, and masking decision tree
Figure 8.3 — The mechanism follows one question: does anything downstream ever need the original value back, through a governed vault or a key?

Artifact — redaction-pipeline configuration. A layered entity-recognition pipeline, applied at both the live-prompt injection point and the retrieved-chunk injection point, with a distinct anonymization action per entity type:

# redaction-pipeline.yaml
pipeline:
  analyzer:
    engine: ner-layered          # statistical NER + regex/checksum recognizers
    entities:
      - PERSON
      - US_SSN
      - CREDIT_CARD
      - MEDICAL_LICENSE
      - DIAGNOSIS_CODE
      - ACCOUNT_NUMBER
      - GEO_LOCATION
    language: en
    confidence_threshold: 0.72

  anonymizers:
    PERSON:            { action: replace,   surrogate: "[PERSON]" }
    US_SSN:             { action: mask,      chars_to_mask: 9, from_end: false }
    CREDIT_CARD:         { action: tokenize,  vault: kms/vault/pci }
    MEDICAL_LICENSE:     { action: tokenize,  vault: kms/vault/phi }
    DIAGNOSIS_CODE:      { action: fpe,       key_ref: kms/fpe/clinical }
    ACCOUNT_NUMBER:      { action: tokenize,  vault: kms/vault/financial }
    GEO_LOCATION:        { action: generalize, level: region }

  injection_points:
    - stage: live_prompt
      apply: true
    - stage: retrieved_chunks     # the point most pipelines omit
      apply: true
      note: "retrieved context is scanned identically to the live prompt"

  fail_mode: closed               # unscanned content is blocked, not passed through

The Masking-Utility Tradeoff

Over-redaction breaks coreference, degrades summarization quality, and undermines RAG grounding — a clinical note with every name and date blacked out stops being clinically useful long before it stops containing PHI. Under-redaction leaves real PII sitting in the context window, retrievable by anyone with query access. Current research is moving toward utility-preserving surrogate substitution — replacing a name with a plausible fictional one rather than a black box — rather than blanket blackout, but this is an active, unsettled research area, not a solved default an architecture can simply adopt.

Secure Pipelines

Data lineage — tracking a piece of data from source document through chunking, embedding, indexing, retrieval, and prompt assembly — turns a breach at any one stage into a traceable blast radius instead of an open question. Without it, "what did the compromised index actually expose" has no answer faster than re-deriving the whole pipeline by hand.

Vector-database access control is today's documented weak point. Namespace, partition, and metadata-filter isolation exist in most major vector databases, but they are not enabled automatically — they must be explicitly configured, and misconfiguration, not sophisticated attack, is the dominant real-world failure mode. Confirmed cases include anonymous read and write access to production vector stores; write access is the more dangerous of the two, because it enables retrieval poisoning — quietly inserting content a RAG pipeline will later retrieve and trust — rather than simple data exposure.

The embedding model itself carries supply-chain risk that is easy to underweight: an embedding model pulled from a public hub is an executable artifact — subject to deserialization risk in common model-file formats — not just a mathematical function, and it warrants the same provenance and signing scrutiny an enterprise already applies to an LLM's own weights.

Figure 8.4 — secure pipeline with lineage
Figure 8.4 — A CI/CD discipline applied to training, fine-tuning, and RAG indexing: provenance checks and audit-log redaction gates at every hop, so a breach at one stage does not silently become a breach of everything.

For Sanctions Screening, this is the difference between an examiner accepting a match's evidentiary chain and an examiner rejecting it — every piece of adverse-media evidence needs a traceable path from external source to the analyst's screen.

Data Residency

Sovereignty and cross-border transfer rules for AI inference and training are evolving on two fronts at once. The EU AI Act's data-governance article (Article 10) imposes obligations on training, validation, and testing data for high-risk systems, with a narrow, safeguard-bound exception permitting the processing of special-category data solely to detect and correct bias — and it intersects with GDPR's existing cross-border transfer regime (Chapter V: adequacy decisions, standard contractual clauses) in ways still being actively mapped as both regimes evolve together. Separately, China's cross-border personal-information transfer framework offers a security-assessment pathway, a standard-contract pathway, and a newer certification pathway with its own impact-assessment requirement and multi-year validity period — and it governs transfers of personal information out of China, including AI training and inference data specifically, not just conventional data exports.

Figure 8.5 — cross-border data residency decision map
Figure 8.5 — Where the data subject sits determines the legal basis for every hop the data takes after that: in-region processing needs no transfer mechanism at all; leaving the region means choosing a named pathway.

Prior Authorization's private-cloud, PHI-scoped deployment is the in-region, self-hosted pattern in practice: rather than resolve a transfer-mechanism question for every clinical record, the architecture avoids the question by keeping processing in-region in the first place.

Data Protection in Practice

The classification-to-handling matrix is the artifact that operationalizes everything above: rows are classification tiers, columns are pipeline stages, and every cell states the required control — or states plainly that the combination is blocked.

Artifact — data-classification-to-handling matrix.

ClassificationTraining-corpus inclusionRAG indexingPrompt inclusionThird-party model-API eligibleLog/trace retentionCross-border transfer
PublicAllowedAllowedAllowedAllowedStandard retentionAllowed
InternalAllowed with maskingAllowedAllowedAllowedStandard retentionAllowed
ConfidentialStatic-masked onlyAccess-controlled indexDynamic-maskedAllowed with contractual DPAReduced retentionSCC required
Restricted-PIIStatic-masked onlyEncrypted, access-controlledTokenized/dynamic-maskedCase-by-case, tokenized onlyRedacted-payload pointer onlyNamed legal mechanism required
Restricted-PHIBlocked (BAA-scoped systems only)Encrypted, in-region onlyTokenized/dynamic-maskedBAA-covered providers onlyRedacted-payload pointer onlyBlocked absent BAA + mechanism
Regulated-FinancialBlocked (tokenized surrogate only)Encrypted, access-controlledTokenizedTokenized only, no raw valuesRedacted-payload pointer onlyNamed legal mechanism required

Artifact — OPA/Rego residency-enforcement snippet. Denies an inference request when the data subject's region and the target endpoint's region don't satisfy an approved transfer mechanism:

package residency.authz

default allow := false

# Approved transfer mechanisms, keyed by (subject_region, endpoint_region)
approved_mechanism[{"subject": s, "endpoint": e}] if {
    mechanism := data.transfer_mechanisms[s][e]
    mechanism.status == "approved"
}

allow if {
    input.subject_region == input.endpoint_region
}

allow if {
    input.subject_region != input.endpoint_region
    approved_mechanism[{"subject": input.subject_region, "endpoint": input.endpoint_region}]
}

deny_reason := reason if {
    not allow
    reason := sprintf(
        "no approved transfer mechanism from %v to %v",
        [input.subject_region, input.endpoint_region]
    )
}

Artifact — key-management architecture note. One enterprise KMS root anchors the entire chapter's encryption controls, but it issues a distinct data-encryption key per pipeline stage — ingestion, embedding index, prompt/trace log, and detokenization vault each hold their own key, rotated on an independent cadence. The design goal is blast-radius containment: a compromised key at one stage unlocks that stage alone, never the whole pipeline. This is the same principle Figure 8.2's ring diagram makes visual, applied down to the operational detail of who rotates what and how often.

Figure 8.1, revisited: every stage in that pipeline diagram is one of the controls above, placed at the exact point it protects — ingestion is the redaction pipeline and tokenization gate, the encrypted index is the vector-database access control, the model-API boundary is the residency check and the border crossing itself.

Design Tradeoffs

There are no free data-protection controls; every one buys safety with reversibility, latency, cost, or access to capability. The point of an architecture is to make those trades on purpose.

DecisionCheaper / faster optionStronger / safer optionThe tradeDefault for regulated data
ReversibilityMasking (irreversible)Tokenization (vaulted, reversible)Masking is simpler and permanent-safe; tokenization adds vault infrastructure but serves processes that need the value backTokenization for anything an audited process may need to recover
Deployment scopePublic multi-tenant model endpointIn-region / self-hosted deploymentPublic endpoints reach best-in-class frontier models; self-hosted keeps data in-region but narrows model choiceIn-region self-hosted for PHI and other Restricted tiers
Redaction aggressivenessHeavy redactionLight redactionHeavy redaction is safer for exposure but degrades grounding and utility; light redaction preserves utility but risks leakageA named owner sets the dial per use case — no universal default
Inference encryptionStandard TLS + at-rest onlyConfidential computing (in-use encryption)Standard encryption is fast and cheap; confidential computing adds attestation latency and cost for a stronger guaranteeConfidential computing for BAA-scoped or similarly regulated workloads only
Key managementCentralized key managementPer-stage key scopingCentralized is operationally simpler; per-stage scoping contains blast radius at the cost of more keys to rotate and trackPer-stage scoping for any pipeline touching Restricted-tier data

Best Practices

Anti-Patterns

Maturity Model

Figure 8.6 — data-protection maturity L1 to L5
Figure 8.6 — The maturity progression from a default, unconfigured vector store to residency enforced as code at every ingress and egress point.
LevelWhat it looks like
L1 — Ad hocVector database runs on default configuration; no data lineage exists; residency is not reviewed for AI workloads at all.
L2 — RepeatableEncryption at rest is applied to primary stores; masking exists in places but is ad hoc and inconsistent across teams.
L3 — DefinedTokenization and masking gates run at ingestion and retrieval; basic lineage tracking exists from source document to prompt.
L4 — GovernedPer-stage key scoping is in place; residency is reviewed and documented under a named legal mechanism for every cross-border flow.
L5 — OptimizedResidency is enforced as code at the routing layer; embeddings, weights, and logs are encrypted comprehensively; lineage is queryable end to end; every control maps to a named owner.

Implementation Checklist

Standards and Further Reading

Map this chapter's controls to the obligations an auditor will actually ask about: the EU AI Act's data-governance article (Article 10) for high-risk systems, read alongside GDPR's cross-border transfer chapter (Chapter V); China's PIPL and its 2025–2026 cross-border certification measures; NIST SP 800-38G for format-preserving encryption (FF1/FF3-1, including the FF3 deprecation); the NIST AI RMF Generative AI Profile; ISO/IEC 42001 for data-governance and lifecycle controls; the HIPAA Security Rule and Minimum Necessary Standard; and PCI-DSS tokenization guidance as the pre-AI baseline this chapter extends. (EU AI Act and China certification-regime effective dates are current as of mid-2026 and should be re-verified at press time; a related wave of Chinese technical standards is expected to phase in through 2026.)

Chapter Summary

Looking Ahead

Data protection makes a single request safe to send. It says nothing about whether the data inside that request was any good to begin with. The next chapter in Part III turns to that quieter risk: validating inputs, scoring confidence, and telling a hallucination apart from data that was simply wrong from the start.

AI Policies (Ch 7) → Data Protection (Ch 8) → Chapter 9: the mechanism that keeps data safe, and the discipline that keeps it trustworthy.

The bigger picture

Where this is heading.

This chapter is part of the buildable path toward the AI-native enterprise — where intelligence, not software, becomes the organizing principle, and applications, documents, and code recede into implementation details. That’s the north-star vision the book works toward.

The book

Read the rest when it lands.

This is one chapter of Enterprise AI Architecture — seven parts, thirty-two chapters. Join the list and I’ll send one note when it’s ready.