Privacy by Design and Default Questions
Designing privacy into products, architectures and the software development lifecycle instead of bolting it on afterward. Covers the privacy-by-design principles and privacy-protective defaults, data minimization and purpose limitation at design time, personal-data flow mapping and PII inventory for a feature, consent and preference design including consent storage, enforcement across web and mobile and region-specific consent flows, retention and deletion design including legal holds, deletion across backups and immutable logs, provable deletion, and data-subject access, export and erasure flows, PII-safe logging, telemetry and session replay, on-device processing to limit data exposure, privacy-versus-personalization trade-offs, privacy in ML training data, feature stores and erasure from trained models, and privacy review gates, checklists, CI/CD checks, release readiness and requirements traceability inside engineering workflows. Includes designing privacy-first features, reference architectures, remediating privacy design flaws and rollout programs across product teams, and working with product, legal and security partners. Cryptographic and statistical privacy techniques, formal impact assessments, data-protection law, cross-border transfer rules, vendor risk, and encryption or access-control mechanics are covered elsewhere.
You inherit a team where engineers routinely log user identifiers to debug. How would you change that, covering immediate fixes, habits, and long-term guardrails?
Sample Answer
Direct answer. Treat it as a habit and tooling problem, not a discipline problem. Engineers log IDs because the logs are their fastest debugger, so the change must give them a better way to debug before it takes the old way away. I would sequence it: stop the leak this week, replace the practice over the next weeks, then enforce with guardrails so it stays fixed.
Why it matters. A user ID that can be linked to an account is personal data, usually pseudonymous (it stands in for a name but can still be linked back to a person) rather than anonymous (not linkable at all), and logs are typically retained widely and readable by many people. The risk is broad access, long retention and copies in third-party log tools. A log index is the searchable collection a log tool keeps, and each index has its own retention and access list.
Immediate fixes (first week)
- Measure first: scan a day of logs per service for IDs, emails and tokens and rank services by volume, so the first fixes go where the most data is. A week-1 result might look like this (illustrative):
checkout1,840 hits per day, mostly emails;search310;notifications95; every other service under 20. The first fixes then go tocheckout. - Shorten retention on the worst log indexes and restrict who can search them.
- Stop the new logging: a lightweight change in the shared logging library that masks fields named
email,user_id,phone, plus tokens. - Do not shame anyone. Announce the why, the date and the replacement.
Habits (weeks 2 to 6)
- Give people a better way to debug. Log a request ID or trace ID (a random value per request) instead of the user. Support passes along the user's request ID; engineers follow it across services.
- Where the same user must be followed across requests, log a keyed hash of the ID (HMAC, a hash made with a secret key). A plain hash of an email can be reversed by guessing, so the key matters and sits with a small group. A privileged lookup tool resolves it for a ticket: support enters the user named on the ticket, the tool recomputes that user's keyed hash and shows whether it matches the
user_refin the logs, and it records who asked and the ticket number. - Add a pull request checklist item, "does this log line contain user data?", and run a short session using real log examples.
- Before and after example:
BEFORE: payment failed for user 48213 (jane.doe@example.com) card ending 4242
AFTER : payment failed request_id=7f3a9c2e user_ref=hmac:9d1e4b amount_bucket=50-100 reason=card_declined
Long-term guardrails
- Typed logging: the logger accepts declared fields only, for example
log.info("payment_failed", request_id=rid, amount_bucket="50-100"). A call that addsuser_email=...is rejected at build time (by the type checker in a typed language, or by a schema check in CI where the language cannot enforce it) because that field was never declared, so a free-formuserfield cannot be added casually. - CI (continuous integration) lint that flags log calls with banned field names, and a pipeline scrubber (a filter between the application and log storage) that drops or masks PII (personally identifiable information) patterns such as email addresses before storage.
- Retention tiers: debug logs for days, audit logs separate and locked down.
- A weekly count of scanner hits by team, reviewed with managers. Success is that count trending to near zero, with exceptions tracked.
- An owner for the logging standard, and an exception process that ends in an expiry date.
What would change my call. If a regulator inquiry or an incident is already open, the first week becomes purging and evidence preservation, with counsel involved. If debugging time visibly worsens, fix the tooling before tightening the rules, or engineers will route around it.
Your support team wants to use free-text customer chat transcripts for analytics and model training. The text contains names, account numbers and occasionally health details. What would you require before this data is used, and what processing design makes it safe enough?
Sample Answer
Direct answer
I would not allow raw transcripts into analytics or training. I would require a documented purpose and legal basis (under GDPR you need one of a short list of lawful reasons, such as consent or legitimate interests, before processing personal data), a risk assessment, a redaction pipeline that runs before any data scientist sees text, separated access, and a retention limit. Health details are special-category data (types of personal data that GDPR protects more strictly, such as health, beliefs and biometrics) under GDPR Art. 9, so they get the strictest treatment, and if reliable redaction is not possible for a use, I would refuse that use.
What I would require first
- Purpose and lawful basis. "Improve support" is too vague. Name each use (for example topic analytics, and a model that suggests replies). Customers were told the chat was for support, so using it for model training may be a new purpose that needs its own basis, notice or opt-out. Counsel decides the basis.
- An extra condition for the health content. Special-category data needs an Art. 9(2) condition (such as explicit consent) on top of the ordinary lawful basis, and legitimate interests alone does not cover it. This is another reason to strip health text before any use.
- A DPIA (data protection impact assessment), a structured risk review, because this is large-scale, sensitive, and new technology.
- Owner and sign-off from the data owner and privacy lead before any copy is made.
Processing design
- Detect. Combine pattern rules for account numbers and emails, a named-entity model (software trained to spot names of people, places and organisations in free text) for names, and a keyword or classifier layer for health terms. Measure recall (the share of the sensitive items that really exist which the detector catches) on a hand-labelled sample, since a missed entity is a leak, and accept that no detector is perfect.
- Redact or replace. Swap with typed placeholders (for example [NAME], [ACCOUNT]) or consistent fake tokens (the same fake name each time the same real name appears, so a reader can follow who said what) so conversation structure survives. Before: "Hi, I'm Priya Nair, account 48213, my diabetes medication was refused." After: "Hi, I'm [NAME], account [ACCOUNT], my [HEALTH] was refused." Drop whole transcripts that contain health content if the use does not need them.
- Separate. Raw transcripts stay in a restricted store with a few named readers. The redacted copy goes to the analytics zone. Any re-link key (the table that maps a fake token back to the real value) lives elsewhere with its own access.
- Retain briefly. Keep raw text only as long as the redaction pipeline needs, and delete the redacted copy when the model and analysis no longer need it. Add deletion-request handling so a customer's transcripts can be located by ID.
- Guard the model. A model trained on residual text can memorize it, so test generations for leaked names and numbers before release, and keep the training run's data version recorded.
Worked example
On a sample of hand-labelled transcripts containing 500 sensitive spans in total, say the detector finds 460 of the 500 (92% recall). The 8% left (40 spans) would flow into training. That is too many for health content, so I would add a second pass or exclude those transcripts, and only proceed when a re-measured sample meets a bar the privacy lead signs. An illustrative bar for health content is 99% or better, and the sample must be big enough to show it: if a fresh sample of 500 spans has zero misses, the 95% upper limit on the miss rate is still about 3/500 = 0.6%, so recall of roughly 99.4% or better is supported. A 92% result is nowhere near it.
When to refuse
Refuse if consent or basis cannot cover the use, if health data is essential to the text and cannot be removed, or if the team cannot show redaction quality.
Tell me about a time you found data being used in a way that broke your company's privacy commitments, for example analytics using personal data without consent. What did you do, who did you tell, and how did you stop it recurring?
Sample Answer
Situation
At a previous company, I noticed while building a funnel report that the analytics events included email addresses for users who had declined the cookie banner. Our privacy notice said analytics ran only for users who opted in. The tool vendor's SDK (software development kit) was initialised before the consent check on one page type, so those events were collected anyway.
Actions I took
- Confirmed it first. I reproduced it in a test browser with consent declined, captured the network call showing the email field, and counted the affected event types in the warehouse (the central database where analytics data is stored for reporting), without opening any individual user's records.
- Contained it the same day. I told the engineer owning the page and asked for a feature flag (a switch in the code that turns a behaviour on or off without a new release) to stop the SDK loading before consent. I restricted warehouse access to the affected table until it was cleaned.
- Told the right people. I raised it with the privacy lead (the person who owns privacy decisions day to day; a data protection officer, or DPO, is the independent adviser some companies are legally required to appoint, if you have one), my manager and the analytics owner, in writing, with the evidence and what I did and did not know. Whether it counted as a reportable breach (one that must be notified to a regulator or to users) or needed user notice was their and legal's decision, not mine.
- Cleaned up. We deleted the non-consented events and the derived tables (reports and summaries built from those events), and recorded what was removed.
- Stopped it recurring. We added an automated test in CI (continuous integration) that loads each page with consent declined and fails if any analytics request fires, and added a consent-aware check to the tracking-plan review (the meeting where the team approves each new analytics event before it is built) for new events.
Result and reflection
The fix shipped within days, the CI check caught one later regression before release, and the privacy lead used the case to add analytics to the launch checklist. Next time I would raise it in the hour I confirmed it rather than the next morning, because the wait extended exposure.
What makes a strong answer
Show restraint (you do not investigate individuals), escalation (you do not decide legal questions alone), and a systemic fix (a test or gate, not "we reminded people").
Design a retention policy for event-level telemetry used for product analytics that must balance long-term trend analysis with privacy. Specify retention windows for raw events, rolled-up aggregates, and derived features for ML; include deletion, archival, and verification strategies.
Sample Answer
Short answer. Keep the most identifying form the shortest and the least identifying form the longest: raw events 30 days, pseudonymized event-level data 13 months, aggregates 25 months, ML features 90 days rolling. Windows below are illustrative starting points; legal and the product's real analysis needs set the final numbers.
Key terms. Raw events carry direct identifiers (user id, device id, full IP). Pseudonymized means the identifier is replaced by a keyed hash (HMAC, a hash made with a secret key) so rows still join, yet the person is not named. It is still personal data. Aggregated means counts and averages with no per-person rows.
Retention schedule
| Tier | What it holds | Window | Deletion mechanism |
|---|---|---|---|
| Raw events | user id, device id, full IP, timestamps | 30 days | drop daily partitions on schedule (the table is split into one chunk per day, and an old chunk is deleted whole, which is fast) |
| Pseudonymized events | HMAC id, coarse geo, no free text, no IP | 13 months | partition drop; per-user delete; a suppression list (the list of deleted users' keyed ids) stops late-arriving events for them from being stored |
| Rolled-up aggregates | counts per day, per segment, no user rows | 25 months | partition drop; segments under a minimum size (say 20 users) are suppressed (a group of 1 or 2 people reveals what those individuals did, so the count is hidden) |
| Derived ML features | per-user features | 90 days rolling (each day the oldest day of features drops off) | recomputed from kept data, old versions dropped |
| Training snapshots | dataset versions used for a model | 180 days, version tagged | deleted with the version record |
Snapshots are the exception to the 90-day feature window: a snapshot freezes feature values for reproducing a model, so it holds per-user data for up to 180 days. Either build snapshots from pseudonymized rows with no direct identifiers, or accept that a deletion request does not reach an existing snapshot until it expires (at most 180 days), say so in the policy, and exclude deleted users when the next snapshot is built. A trained model is not edited either: retrain on the next scheduled cycle from data that already excludes the deleted user.
Why 13 and 25 months: 13 months lets a year-over-year comparison include one extra month; 25 months gives two full years of trend. If analysts can answer questions from aggregates, the event-level tiers can shrink.
One record traced. A user's page view is stored on 2026-01-05. The raw copy is dropped on 2026-02-04 (30 days). The pseudonymized copy lives until 2027-02-05 (13 months). Only its contribution to a daily count remains after that, kept until about 2028-02. If the user deletes their account on 2026-03-01, the raw copy is already gone, so the pseudonymized rows are deleted that day and their keyed id goes on the suppression list. Per-user features are recomputed without them within their 90-day window, and any snapshot that still holds them expires by 180 days from its creation.
Logs by type (forensic need versus minimization)
- Security and audit logs: 12 months. Forensics needs the long window to see slow intrusions.
- Application debug logs: 14 days, free text scrubbed of PII at ingestion.
- Access logs with IP: 30 days, then IP truncated.
Archival. Archiving personal data is still retention, so never "archive raw" to dodge a window. Only aggregates go to long-term cold storage.
Backups and replicas. Backups expire on their own rotation (for example 35 days). Replicas follow the primary. State in the policy that a restore must replay the deletion ledger (the append-only list of deletion requests, kept without readable personal data) before data is served again.
Verification
- Each expiry job writes a receipt: table, partitions dropped, row counts.
- A daily check asserts that the oldest event time in each tier is inside its window.
- A weekly test injects a synthetic user (a fake test person created for this check), deletes it, and queries every tier and backup index for it.
- Per-user deletions are checked against the suppression list so deleted users do not reappear from late events.
Trade-off. Shorter raw windows make incident debugging and model retraining harder. Keep a pseudonymized copy for that need rather than extending the raw window.
Product wants data sharing to stay opt-out because opt-in would crater participation. How would you decide the default, and how would you test its effect on conversion and long-term retention without gaming the result?
Sample Answer
Direct answer
I would not treat the default as a pure growth call. First ask whether the law lets this sharing run on an opt-out default at all, then pick the default by what the sharing is, and only then run an experiment. Opt-out means data is shared unless the user switches it off. Opt-in means nothing is shared until the user turns it on.
Step 1: is opt-out even available? (counsel confirms)
- Under the EU GDPR (General Data Protection Regulation; its articles are the binding rules and its recitals are the explanatory preamble that shows how to read them), consent must be an affirmative act: recital 32 says "silence, pre-ticked boxes or inactivity should not therefore constitute consent". If the sharing needs consent, opt-out is not a lawful design there, however much conversion it saves.
- Article 25(2) also says that by default only data necessary for each specific purpose is processed.
- Some other regimes (certain US state laws) treat sale or sharing of data as opt-out with a visible "do not sell or share" control. So the answer can differ by market. I would state what each rule requires and let counsel decide the market list.
Step 2: choose the default by the nature of the sharing
| Question | Points to opt-out | Points to opt-in |
|---|---|---|
| Would an ordinary user expect it from the feature? | Yes | No, it is a surprise |
| Who receives the data? | Own processors | Independent third parties |
| Sensitivity (location, health, minors) | Low | High |
| Can the user undo it and have data removed? | Easily | Hard |
If it fails most rows, the answer is opt-in, and the job becomes making opt-in convert: ask at the moment the user sees the benefit, state what is shared in one plain line, and offer a middle level (share aggregated data, or pseudonymized data where names are replaced by codes but it remains personal data).
Step 3: test it without gaming
Randomize by user into two arms, only in markets where both arms are lawful. Pre-register (write down and date before launch) the hypothesis, the primary metric, the run length and the stopping rule (the condition under which you stop), and do not peek and stop early. Peeking inflates false wins because every look is another chance for random noise to cross the 5% line. In a simulation of 1,000 experiments with no real difference, checking ten times and stopping at the first p below 0.05 declared a winner in about 19% of them instead of 5% (MEASURED, one simulation run).
- Both arms get equal-prominence choices and equally easy reversal. A hidden or hard-to-find toggle is a dark pattern (an interface design that steers people into a choice they did not clearly make): it inflates opt-out participation and produces a result that measures confusion.
- Primary metric: 90-day retention, because a default that wins on day-one sharing but loses users later is a loss.
- Counted separately: share rate, revocation within 30 days, privacy complaints and support contacts, and a short comprehension check ("what is shared?"). Participation that comes from not noticing is not engagement.
- Illustrative power calculation (computed in python). Alpha 0.05 is the accepted false-alarm rate and power 80% is the chance of catching a real lift. The normal approximation formula is n = (1.96 * sqrt(2 * pbar * (1 - pbar)) + 0.8416 * sqrt(p1(1-p1) + p2(1-p2)))^2 / (p1 - p2)^2, where 1.96 and 0.8416 are the normal-curve values for 5% two-sided significance and 80% power. With 40% baseline retention, a 2-point lift (p1 = 0.40, p2 = 0.42) needs about 9,490 users per arm, and a 3-point lift (p2 = 0.43) about 4,230 per arm. The 2-point test needs about 2.24 times the 3-point sample, which is (3/2) squared, because the difference is squared in the denominator; halving the detectable lift roughly quadruples the sample. Retention needs the 90-day wait, so the answer is not available at launch.
What would change my call
A regulator or counsel ruling the opt-out lawful and the data low-risk would let me ship opt-out with a prominent control. High revocation or complaint rates in the opt-out arm would flip me to opt-in even if retention looked flat. Product owns the experiment, legal decides the lawful arms, and a Security Architect reviews where the shared data goes.
Unlock Full Question Bank
Get access to all 16 Privacy by Design and Default interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.