Why this matters
AI features move data to new places: third-party model APIs, vector stores, logs full of prompts, browser storage of drafts. Each move needs the same discipline as any data flow, applied consistently. This lesson applies 5.5 and 5.6 to AI.
Q28. PII and PHI?
Minimize; redact or tokenize before external calls unless the endpoint is covered (HIPAA basics); provider storage off (store: false, P2); hash user identifiers sent to providers; keep clinical drafts out of long-lived browser storage; audit logs that record field names, never values (P12); retention and deletion defined; obligations confirmed, not assumed.
Q29. Outbound calls and SSRF?
Any URL your server fetches on someone's behalf, including vendor-issued presigned URLs, is an attack path. Require https, resolve and refuse private, loopback and link-local addresses, send no API key to storage hosts, stream large files. Casebook: SSRF hardening for presigned storage URLs (P1); checking every URL called for a user (P7). Agents with web or HTTP tools make this critical.
Q30. Secrets?
Read keys by name from the environment or a secrets manager; say only whether a key is set; keep it out of repr, logs and error bodies (scrub); refuse to start with placeholder secrets (P7); never in git, rc files or chat. Casebook: P1 keeps the API key out of repr and scrubs it from error bodies.
Vendor data terms checklist
Before sending real user data to any model or speech/OCR vendor, check:
- Is input/output stored? For how long? Can storage be disabled?
- Is data used for training by default? Can you opt out (and did you)?
- Which regions process the data?
- Is there a data-processing agreement, and a BAA if health data is involved?
- Does consent from the data subject cover this processing?
Some speech and AI vendors train on uploads unless you opt out; read terms before sending anyone's audio or documents. Record consent per item for evaluation datasets (Q24).
Common mistakes
- Logging full prompts and completions with personal data in plain text.
- Using a consumer chat app with client data.
- Embedding personal data into a shared vector index without tenant filters.
Check yourself
Where should de-identification happen in a pipeline that calls an uncovered model API with clinical text?
Upstream, before the call: detect and replace identifiers with tokens, send only de-identified text, and re-identify only at presentation for authorised users, with an audit trail. Better still, use an endpoint covered by the right agreement.
Name four places an API key can leak in an AI service.
Source control; logs (including debug prints of config objects); error messages echoing provider responses; images or build artefacts; client-side code; shared chat or tickets.
Build it
Add a redaction step before your model calls (emails, phone numbers, IDs), a structured log that records which fields were redacted without values, and a test proving the key never appears in any log line or error.