We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
This idea carries a full system design question on its own. Each walks through the full answer.
System Design Masterclass · Security Architecture
Free preview: the first 2 parts of this 6-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Security Architecture
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
After discovering unauthorized data access, the incident response team asked the obvious question: "Who accessed this data, when, and from where?" The answer was devastating. Nobody knew. The application logged errors and performance metrics but not security events. There were no records of who logged in, who accessed sensitive resources, who changed permissions, or who exported data.
Without audit logs, the team could not determine the scope of the breach, which users were affected, or how the attacker got in. The company had to assume the worst and notify all 2 million users, a decision that cost $4.5 million in notification expenses and destroyed customer trust. If they had audit logs, the scope might have been limited to 200 affected accounts.
Equifax's 2017 breach investigation was hampered by the same problem. The attackers operated undetected for 76 days because security event logging was fragmented and incomplete. Contrast that with GitHub's 2022 token incident where their audit logs enabled them to identify exactly which repositories were accessed, by which tokens, within hours.
Security audit logging is NOT the same as application logging. Application logs capture errors, performance metrics, and debug information. Security audit logs specifically record who did what to which resource, when, and whether it was allowed.
Security events you must capture:
| Event Category | What to Log | Why It Matters |
|---|---|---|
| Authentication | Login success/failure, logout, password change, MFA enrollment/bypass, session creation | Detect brute force, credential stuffing, unauthorized access |
| Authorization | Access granted/denied, permission changes, role assignments | Detect privilege escalation, unauthorized permission grants |
| Data access | Who read/modified/deleted sensitive data | Scope a breach: exactly which records were accessed |
| Admin actions | User creation/deletion, config changes, deployments | Detect insider threats, unauthorized config changes |
| System events | Service start/stop, certificate rotation, key usage, backup operations | Detect tampering with infrastructure |
Every log entry must contain these fields:
| Field | Format | Example |
|---|---|---|
| Timestamp | ISO 8601, UTC, millisecond precision | 2026-04-04T10:23:45.123Z |
| Actor | Identifier with namespace | user:alice@company.com or service:payment-api |
| Action | Structured verb with category | auth:login_failed, data:read, admin:role_changed |
| Resource | Full resource path | /api/users/123, database:customers.pii_table |
Tamper protection is non-negotiable. If an attacker can delete audit logs to cover their tracks, the logs are worthless. Write to append-only storage: S3 with Object Lock (WORM mode), CloudWatch Logs (cannot delete individual entries), or immutable Azure Blob storage. Forward logs to a separate system (SIEM) that the application has no write or delete access to.
Retention requirements by compliance framework:
| Framework | Minimum Retention | Who Must Comply |
|---|---|---|
| PCI-DSS | 1 year (3 months immediately accessible) | Anyone processing payment cards |
| SOX | 7 years | Publicly traded companies in the US |
| HIPAA | 6 years | Healthcare and related entities |
| GDPR | Varies (proportional, typically 1-3 years) | Organizations handling EU personal data |
| SOC 2 | 1 year minimum | SaaS companies serving enterprise |
| Outcome |
| Enumerated result |
success, denied, error |
| Context | Request metadata | IP: 203.0.113.42, device: Chrome/120, session: sess_abc |
| Request ID | Correlation identifier | req_7f3a2b (ties to distributed trace) |