Topic 4 of 5 · 4 min read
Redaction, retention and access controls for AI data
Goal: Choose redaction, retention and access controls for an AI feature's prompts and logs and justify each by the leak it prevents.
Pick each data control for the specific leak it stops: redact to shrink what exists, limit retention to shorten how long it exists, and restrict access to shrink who can see it.
Check yourself · 1 of 3
Which control best prevents a tracing vendor from holding customers' email addresses?
Why it matters
You cannot leak what you never stored. Every control on this page is a way to hold less data, for less time, in fewer hands. A team that adds "security" without naming the leak ends up with a long checklist and the same holes. Matching control to leak makes the plan short and checkable.
The four controls
- Redact before sending. Replace names, emails, card numbers and ID numbers with placeholders such as
[EMAIL]before the text goes to the model or a vendor. The model usually still does the job, because it rarely needs the real value. This prevents leaks to the vendor and into every later log. - Mask in logs. Even when the model gets the full text, store a masked copy in traces. This prevents leaks through the trace store and through copied tickets.
- Limit retention. Set a clear lifetime, such as 30 days, and delete on schedule. Ask each vendor for its retention and whether a zero-data-retention option exists. The OpenAI and Anthropic documentation both describe retention settings and the conditions for zero retention. This prevents old data being found in a future breach.
- Restrict access. Give trace access by role: the on-call team sees traces, everyone else sees counts. Log who opened what. This prevents curiosity reads and insider leaks.
Before and after
Before: All prompts go to the vendor in full, traces are kept until disk is full, and the whole company has the tracing password.
After: Emails and card numbers are replaced before the call. Traces keep 30 days. A role called "ai-support" can open traces, and every open is recorded. The vendor contract states no training on our data.
Notice that each sentence in the "after" answers one leak. Nothing is added "just in case".
What goes wrong
- Redaction that misses. A pattern for emails does not catch a name or an address in free text. Test the redactor on real-looking samples.
- Over-redaction. Removing everything makes the answers useless and people turn the control off.
- Retention without deletion. The policy says 30 days but backups keep it for a year.
- Zero retention assumed. The option may need a request or an agreement and may not cover every feature, so check the vendor's page.
A short code branch for engineers:
import re
EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+")
def mask(text):
return EMAIL.sub("[EMAIL]", text)
A real redactor needs more patterns and tests, but the idea is this simple.
Examples
Redact, then ask
A bot that summarises customer complaints replaced emails and phone numbers with placeholders before calling the model. The summaries were just as useful and the vendor never held contact details.
A retention table
Prompts to vendor: not stored (zero retention agreed). Traces: 30 days, ai-support role only. Eval set: synthetic or redacted chats, reviewed quarterly. Each row stops a different leak.
Key points
- Each control should name the leak it prevents: redaction for vendor and log copies, retention for old data, access control for who reads.
- Redact personal data before it reaches the model or a vendor when the task does not need the real value.
- Set a written retention period and check that backups and vendor copies follow it.
- Zero-data-retention options depend on the vendor and plan, so read the vendor's current documentation.
- Test redaction on realistic samples, because patterns miss names and addresses in free text.
Common mistakes
- Adding controls without naming which leak each one stops.
- Writing a retention period but forgetting backups and vendor-side copies.
- Trusting a redaction pattern without testing it on real-looking text.
- Assuming zero data retention applies to every feature of a vendor's product.
Check yourself · 2 of 3
A policy says traces are kept 30 days, but nightly backups are kept a year. What is wrong?
Check yourself · 3 of 3
Why redact names before sending a complaint to a model for summarising?
Practice items, not counted towards your mastery.
Start here
- OWASP LLM07:2025 System Prompt Leakage (opens in a new tab)DocsFree
Defines prompt leakage and states that secrets and access rules do not belong in the system prompt.
- LLM02:2025 Sensitive Information Disclosure (OWASP GenAI) (opens in a new tab)StandardFree
Lists how LLM apps expose personal and confidential data, with prevention steps.
- Logging Cheat Sheet (OWASP) (opens in a new tab)ArticleFree
Says what never to log, how to protect log files and how long to keep them.
More for this topic
- Your data (OpenAI API guide) (opens in a new tab)DocsFree
Shows how one vendor handles stored API data, retention and zero data retention options.
- API and data retention (Claude docs) (opens in a new tab)DocsFree
Anthropic's description of what is retained and how zero data retention works.