GDPR, SOC 2 and PCI for Developers
On this page
Learning Objective
Translate privacy principles into engineering work: inventory personal data, minimize and retain it deliberately, build export and erasure workflows that reach every store, understand what SOC 2 and PCI DSS ask of an application team, and reduce compliance scope by design. This is engineering guidance, not legal advice.
Concept Explanation
Privacy regulation such as the European Union's General Data Protection Regulation, and similar laws in California and elsewhere, turns good data hygiene into legal obligations. The GDPR's principles read like an engineering checklist: collect data only for a stated purpose, collect no more than needed, keep it accurate, keep it no longer than necessary, protect it, and be able to demonstrate that you do. Article 25 calls this data protection by design and by default, which means privacy decisions are made when the feature is designed, not after a complaint. Work with your legal and privacy colleagues on the interpretation, and take responsibility for making the system able to do what they decide.
Everything starts with knowing what you hold. Build a data inventory that lists each kind of personal data, where it lives, why you collect it, the legal basis for processing, who can access it, how long you keep it, and which third parties receive it. The places are more numerous than the primary database: read replicas, backups, search indexes, caches, message queues, analytics warehouses, log files, error trackers, support tools, and exports on people's laptops. Mark personal data in code, for example with an attribute on entity properties naming its category, so tooling can find it, so logs can redact it, and so export and erasure can enumerate it. Minimization is the cheapest control: data you never collected cannot leak, be subpoenaed, or need erasing.
The rights of individuals become features. People may ask what data you hold, to receive a copy in a portable format, to correct it, to have it erased, or to object to certain processing, and the regulation generally expects a response within one month. Build these as workflows, not as one-off scripts: verify the requester's identity without collecting more data than needed, fan the request out to each module or service through a common interface, collect results or confirmations, and keep a record. Erasure has subtleties. Some data must be kept for legal reasons such as tax records, so erase or anonymize what you can and document the rest. Backups are commonly handled by letting them expire on schedule and making sure that a restore re-applies pending erasures. Derived data in search indexes, caches, and warehouses needs the same treatment, and event logs need the crypto-shredding approach of Day 121. Retention is the other half: a scheduled job should delete or anonymize data past its retention period, as a matter of routine.
Security frameworks overlap with privacy. A breach involving personal data must generally be reported to the regulator within 72 hours of discovery, which requires an incident process from Day 98 that can determine quickly what was exposed. SOC 2 is an attestation, produced by an independent auditor, about controls against the AICPA Trust Services Criteria: security, availability, processing integrity, confidentiality, and privacy. A Type I report describes the design of controls at a point in time, and Type II tests that they operated over a period, usually months. Customers in the business-to-business market often require it, and for developers it means evidence: access reviews, change management through pull requests and pipelines, logging, backups tested, vulnerability management, and incident records. The PCI Data Security Standard applies wherever payment card data is stored, processed, or transmitted, and its scope is the systems that touch that data. Version 4.0, published in 2022, retired the earlier version in March 2024, with many new requirements becoming mandatory in March 2025. The engineering answer is scope reduction, as Day 125 showed: use hosted fields or checkout so card data never reaches your systems, and your obligations shrink to a much smaller questionnaire.
| Obligation | Engineering response |
|---|---|
| Know what you hold | Data inventory, personal data marked in code |
| Minimize and limit purpose | Collect less, separate optional data, review new fields |
| Access, portability, erasure | Fan-out workflow to every module, store, and processor |
| Retention | Scheduled deletion or anonymization jobs |
| Breach notice within 72 hours | Detection, logging, and a rehearsed incident process |
| SOC 2 evidence | Pull request reviews, access reviews, logs, backup tests, ticket trail |
| PCI scope | Hosted payment fields so card data never enters your systems |
Worked Example: Marking Personal Data, a Subject Request Pipeline and a Retention Job
The code marks fields, exports and erases through per-module handlers, and enforces retention.
// Personal data is labelled where it is defined. Tooling reads the labels for logs, exports and audits.
[AttributeUsage(AttributeTargets.Property)]
public sealed class PersonalDataAttribute(string category, string purpose, int retentionDays) : Attribute
{
public string Category { get; } = category; // "contact", "identifier", "content", "financial"
public string Purpose { get; } = purpose;
public int RetentionDays { get; } = retentionDays;
}
public sealed class UserProfile
{
public Guid Id { get; set; }
[PersonalData("contact", "account communication", 730)] public string Email { get; set; } = "";
[PersonalData("identifier", "display in the product", 730)] public string DisplayName { get; set; } = "";
public DateTimeOffset CreatedAt { get; set; } // not personal on its own
}
// Every module that stores personal data implements the same contract, so a request reaches all of them.
public interface IDataSubjectHandler
{
string Module { get; }
Task<DataSubjectExport> ExportAsync(Guid userId, CancellationToken ct);
Task<ErasureReport> EraseAsync(Guid userId, CancellationToken ct); // erase or anonymize, and say what was kept and why
}public sealed class DataSubjectRequestService(IEnumerable<IDataSubjectHandler> handlers, AppDb db, IAuditLog audit)
{
public async Task<Guid> OpenAsync(Guid userId, RequestKind kind, CancellationToken ct)
{
var req = new DataSubjectRequest { UserId = userId, Kind = kind, ReceivedAt = DateTimeOffset.UtcNow, DueAt = DateTimeOffset.UtcNow.AddDays(30), Status = "open" };
db.DataSubjectRequests.Add(req);
db.Outbox.Add(OutboxMessage.From(new ProcessDataSubjectRequest(req.Id))); // runs in the background, tracked against the deadline
await db.SaveChangesAsync(ct);
await audit.WriteAsync("dsr.opened", userId, new { kind }, ct);
return req.Id;
}
public async Task ProcessAsync(Guid requestId, CancellationToken ct)
{
var req = await db.DataSubjectRequests.SingleAsync(r => r.Id == requestId, ct);
var results = new List<object>();
foreach (var h in handlers) // identity, tasks, billing, files, search, analytics...
results.Add(req.Kind == RequestKind.Export ? await h.ExportAsync(req.UserId, ct) : await h.EraseAsync(req.UserId, ct));
req.Status = "completed"; req.CompletedAt = DateTimeOffset.UtcNow; req.ResultJson = JsonSerializer.Serialize(results);
await db.SaveChangesAsync(ct);
await audit.WriteAsync("dsr.completed", req.UserId, new { req.Kind, modules = handlers.Select(h => h.Module) }, ct);
}
}
// Retention: a routine job removes what has outlived its purpose.
public async Task RunRetentionAsync(CancellationToken ct)
{
var cutoff = DateTimeOffset.UtcNow.AddDays(-730);
var stale = await db.UserProfiles.Where(u => u.IsDeactivated && u.DeactivatedAt < cutoff).Select(u => u.Id).ToListAsync(ct);
foreach (var id in stale) await requests.OpenAsync(id, RequestKind.Erase, ct); // reuse the same, tested erasure path
}// Logs are a personal data store too. Redact by convention before they are written.
public sealed class PersonalDataDestructuringPolicy : IDestructuringPolicy
{
public bool TryDestructure(object value, ILogEventPropertyValueFactory f, [NotNullWhen(true)] out LogEventPropertyValue? result)
{
var props = value.GetType().GetProperties().Where(p => p.GetCustomAttribute<PersonalDataAttribute>() is null)
.Select(p => new LogEventProperty(p.Name, f.CreatePropertyValue(p.GetValue(value)))); // labelled properties are left out
result = new StructureValue(props);
return true;
}
}SOC 2 evidence an engineering team produces almost automatically
Change management: every production change is a reviewed pull request with a passing pipeline (Day 83).
Access control: quarterly access review export from Entra ID, with removals recorded.
Logging: central logs retained for a defined period, alerts for privileged actions.
Availability: backup restore test results, disaster recovery exercises (Day 142).
Vulnerability mgmt: scanner results and remediation tickets within the agreed timelines (Day 137).
Incident response: the postmortems and drill records.The pipeline is the same one used for every request, including retention, so it gets exercised routinely. A workflow that runs only when a regulator's deadline is near tends to be broken when needed.
Real-World Examples
- In May 2023 Ireland's Data Protection Commission fined Meta 1.2 billion euros for transferring European users' data to the United States without adequate safeguards, the largest GDPR fine at the time. In 2021 Luxembourg's regulator fined Amazon 746 million euros over its advertising practices and consent. They show that enforcement can be large and applies to design decisions about where data flows and how consent is obtained.
- The Payment Card Industry Security Standards Council released version 4.0 of the PCI DSS in March 2022 and retired version 3.2.1 in March 2024, with future-dated requirements mandatory from March 2025. Organizations that redirected customers to a hosted payment page had far fewer requirements to meet than those whose systems handled card numbers, which is why scope reduction is the standard advice.
Review Questions & Answers
You cannot export, correct, erase, or protect data you do not know you have, and personal data spreads into replicas, logs, indexes, caches, and third-party tools. An inventory shows where each kind lives, why it is collected, and how long it is kept.
Backups are usually allowed to expire on their normal schedule, with a process to re-apply erasures after any restore, while derived copies such as search indexes, caches, and warehouses must be updated by the same erasure workflow. Data that must be kept for legal reasons is documented.
Type I assesses the design of controls at one point in time, while Type II tests whether they operated effectively over a period. Customers usually want Type II because it shows sustained practice.
Card numbers go directly from the customer's browser to the payment provider, so your servers never store, process, or transmit them. The systems that touch card data are the scope, and yours no longer do.