Data Security: Scenario-Based Questions
60. How do you handle sensitive data in applications, including masking, encryption, and compliance?
Sensitive data like PII, financial records, or medical info must be handled with care. Leaks or misuse can lead to legal penalties and reputational harm. A robust data protection strategy includes both technical and procedural controls.
🔐 Data Classification & Risk Assessment
- Classify data as public, internal, confidential, or restricted.
- Identify sensitive fields (e.g., SSN, credit card, health info).
- Apply stricter controls to high-risk datasets and flows.
🧊 Encryption at Rest & In Transit
- At Rest: Use AES-256 via KMS/CloudHSM for DBs, object stores, backups.
- In Transit: Enforce TLS 1.2+ across APIs, interservice calls, UIs.
- Key Rotation: Schedule key rotation policies (monthly/yearly).
🫥 Masking & Redaction
- Mask data in logs, dashboards, and staging environments.
- Apply tokenization or format-preserving encryption (FPE) for analytics access.
- Use role-based masking — e.g., partial vs full SSN based on user role.
✅ Auditing & Monitoring
- Track access to sensitive tables or blobs — log and alert on anomalies.
- Use tools like AWS Macie, GCP DLP to scan for sensitive data exposure.
- Maintain audit trails of who accessed or modified sensitive info.
📄 Compliance & Legal Considerations
- Follow frameworks: GDPR, HIPAA, SOC 2, PCI-DSS.
- Allow user-initiated deletions (right to be forgotten).
- Use data retention policies aligned with legal requirements.
🚫 Common Pitfalls
- Logging raw sensitive data (e.g., request payloads, query params).
- Over-permissive access to production DBs or S3 buckets.
- Encrypting data but leaving keys exposed in source code.
📌 Final Insight
Data protection is a shared responsibility — combining application design, infrastructure controls, and policy enforcement. Handling sensitive data well builds customer trust and regulatory resilience.