All lessons Leer en español

Security in depth · Unit 27 · Lesson 2 of 11

AI data, retrieval, and safe output

Follow information into and out of an AI feature, with separate controls for source integrity, permissions, and rendering.

7 minready

MITRE ATLAS

Helpful before thisPrompt injection and instruction boundaries

After this lesson you can

  • Distinguish training changes from retrieval changes and runtime data exposure.
  • Choose output handling appropriate to the destination interpreter.
  • Explain why provenance, access checks, and retention still apply to AI data.

An AI feature is a data pipeline. Information enters through documents, requests, and tools; generated material leaves through a screen, a stored draft, or an action. Security needs to follow the whole journey.

Start with three questions: where did this information come from, who may use it, and what will interpret it next? The model does not remove any of those questions.

AI data, retrieval, and safe outputSource integrity, retrieval permission, and output handling are distinct checks. A trustworthy source does not automatically authorize every destination.Source and permissionModel contextSafe destination
Source integrity, retrieval permission, and output handling are distinct checks. A trustworthy source does not automatically authorize every destination.

Training and retrieval change different things

Training or fine-tuning adjusts model parameters. Changing a training dataset can affect a later model produced from it. RAG, or retrieval-augmented generation, usually selects external content and places it into the context of a request without updating those parameters.

A misleading document in a search index can therefore affect an answer without “infecting the weights.” Fixing a retrieval source and replacing a trained model are different remediation tasks. Some products combine both processes, so describe the actual data flow.

Embeddings help represent similarity. They are not proof that a document is true, safe, or relevant to every user. Retrieval rankings can vary with indexing, search logic, and the question.

Establish provenance and access separately

Data provenance records where an item came from and how it changed. Useful information includes the source, version, owner, review state, and permitted audience. A hash can show that bytes match a known value; it does not by itself establish that the author is trustworthy or the content is correct.

Enforce permissions when retrieving the underlying records, and make caches respect the same user or tenant scope. A citation does not repair unauthorized retrieval. A source’s access can change after it was indexed, so deletion and permission changes need to propagate to derived copies.

Generated output is still input somewhere else

Output handling depends on the destination. Browser text needs safe rendering; permitted rich formatting needs an appropriate sanitization policy. Database values should remain data in parameterized operations. File operations need real containment checks that understand path boundaries, rather than a simple matching prefix.

A proposed URL needs an application policy for allowed destinations and network access. Passing a format check does not establish that its destination is appropriate. Prefer narrowly defined operations over interpreting free-form generated text as commands.

The important distinction is between content that looks acceptable to a person and content that a downstream interpreter will treat as executable instructions.

Treat traces as another data store

A support assistant may copy a ticket into a prompt, retrieve another excerpt, generate a reply, and record all of it in diagnostics. Even if no training occurs, those runtime copies can expose sensitive information.

Define who can inspect traces, what is redacted, and when records expire. Keep enough evidence for troubleshooting without routinely collecting complete private conversations or credentials. Access separation should extend to analytics, exports, caches, and backups.

Review a realistic failure without guessing its cause

Imagine a fictional user receiving a reply containing another customer’s ticket excerpt. Several causes are possible: a retrieval permission error, a shared cache, an incorrectly scoped conversation, or an output-selection bug. The symptom does not prove training-data memorization.

Trace the source and copies using fictional fixtures or minimized evidence. State the observed disclosure, identify the boundary that failed, correct it, and verify that legitimate answers still work. This is more useful than treating every AI data problem as the same model-level weakness.

Terms you met

data provenanceRAGoutput handling

Check yourself

No timer. No penalties. Read the explanation and try again whenever you like.

  1. Does adding a document to a RAG index normally retrain the model?

    Show the answer

    Correct answer: No; retrieval supplies context at runtime unless a separate training process uses it. Changing retrieved content and changing model weights are different operations.

  2. A generated reply contains formatted text for a browser. What protects the page?

    Show the answer

    Correct answer: Safe rendering and context-appropriate handling of untrusted content. The application must decide which markup and URL schemes it permits; model authorship does not establish safety.

  3. A retrieved passage has a source citation. Does that prove it is correct and authorized?

    Show the answer

    Correct answer: No; citations help provenance, while accuracy and access still need checks. A source may be wrong, outdated, or outside the viewer’s permitted scope.

  4. Where can sensitive information accumulate in an AI application?

    Show the answer

    Correct answer: In prompts, retrieved excerpts, outputs, caches, and diagnostic logs. Each copy is a data store with access and retention requirements.

Try it

  • WriteA fictional help center indexes customer tickets and drafts replies. Draw where the original ticket, retrieved excerpt, reply, and debug log are stored. For each, name who may read it, who may change it, and how long it should be retained.
References