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.
Your product keeps authentication logs, transaction records and marketing analytics indefinitely. How would you set a retention period for each, what drives the difference, and how do you make sure deletion actually happens?
Sample Answer
Direct answer
A retention period is the answer to "how long do we have a valid purpose for this data?", not a round number. For each data class I identify the purpose, the legal or contractual minimum that forces us to keep it, and the operational need, then keep it for the longest justified of those and no longer. Deletion only counts when it is automated and verified. The periods below are illustrative starting points; the legal minimums are set by counsel or the relevant regulation for your jurisdiction.
Decision approach
- Purpose: why do we hold it? (Purpose limitation: data collected for one purpose should not linger because it might be useful for another. For example, login IP addresses collected to detect account takeover should not be kept to build ad audiences.)
- Legal and contractual floor (the minimum time a rule forces us to keep it): is there a rule that requires us to keep it (tax, accounting, sector law)? For instance, many countries' tax rules require invoices to be kept for a set number of years, and the number differs by country. Counsel confirms.
- Operational need: how long is it useful for debugging, fraud, security investigation or support?
- Set the period at the longest of the justified inputs, then decide the end state: delete, or aggregate into data that is no longer about individuals.
The three data classes
| Data | What drives the period | Illustrative approach |
|---|---|---|
| Authentication logs (logins, failures, IPs) | Security investigation and fraud detection, not business reporting | Keep raw logs for a short window that covers typical investigation lag, for example 90 days in searchable storage; keep summarized security counters longer. |
| Transaction records | Legal and accounting obligations, plus dispute handling | Keep for the legally required period set by finance and counsel (often multiple years), restrict access, then delete. Do not extend it for analytics convenience. |
| Marketing analytics | Value fades fast, and consent often governs it | Keep event-level data for a short window, for example 13 months to compare year over year, then aggregate and drop user-level identifiers. Delete sooner if consent is withdrawn. |
Making deletion actually happen
- Mark it at write time: store a
created_atand a data-class tag, so an expiry can be computed instead of guessed. - Automate: time-to-live (TTL, automatic expiry) settings on log stores and object storage, and a scheduled job for database rows.
- Cover copies: replicas, search indexes, the data warehouse and backups. Backups usually cannot be edited, so document that they age out on their own schedule and that restored data is re-purged.
- Verify: the job emits a count of rows deleted, and a periodic check queries for records older than the limit plus a grace margin sized to how often the purge job runs (for a nightly job, one day) and expects zero, so that rows merely waiting for the next purge do not raise a false alarm. Plant a test record with an old date and confirm it disappears.
- Own it: each data class has a named owner and the retention schedule lives in version control with a review date.
Worked example
Transaction records: purpose is billing and disputes; the floor is whatever finance and counsel confirm, say 7 years for invoices (illustrative; 7 x 365 = 2,555 days); the operational need is dispute handling, say 1 year; the longest justified input wins, so 7 years, then delete. The nightly check is "count of transaction rows older than 7 years plus 30 days", expected 0. Marketing analytics: purpose is product and campaign insight, floor none, operational need is comparing this month with the same month last year, so 13 months (12 plus one month of slack), then aggregate; the check is "count of event rows with a user identifier older than 13 months plus 1 day", expected 0.
Auth logs: purpose is security, floor is none, operational need is investigations that surface within about a month, so a 90-day raw window gives a safety margin of 60 days over 30 days. The verification query "count of auth log rows older than 91 days" (90 days plus one day of grace for the nightly purge) should return 0 every night; a non-zero result pages the owner.
Pitfalls
A policy on paper with no deletion job; one blanket period for all data; forgetting derived copies; and keeping data "in case" with no named purpose.
You are tasked with leading a cross-functional program to integrate privacy controls into the CI/CD pipeline (e.g., automated checks for PII in commits, redaction in logs, policy gates on deployments). Propose a 6–12 month roadmap, required engineering and compliance resources, pilot plan, KPIs to measure success, and strategies to gain executive and engineering buy-in.
Sample Answer
Direct answer. I would run it as a 12-month program in four phases (a reduced version can stop after phase 2 at about month 5): baseline and quick wins, a pilot on two or three teams, platform-wide rollout in advisory mode, then enforcement with metrics. Checks start as warnings, only become blocking once measured as accurate, and the program is sold to engineers as less rework and to executives as fewer incidents and faster reviews. CI/CD means continuous integration and continuous delivery, the automated build, test and deploy pipeline. PII means personally identifiable information. Advisory mode means a check shows a warning and never blocks a merge; a policy gate is an automated check that can stop a deployment; a suppression is a recorded decision to ignore one finding.
Roadmap
| Months | Phase | Deliverables |
|---|---|---|
| 1-2 | Baseline | Inventory of pipelines and repos, list of past privacy bugs by class (PII in logs, secrets, untagged schema changes), pick the first 3 to 4 checks, agree the exception process |
| 3-5 | Pilot | Two or three willing teams run PII-in-commit scanning, log redaction library and one deployment policy gate in advisory mode |
| 6-9 | Rollout | Extend to more teams via shared pipeline templates, add schema and infrastructure checks, tune rules from pilot data, publish docs |
| 10-12 | Enforce | Promote proven checks to blocking, add deployment policy gates (for example production deploy blocked if a new data store has no retention setting), quarterly report |
The phase lengths sum to 2 + 3 + 4 + 3 = 12 months.
Resources (illustrative, scale to org size). One program lead (technical program manager), two platform or DevOps engineers, one privacy engineer to write and own rules, a part-time counsel or privacy lead for policy questions, and a named champion per pilot team. Compliance owns the written standard and the exception record; engineering owns the checks.
Pilot plan. Pick teams with different stacks, one that ships often. Run advisory-only for several weeks, label every finding as a true positive (the finding is real) or a false positive (it is wrong), and set a go-forward bar before the pilot, for example precision of at least 90 percent (at least 9 in 10 findings are real) over at least 50 labeled findings (illustrative). A rule with 60 findings of which 51 are confirmed has precision 51/60 = 85 percent, so it stays advisory and is tuned; after tuning, 48 confirmed out of 50 is 96 percent and it clears the bar. Pilot exit means the bar is met or the rule is cut.
KPIs
- Coverage: share of repos and pipelines running the checks.
- Precision: share of findings engineers confirm as real, per rule.
- Mean time to fix a finding, and number of suppressions and their expiry.
- Privacy bugs found in production or review versus found in CI (leading indicator).
- Pipeline time added, to prove it does not slow delivery.
Buy-in. Executives: frame as reduced incident and rework risk, with the pilot data as proof. Engineers: findings in the pull request, clear fix guidance, a fast exception path, and a rule that is wrong gets fixed within days. Guard against a tool that engineers learn to bypass.
Risks. Blocking too early causes workarounds; a program with no platform owner stalls after the pilot.
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.
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.
Tell me about a time you convinced product managers and engineers to change a feature because of privacy risk. What evidence did you use, what compromises did you offer, and what was the outcome?
Sample Answer
Direct answer
Pick a real story where you changed a design because of privacy risk. The shape that works: name the feature and the specific risk, show the evidence in terms the team cares about, offer a compromise that kept their goal, and report what happened honestly. A model story follows, with illustrative details to replace with your own.
Situation
A product team planned to log full search queries with user IDs to improve ranking (the order in which results appear). Queries were free text, so they would include names and health or financial terms, and the data would sit in a warehouse many people could read.
Task
I was the security or privacy engineer asked to review the design. I needed the team to change the design without losing the ranking improvement they needed.
Actions
- Evidence. I did not argue in principle. I sampled a small set of existing support-search logs (with approval and access controls), counted how many contained identifiable content (52 of 400 queries, or 13%, held a name, email, or health or financial term), and showed three anonymized examples. I also walked through who could read the warehouse table.
- Technical argument and prototype. I built a small prototype of an alternative: log query length bucket, result clicked position, and a coarse category label chosen from a fixed list of about 20 (such as "travel" or "health") and assigned on the server, so the free text itself is not in the event, with the raw text kept for 14 days in a restricted store for ranking debugging only.
- Compromises offered. Keep raw text for a short window with restricted access, review a 5% sample of live queries each month to check the filter keeps working (separate from the one-off log sample above), and drop the user ID from ranking events (the click records the ranking model learns from).
- Communication. With the PM I framed it as launch risk and delay risk: a leak or complaint would cost more than one sprint. With engineers I showed the schema change was small (one new field type, one filter).
- What I lost. The PM refused to drop user identity entirely, because returning-user personalization mattered to them. I conceded that point and we settled on a random ID that resets every 30 days, which still prevented long-term linking of one person's searches.
- Resolution. Agreed on the prototype design, with the PM keeping a path to expand if ranking metrics needed it.
Result
State measurable results you can stand behind. Illustrative numbers to replace with your own: 100% of ranking events shipped without raw text; in the A/B test (half of users on the old logging design, half on the new) click-through on the top result was 31.0% versus 30.8%, a gap too small to matter (with an illustrative 100,000 users per arm the standard error of the difference is about 0.2 points, so a 0.2-point gap is within noise: the test shows no detectable harm at that size, not proof of zero effect); and the launch slipped 3 days. If you cannot measure the effect, say so and describe what you checked.
What I would do differently
Involve the team before the design doc was finished, so the conversation would have been about options rather than a review comment.
Telling it well
Use "I" for your actions, show one concrete piece of evidence, name what you gave up as a compromise, and include a case where you lost part of the argument and what you did next.
Unlock Full Question Bank
Get access to all Privacy by Design and Default interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.