Sub topic 3
Why it matters: risks and obligations
This chapter explains what goes wrong when personal data reaches an LLM application unchecked, and which legal and contractual duties apply. It gives you the reasons behind the detectors and redaction steps in later chapters. It is not legal advice. Regulations differ by country and sector, so confirm specifics with your legal or privacy team.
Prerequisites: you know basic Python, you have called an LLM API, and you know what a prompt, a response, and a log are. The earlier chapters on kinds of personal data and on data flows are assumed. The short recap below is enough if you skipped them.
Recap: what is at stake
Personal data is any information that relates to an identifiable person. Direct identifiers such as a name, email address, or card number point at one person alone. Quasi-identifiers such as a postcode, birth date, and job title identify someone only in combination. Sensitive categories such as health, religion, or biometrics carry stricter rules. An LLM app handles all three, often in free text that nobody planned to treat as a database.
The risks
Risks fall into five groups. Each one maps to a point in the request pipeline where redaction can help.
Disclosure to a third party
Most LLM apps call a hosted model. Every prompt you send is a disclosure of its contents to the model provider, a third party. Even when the provider promises not to train on API data, it still processes the data, may retain it for abuse monitoring, and may use sub-processors in other countries. Raw personal data in the prompt is therefore a data transfer you must justify and document.
If you redact before the call, the provider receives placeholders instead. The disclosure shrinks, and so does the damage if the provider is breached.
Persistence in places you forgot
Personal data rarely stays where you sent it. Typical copies:
- Application logs that record full prompts and responses for debugging.
- Traces and analytics from observability tools, often hosted by another vendor.
- Conversation history stored for multi-turn chat.
- Vector databases that hold embeddings and the source chunks of documents.
- Evaluation sets and fine-tuning data built from real traffic.
- Backups of all of the above.
The user typed their phone number once. Your system may now hold it in six places, each with its own retention rules and access list. Deletion requests must reach every copy. Redacting early means the copies contain placeholders, so there is less to find and delete.
Leakage through model behavior
A model that was trained or fine-tuned on text containing personal data can reproduce it. This is memorization: rare strings, such as an email address that appeared a few times, can be emitted verbatim under the right prompt. The risk applies to fine-tuning you do yourself, and to any shared context your app builds. A retrieval pipeline can also surface one user's document in another user's answer if access control is weak. In that case the model is working correctly and the leak is an authorization bug, but the effect on the victim is the same.
Exposure through attacks
Prompt injection is text in the input or in retrieved content that tells the model to ignore its instructions. If the context holds personal data and the model has tools, such as email or web requests, an attacker can ask the model to send that data out. A common variant makes the model render a Markdown image whose URL contains the data, so that the user's browser sends it to the attacker's server.
Redaction limits the loss: if the context contains <EMAIL_1> instead of the address, there is nothing useful to steal. It does not remove the injection problem, which is covered in the last chapter of this tutorial.
Harm to people and to you
For the person, consequences include identity theft, fraud, stalking, discrimination, and embarrassment from disclosed health or financial details. For your organization, they include fines, breach notification costs, contract termination, and lost customer trust. The cost lands on people who never chose to use your system, such as the third parties named in a user's message.
Principles that drive the design
Several principles recur in privacy law and security practice. They translate directly into engineering decisions.
- Data minimization. Collect and process only what the purpose needs. If the model can summarize an invoice without seeing the customer's name, the name should not be sent. This is the legal basis for redacting before the model call.
- Purpose limitation. Data collected for support tickets should not quietly become training data for something else.
- Storage limitation. Keep data no longer than necessary. Set retention periods for logs and history, and enforce them.
- Security. Apply technical measures proportionate to the risk. Redaction, access control, and encryption are all such measures, and none replaces the others.
- Accountability. You must be able to show what you did. A written data-flow inventory and test results for your detectors count as evidence.
Regulatory drivers
The list below names the frameworks you meet most often. Which ones apply depends on where your users are, what data you handle, and your role.
| Framework | Applies to | Relevant points for LLM apps |
|---|---|---|
| GDPR (EU and UK GDPR) | Personal data of people in the EU or UK, or processing by organizations established there | Lawful basis, minimization (Art. 5), special categories (Art. 9), processor contracts (Art. 28), security (Art. 32), breach notice within 72 hours (Art. 33), international transfers (Chapter V), erasure (Art. 17) |
| CCPA/CPRA | Consumers in California, for businesses over certain thresholds | Notice, access and deletion rights, limits on selling or sharing data, sensitive personal information category |
| HIPAA | US health providers, insurers, and their business associates | Protected health information, business associate agreements, de-identification by removing 18 listed identifier types (Safe Harbor) |
| PCI DSS | Anyone who stores, processes, or transmits payment card data | Strict controls on card numbers; the simplest compliance path is to keep them out of systems entirely |
| Contracts and internal policy | Your customers and employer | Often stricter than the law: "no customer data to third-party AI services" is a common clause |
Three points deserve emphasis.
- Pseudonymized data is still personal data under GDPR. If you replace a name with
<PERSON_1>but keep a mapping that can reverse it, the data can still be linked to a person. Pseudonymization lowers risk and is recognized as a safeguard, but it does not take the data out of scope. Truly anonymous data, where re-identification is not reasonably possible, is out of scope. That is a high bar, and the quasi-identifiers from the recap are the reason: a record with no name but a rare job, town, and birth date can still identify one person. - Your role matters. When you send data to a model provider on behalf of your customers, you are usually a processor, or a sub-processor, and need a data processing agreement. When you decide the purposes, you are a controller. Both carry duties.
- Regulators look at outcomes. A detector with 90% recall that is documented, tested, and paired with other controls is a defensible measure. An unmeasured regex that "should catch most things" is hard to defend after an incident.
Turning obligations into a checklist
A short, checkable inventory makes these abstract duties concrete. The sketch below models each data flow and flags the two problems seen most often: raw data leaving your boundary, and raw data kept too long. It is intentionally simple. Real inventories also record legal basis and owner.
from dataclasses import dataclass
@dataclass
class Flow:
name: str
leaves_boundary: bool # sent to a vendor or another region
retained_days: int # how long the copy is kept
redacted: bool # personal data replaced before this point
def review(flows, max_retention_days=30):
findings = []
for f in flows:
if f.leaves_boundary and not f.redacted:
findings.append(f"{f.name}: raw personal data leaves the boundary")
if f.retained_days > max_retention_days and not f.redacted:
findings.append(
f"{f.name}: raw data kept {f.retained_days} days "
f"(limit {max_retention_days})"
)
return findings
flows = [
Flow("prompt to model API", True, 0, False),
Flow("debug logs", False, 90, False),
Flow("vector store chunks", False, 365, True),
Flow("trace vendor", True, 30, True),
]
for finding in review(flows):
print(finding)Running it prints two findings: the prompt to the model API sends raw data out, and the debug logs keep raw data for 90 days. The vector store passes because its chunks are redacted, and the trace vendor passes because its data is redacted and kept within the limit. The later chapters on detection and redaction are how you flip redacted to True honestly.
What redaction does not fix
Be precise about what you are buying. Automated redaction reduces exposure, but several risks remain:
- Missed entities. No detector has perfect recall. Names in unusual spellings, informal references like "my landlord's wife", and identifiers in unexpected formats get through.
- Residual context. After removing names, the remaining text can still identify someone: "the only cardiologist in a town of 800 people."
- Placeholders that leak structure. Numbered placeholders reveal that a person was mentioned and how many distinct people appear.
- The mapping itself. Reversible pseudonymization creates a table of real values. It becomes a high-value target and needs the same protection as the original data.
- Non-text data. Images, audio, and attached files may carry personal data that a text detector never sees.
Because of this, treat redaction as one layer. Combine it with access control, retention limits, vendor agreements, encryption, and monitoring. The final chapter returns to this idea.
Practical decisions this chapter should change
- Decide per data flow whether the model needs the raw value. Names and card numbers rarely help a model summarize or classify text.
- Set retention on logs and history before launch, not after the first audit.
- Record the model provider's role, data location, and retention terms in your inventory.
- Treat sensitive categories (health, biometrics, beliefs) as a reason for stricter redaction, and consider keeping them out of third-party services entirely.
- Plan for deletion: know every place a user's data can live, and prefer designs where most copies hold only placeholders.
Exercise
Your support app replaces each customer name with a placeholder like <PERSON_1> before calling a hosted model, and keeps a mapping table so replies can be restored. A colleague says the stored conversations are now "anonymous" and exempt from GDPR. Is this correct? Name one risk the design still carries.
Show answer
No. Because the mapping table lets you reverse the placeholders, the data is pseudonymized, not anonymous, and pseudonymized data is still personal data under GDPR. Remaining risks include the mapping table itself becoming a target that needs full protection, names the detector missed, and quasi-identifiers (such as a rare job or town) in the remaining text that can still identify the person.
Exercise
A team logs every full prompt for 180 days to debug model quality, and also sends prompts to a vendor's tracing service. Using the checklist in this chapter, list the two findings the review function would raise if redaction is not applied, and one change that fixes both.
Show answer
Findings: raw personal data leaves the boundary (the tracing vendor), and raw personal data is kept longer than the 30-day limit (the 180-day logs). A single fix is to redact prompts before they are logged or traced, which makes the stored copies placeholders. Cutting log retention to 30 days or less is a complementary control.