Privacy by Design
7 Foundational Principles (Ann Cavoukian)
| # |
Principle |
In practice |
| 1 |
Proactive not reactive |
Build privacy in from the start; don't bolt on after |
| 2 |
Privacy as the default |
Default settings protect privacy; users opt IN to sharing |
| 3 |
Privacy embedded into design |
Not an add-on; integral to system architecture |
| 4 |
Full functionality (positive-sum) |
Privacy AND security AND functionality — not zero-sum |
| 5 |
End-to-end security |
Data protected throughout full lifecycle |
| 6 |
Visibility and transparency |
Openness about policies and practices |
| 7 |
Respect for user privacy |
User-centric: keep it user-friendly and privacy-protective |
DPIA Trigger Checklist
A Data Protection Impact Assessment is required when processing is "likely to result in a high risk." Conduct a DPIA if 2 or more apply:
DPIA Process
Step 1: Describe the Processing
- What personal data is collected?
- Who are the data subjects?
- What is the purpose and legal basis?
- Who are the recipients (internal and third parties)?
- Where is data stored and transferred?
- How long is it retained?
Step 2: Assess Necessity and Proportionality
- Is the processing necessary for the stated purpose?
- Is there a less privacy-invasive way to achieve the same goal?
- Is the legal basis appropriate and documented?
- Are data subjects adequately informed?
Step 3: Identify and Assess Risks
| Risk |
Likelihood (1-5) |
Severity (1-5) |
Score |
Mitigation |
| Unauthorized access |
|
|
|
|
| Data breach / exposure |
|
|
|
|
| Excessive data collection |
|
|
|
|
| Purpose creep |
|
|
|
|
| Inaccurate data leading to harm |
|
|
|
|
Step 4: Identify Mitigations
- Technical controls (encryption, access control, pseudonymization)
- Organizational controls (policies, training, contracts)
- Design changes (data minimization, shorter retention)
Step 5: Consult DPO (if applicable)
- If residual risk remains high after mitigation → consult supervisory authority before processing
Step 6: Document and Sign Off
- Document findings and decisions
- Obtain approval from data controller / DPO
- Schedule review date (at least when processing changes materially)
Data Minimization Techniques
| Technique |
Description |
Example |
| Collection limitation |
Only collect what's needed for the purpose |
Don't collect DOB if only age verification needed |
| Retention limitation |
Delete when no longer needed |
Auto-purge logs after 90 days |
| Access limitation |
Restrict who can see data |
Mask PAN except last 4 digits for support agents |
| Aggregation |
Use aggregate stats instead of individual records |
Cohort analytics instead of user-level tracking |
| Pseudonymization |
Replace identifiers with tokens |
Replace email with user_id in analytics events |
| Anonymization |
Remove all identifying information |
Publish research data with k-anonymity applied |
Purpose Limitation Implementation
Definition
Data collected for Purpose A must not be used for Purpose B without either:
- A new, compatible purpose (assess compatibility — link to original)
- Fresh consent for the new purpose
- A specific legal basis for the new purpose
Compatibility Assessment Factors
- Link between original and new purpose
- Context of collection (subject's reasonable expectations)
- Nature of data (sensitive data → stricter)
- Consequences for data subjects
- Existence of safeguards
Technical Enforcement
- Tag data records with collection purpose at ingestion
- Enforce purpose tags in data access layer (deny cross-purpose queries)
- Audit logs for all data access with purpose declared
Pseudonymization vs Anonymization
|
Pseudonymization |
Anonymization |
| Definition |
Replace identifiers; re-identification possible with key |
Remove all identifiers; re-identification not possible |
| Still personal data? |
Yes — GDPR still applies |
No — GDPR does not apply |
| Reversible? |
Yes (with key) |
No |
| Risk |
Key compromise = re-identification |
Residual inference risk |
| Use case |
Analytics, research with need for re-linking |
Publishing, open data, sharing |
| Techniques |
Tokenization, hashing with salt |
K-anonymity, l-diversity, differential privacy |
Privacy Risk Scoring Matrix
| Likelihood |
Low impact |
Medium impact |
High impact |
| High |
Medium risk |
High risk |
Critical risk |
| Medium |
Low risk |
Medium risk |
High risk |
| Low |
Negligible |
Low risk |
Medium risk |
Action by level:
- Critical: Do not proceed without DPA consultation + significant redesign
- High: Mandatory mitigation + DPIA sign-off
- Medium: Mitigate and document
- Low/Negligible: Document and monitor
Privacy Review Checklist for New Features
Before launching any feature that processes personal data:
Privacy Engineering Patterns
Data Masking
-- Display only last 4 digits of payment card
SELECT
customer_id,
CONCAT('****-****-****-', RIGHT(card_number, 4)) AS masked_card
FROM payments;
Pseudonymization with HMAC
import hmac, hashlib
def pseudonymize(email: str, secret_key: bytes) -> str:
return hmac.new(secret_key, email.encode(), hashlib.sha256).hexdigest()
Differential Privacy (concept)
Add calibrated noise to aggregate queries so individual records cannot be inferred:
- Laplace mechanism for numeric queries
- Randomized response for categorical data
- Budget tracking: each query consumes epsilon budget
Aggregation Instead of Individual Tracking
-- Instead of: SELECT user_id, page_views FROM sessions
-- Use:
SELECT
DATE_TRUNC('day', session_date) AS day,
COUNT(DISTINCT user_id) AS unique_visitors,
SUM(page_views) AS total_page_views
FROM sessions
GROUP BY 1;
1---2name: privacy-by-design3description: When to activate: privacy by design, PbD, DPIA, data minimization, purpose limitation, privacy impact assessment, privacy engineering, pseudonymization4---56# Privacy by Design78## 7 Foundational Principles (Ann Cavoukian)910| # | Principle | In practice |11|---|-----------|-------------|12| 1 | Proactive not reactive | Build privacy in from the start; don't bolt on after |13| 2 | Privacy as the default | Default settings protect privacy; users opt IN to sharing |14| 3 | Privacy embedded into design | Not an add-on; integral to system architecture |15| 4 | Full functionality (positive-sum) | Privacy AND security AND functionality — not zero-sum |16| 5 | End-to-end security | Data protected throughout full lifecycle |17| 6 | Visibility and transparency | Openness about policies and practices |18| 7 | Respect for user privacy | User-centric: keep it user-friendly and privacy-protective |1920## DPIA Trigger Checklist2122A Data Protection Impact Assessment is required when processing is "likely to result in a high risk." Conduct a DPIA if **2 or more** apply:2324- [ ] Systematic and extensive profiling or automated decision-making with legal effects25- [ ] Processing special category / sensitive data at scale26- [ ] Systematic monitoring of publicly accessible areas (CCTV, location tracking)27- [ ] New technology being deployed28- [ ] Processing data of vulnerable individuals (children, employees, patients)29- [ ] Matching or combining datasets beyond original collection purpose30- [ ] Large-scale processing of personal data31- [ ] Invisible processing (data not collected directly from subject)32- [ ] Cross-border data transfers to countries without adequacy decisions3334## DPIA Process3536### Step 1: Describe the Processing37- What personal data is collected?38- Who are the data subjects?39- What is the purpose and legal basis?40- Who are the recipients (internal and third parties)?41- Where is data stored and transferred?42- How long is it retained?4344### Step 2: Assess Necessity and Proportionality45- Is the processing necessary for the stated purpose?46- Is there a less privacy-invasive way to achieve the same goal?47- Is the legal basis appropriate and documented?48- Are data subjects adequately informed?4950### Step 3: Identify and Assess Risks5152| Risk | Likelihood (1-5) | Severity (1-5) | Score | Mitigation |53|------|-----------------|----------------|-------|------------|54| Unauthorized access | | | | |55| Data breach / exposure | | | | |56| Excessive data collection | | | | |57| Purpose creep | | | | |58| Inaccurate data leading to harm | | | | |5960### Step 4: Identify Mitigations61- Technical controls (encryption, access control, pseudonymization)62- Organizational controls (policies, training, contracts)63- Design changes (data minimization, shorter retention)6465### Step 5: Consult DPO (if applicable)66- If residual risk remains high after mitigation → consult supervisory authority before processing6768### Step 6: Document and Sign Off69- Document findings and decisions70- Obtain approval from data controller / DPO71- Schedule review date (at least when processing changes materially)7273## Data Minimization Techniques7475| Technique | Description | Example |76|-----------|-------------|---------|77| Collection limitation | Only collect what's needed for the purpose | Don't collect DOB if only age verification needed |78| Retention limitation | Delete when no longer needed | Auto-purge logs after 90 days |79| Access limitation | Restrict who can see data | Mask PAN except last 4 digits for support agents |80| Aggregation | Use aggregate stats instead of individual records | Cohort analytics instead of user-level tracking |81| Pseudonymization | Replace identifiers with tokens | Replace email with user_id in analytics events |82| Anonymization | Remove all identifying information | Publish research data with k-anonymity applied |8384## Purpose Limitation Implementation8586### Definition87Data collected for Purpose A must not be used for Purpose B without either:88- A new, compatible purpose (assess compatibility — link to original)89- Fresh consent for the new purpose90- A specific legal basis for the new purpose9192### Compatibility Assessment Factors931. Link between original and new purpose942. Context of collection (subject's reasonable expectations)953. Nature of data (sensitive data → stricter)964. Consequences for data subjects975. Existence of safeguards9899### Technical Enforcement100- Tag data records with collection purpose at ingestion101- Enforce purpose tags in data access layer (deny cross-purpose queries)102- Audit logs for all data access with purpose declared103104## Pseudonymization vs Anonymization105106| | Pseudonymization | Anonymization |107|-|-----------------|---------------|108| Definition | Replace identifiers; re-identification possible with key | Remove all identifiers; re-identification not possible |109| Still personal data? | **Yes** — GDPR still applies | **No** — GDPR does not apply |110| Reversible? | Yes (with key) | No |111| Risk | Key compromise = re-identification | Residual inference risk |112| Use case | Analytics, research with need for re-linking | Publishing, open data, sharing |113| Techniques | Tokenization, hashing with salt | K-anonymity, l-diversity, differential privacy |114115## Privacy Risk Scoring Matrix116117| Likelihood | Low impact | Medium impact | High impact |118|-----------|-----------|---------------|-------------|119| High | Medium risk | High risk | Critical risk |120| Medium | Low risk | Medium risk | High risk |121| Low | Negligible | Low risk | Medium risk |122123**Action by level:**124- Critical: Do not proceed without DPA consultation + significant redesign125- High: Mandatory mitigation + DPIA sign-off126- Medium: Mitigate and document127- Low/Negligible: Document and monitor128129## Privacy Review Checklist for New Features130131Before launching any feature that processes personal data:132133- [ ] Data minimization: only collecting what's needed?134- [ ] Legal basis identified and documented?135- [ ] Purpose documented and communicated to users?136- [ ] Retention period defined and enforced technically?137- [ ] Data encrypted at rest and in transit?138- [ ] Access controls applied (least privilege)?139- [ ] Third-party data sharing identified and contractually covered?140- [ ] DPIA completed (if high-risk processing)?141- [ ] User rights supported (access, deletion, portability)?142- [ ] Privacy notice updated to reflect new processing?143- [ ] Data breach response plan covers this new data type?144145## Privacy Engineering Patterns146147### Data Masking148```sql149-- Display only last 4 digits of payment card150SELECT151 customer_id,152 CONCAT('****-****-****-', RIGHT(card_number, 4)) AS masked_card153FROM payments;154```155156### Pseudonymization with HMAC157```python158import hmac, hashlib159def pseudonymize(email: str, secret_key: bytes) -> str:160 return hmac.new(secret_key, email.encode(), hashlib.sha256).hexdigest()161```162163### Differential Privacy (concept)164Add calibrated noise to aggregate queries so individual records cannot be inferred:165- Laplace mechanism for numeric queries166- Randomized response for categorical data167- Budget tracking: each query consumes epsilon budget168169### Aggregation Instead of Individual Tracking170```sql171-- Instead of: SELECT user_id, page_views FROM sessions172-- Use:173SELECT174 DATE_TRUNC('day', session_date) AS day,175 COUNT(DISTINCT user_id) AS unique_visitors,176 SUM(page_views) AS total_page_views177FROM sessions178GROUP BY 1;179```