PII is redacted or screened before AI API calls
Why it matters
GDPR Article 25 mandates data protection by design — minimizing the personal data transmitted to processors. OWASP A02 (Cryptographic Failures) and CWE-359 (Exposure of Private Information) both apply when PII travels unredacted to a third party. Users routinely paste email addresses, phone numbers, credit card numbers, and SSNs into chat interfaces without realizing the consequences. Without a server-side screening pass, every one of those values is sent verbatim to the AI provider, where it persists in their logs and training pipelines according to their retention policies — not yours. The 2023 Samsung incident, where employees pasted internal code into ChatGPT, is the canonical example of this failure mode.
Severity rationale
Critical because unredacted PII sent to a third-party AI provider constitutes unauthorized data disclosure under GDPR Art. 25, CWE-359, and OWASP A02, with no technical control stopping the exfiltration once the API call fires.
Remediation
Implement a server-side redaction pass in lib/ai/pii-guard.ts and apply it before every AI API call. Server-side is mandatory — client-side filtering is bypassable.
// lib/ai/pii-guard.ts
const EMAIL_RE = /\b[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}\b/g
const PHONE_RE = /(\+?1[\s.-]?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}/g
const CC_RE = /\b\d{4}[\s\-]?\d{4}[\s\-]?\d{4}[\s\-]?\d{4}\b/g
export function redactPii(input: string): string {
return input
.replace(EMAIL_RE, '[EMAIL]')
.replace(PHONE_RE, '[PHONE]')
.replace(CC_RE, '[CARD]')
}
Apply before every AI invocation:
const safePrompt = redactPii(userInput)
const response = await openai.chat.completions.create({
messages: [{ role: 'user', content: safePrompt }]
})
For higher-assurance use cases, AWS Comprehend DetectPiiEntities covers 100+ PII types. Verify with a unit test: pass an email address string and assert the AI mock receives [EMAIL].
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the AI Data Privacy Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- gdpr · Art. 25 — Data protection by design and by default
- owasp:2021 · A02 — Cryptographic Failures / sensitive data exposure
- cwe · CWE-359 — Exposure of Private Personal Information to an Unauthorized Actor
- nist:rev5 · SI-12 — Information management and retention
- owasp-llm:2025 · LLM06 — Excessive Agency — sensitive data leaving trust boundary
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-data-privacy·automated