Sub topic 3
Why it matters: risks and obligations
This chapter assumes you can read basic Python, know what a prompt, a response, and a log are, and have called an LLM API before. It explains why detection and redaction are worth building. The later chapters cover how to build them.
The risks in an LLM app
Personal data can cause harm at several points in an LLM app. Each point leads to a different design choice later.
- Third-party exposure. A prompt sent to a hosted model leaves your infrastructure. The provider may retain it for a period, review it for abuse, or use it for training, depending on the contract and plan.
- Log and trace sprawl. Prompts and responses are often copied into application logs, tracing tools, analytics, and error reports. These copies usually have weaker access control and longer retention than the primary database.
- Retrieval leaks. In a retrieval-augmented generation (RAG) system, the model can quote any document it receives. A user may see another person's data if the index mixes documents with different access rights.
- Memory and caching. Chat history, prompt caches, and embeddings stores keep data after the request ends. Deleting a user's record from the main database does not delete these copies.
- Output leakage. The model can repeat personal data from its prompt in places you did not intend, such as a summary sent to a wider audience.
The diagram shows how one piece of personal data spreads from a single user message.
Data minimization
The most reliable control is to send less data. Data minimization is the principle that you collect, process, and keep only what the task needs. A model that summarizes a support ticket does not need the customer's phone number. If the number never reaches the model, it cannot be retained, logged, or leaked from there.
Redaction is how you apply this principle to free text. You find the personal data, then remove or replace it before it travels further.
Regulatory drivers
Laws differ by region and change over time, so treat this section as orientation and not legal advice. Check requirements with your legal or privacy team.
| Regulation | Region | Relevant ideas for LLM apps |
|---|---|---|
| GDPR | European Union and UK (as UK GDPR) | Lawful basis for processing, data minimization, purpose limitation, rights to access and erasure, rules for transfers outside the region |
| CCPA / CPRA | California, USA | Rights to know, delete, and opt out of sale or sharing of personal information |
| HIPAA | USA, health data | Safeguards for protected health information, and agreements with vendors that handle it |
| PCI DSS | Industry standard for card data | Strict limits on storing and transmitting card numbers |
Two points apply across these rules. First, sending data to a model provider is usually a form of processing, and the provider is often a processor or vendor that needs a contract. Second, deletion and access requests must cover every copy, including logs and indexes. Redacting before data is copied makes those requests much easier to satisfy.
Redaction is a risk reducer, not a guarantee
Automated detection misses some values and flags some harmless text. Later chapters measure this with precision and recall. For now, remember that redaction lowers risk and does not remove it. Legal obligations can still apply to data you failed to detect.
A simple risk check
Before building anything, list each place where text is stored or sent. A short script can make this inventory explicit and reviewable.
FLOWS = [
{"name": "model API call", "leaves_system": True, "retention_days": 30},
{"name": "application log", "leaves_system": False, "retention_days": 365},
{"name": "vector store", "leaves_system": False, "retention_days": None},
]
def needs_redaction(flow, max_days=30):
retention = flow["retention_days"]
return flow["leaves_system"] or retention is None or retention > max_days
for flow in FLOWS:
print(flow["name"], "->", "redact" if needs_redaction(flow) else "ok")The rule here is simple on purpose: redact when data leaves your system or is kept longer than a limit you choose. Unlimited retention counts as too long. Your own rule will depend on your contracts and policies.
Exercise
A team logs every prompt for 90 days for debugging, and the prompts contain customer emails. Name two risks, and say which control from this chapter reduces both.
Show answer
Risks include wider access to the logs than to the main database, and a deletion request that cannot be fulfilled because copies remain in the logs. Redacting emails before the prompt is logged (data minimization) reduces both, because the logs then hold no email to expose or to delete.
Exercise
Why is it wrong to call a redacted prompt "anonymous" without further evidence?
Show answer
Detection can miss values, and remaining details such as a rare job title plus a city can still identify a person. Redaction lowers risk but does not guarantee anonymity.