SOC2 Type II Compliance
Trust Service Criteria (TSC)
1. Security (Common Criteria - CC)
| Control |
Requirement |
Implementation |
| CC1.1 |
COSO principles |
Documented security policies |
| CC2.1 |
Information communication |
Security awareness training |
| CC3.1 |
Risk assessment |
Annual risk assessment process |
| CC5.1 |
Control activities |
Technical + administrative controls |
| CC6.1 |
Logical access |
RBAC, MFA, least privilege |
| CC6.2 |
Auth mechanisms |
SSO, password policy, key rotation |
| CC6.3 |
Access revocation |
Automated deprovisioning |
| CC7.1 |
Threat detection |
IDS/IPS, SIEM, vulnerability scanning |
| CC7.2 |
System monitoring |
Real-time alerting, log aggregation |
| CC7.3 |
Incident evaluation |
Severity classification, escalation |
| CC7.4 |
Incident response |
Documented IR plan, tabletop exercises |
| CC8.1 |
Change management |
PR review, CI/CD gates, rollback plan |
| CC9.1 |
Risk mitigation |
Business continuity, DR plan |
2. Availability (A)
3. Processing Integrity (PI)
4. Confidentiality (C)
5. Privacy (P)
Access Control Checklist
Authentication
// MFA enforcement middleware
async function requireMFA(req: Request, res: Response, next: NextFunction) {
const user = req.user;
if (!user) return res.status(401).json({ error: 'Unauthenticated' });
if (!user.mfaVerified) {
await auditLog({
action: 'auth.mfa.required',
actor: user.id,
resource: req.path,
result: 'blocked',
});
return res.status(403).json({ error: 'MFA verification required' });
}
next();
}
Authorization (RBAC)
interface Permission {
resource: string;
action: 'read' | 'write' | 'delete' | 'admin';
}
interface Role {
name: string;
permissions: Permission[];
}
function checkPermission(user: User, resource: string, action: string): boolean {
const role = getRoleByName(user.role);
const hasPermission = role.permissions.some(
(p) => p.resource === resource && p.action === action
);
auditLog({
action: `authz.${action}.${hasPermission ? 'granted' : 'denied'}`,
actor: user.id,
resource,
});
return hasPermission;
}
Access Review Checklist
Audit Logging Requirements
What to Log (ZORUNLU)
| Event Category |
Examples |
Retention |
| Authentication |
Login, logout, MFA, password reset |
1 yil |
| Authorization |
Permission grants, denials, role changes |
1 yil |
| Data access |
PII reads, exports, downloads |
1 yil |
| Data modification |
Create, update, delete operations |
1 yil |
| System events |
Config changes, deployments, restarts |
1 yil |
| Admin actions |
User management, policy changes |
3 yil |
Log Format
interface AuditLogEntry {
id: string; // UUID
timestamp: string; // ISO 8601
action: string; // 'user.login.success'
actor: {
id: string;
email: string;
ip: string;
userAgent: string;
};
resource: {
type: string; // 'user', 'document', 'config'
id: string;
name?: string;
};
result: 'success' | 'failure' | 'error';
details?: Record<string, unknown>;
correlationId?: string; // Request tracing
}
async function writeAuditLog(entry: AuditLogEntry): Promise<void> {
// Append-only, tamper-evident storage
await auditStore.append({
...entry,
hash: computeHash(entry), // Chain hash for integrity
});
}
Anti-Patterns
| Anti-Pattern |
Neden Yanlis |
Dogru Yol |
| Logging PII in plaintext |
Data exposure riski |
Mask/hash sensitive fields |
| Mutable audit logs |
Tampering riski |
Append-only, immutable store |
| No correlation ID |
Trace edilemez |
Her request'e UUID ata |
| Missing failure logs |
Saldiri tespiti zorlasiyor |
Basarisiz denemeleri de logla |
| Client-side only logging |
Manipule edilebilir |
Server-side zorunlu |
Change Management
Change Request Template
## Change Request
**Requester:** [isim]
**Date:** [tarih]
**Priority:** [P0-P3]
**Type:** [Standard | Emergency | Normal]
### Description
[Ne degisecek]
### Impact Assessment
- Affected systems: [liste]
- Affected users: [kac kisi, hangi roller]
- Risk level: [Low | Medium | High | Critical]
- Rollback plan: [nasil geri alinir]
### Approval
- [ ] Engineering lead
- [ ] Security review (High/Critical risk)
- [ ] Business owner (user-facing changes)
### Implementation
- [ ] Changes tested in staging
- [ ] Monitoring dashboards checked
- [ ] Rollback procedure verified
- [ ] Post-deployment verification
CI/CD Gates
# SOC2 compliant pipeline
deployment:
stages:
- lint-and-test
- security-scan
- code-review-approval # Min 1 reviewer
- staging-deploy
- staging-verification
- production-approval # Manual gate
- production-deploy
- post-deploy-verification
rules:
- require_code_review: true
- require_passing_tests: true
- require_security_scan: true
- no_direct_push_to_main: true
- branch_protection: true
Incident Response Plan
Severity Classification
| Severity |
Definition |
Response Time |
Examples |
| SEV-1 |
Service down, data breach |
15 min |
Production outage, unauthorized access |
| SEV-2 |
Major degradation |
1 saat |
Feature broken, performance issue |
| SEV-3 |
Minor impact |
4 saat |
Non-critical bug, cosmetic issue |
| SEV-4 |
No user impact |
Next business day |
Internal tool issue |
Response Workflow
1. DETECT → Monitoring alert / user report
2. TRIAGE → Classify severity, assign IC (Incident Commander)
3. CONTAIN → Stop the bleeding (isolate, rollback, block)
4. ERADICATE → Root cause fix
5. RECOVER → Restore normal operations
6. REVIEW → Post-incident review within 48 saat
7. IMPROVE → Action items tracked to completion
Post-Incident Review Template
## Post-Incident Review
**Incident:** [INC-XXXX]
**Date:** [tarih]
**Duration:** [suresi]
**Severity:** [SEV-1/2/3/4]
**IC:** [isim]
### Timeline
- HH:MM - Event detected
- HH:MM - IC assigned
- HH:MM - Root cause identified
- HH:MM - Fix deployed
- HH:MM - Service restored
### Root Cause
[Detayli aciklama]
### Impact
- Users affected: [sayi]
- Duration: [sure]
- Data impact: [varsa]
### Action Items
- [ ] [Action 1] - Owner: [isim] - Due: [tarih]
- [ ] [Action 2] - Owner: [isim] - Due: [tarih]
### Lessons Learned
[Ne ogrendi]
Evidence Collection Guide
Continuous Evidence Collection
| Evidence Type |
Source |
Frequency |
Tool |
| Access reviews |
IAM provider |
Quarterly |
Okta/Auth0 export |
| Change logs |
Git, CI/CD |
Continuous |
GitHub audit log |
| Security scans |
SAST/DAST |
Per deploy |
Snyk, SonarQube |
| Penetration tests |
External auditor |
Annual |
Report PDF |
| Training records |
LMS |
Annual |
Completion certs |
| Incident reports |
Incident tracker |
Per incident |
PagerDuty, Jira |
| Backup tests |
DR runbook |
Quarterly |
Restore verification |
| Uptime metrics |
Monitoring |
Continuous |
Datadog, Grafana |
| Vulnerability patches |
Dependency manager |
Continuous |
Dependabot, Renovate |
Evidence Automation
// Automated evidence collector
async function collectMonthlyEvidence(): Promise<EvidencePackage> {
const [accessLogs, changeLog, securityScans, uptimeMetrics] = await Promise.all([
fetchAccessReviewReport(),
fetchGitChangeLog(),
fetchSecurityScanResults(),
fetchUptimeMetrics(),
]);
return {
period: getCurrentMonth(),
accessReview: accessLogs,
changeManagement: changeLog,
securityScanning: securityScans,
availability: uptimeMetrics,
generatedAt: new Date().toISOString(),
};
}
Common SOC2 Findings & Fixes
| Finding |
Risk |
Fix |
| No MFA for admin accounts |
High |
Enable MFA for all privileged users |
| Missing access reviews |
Medium |
Implement quarterly review process |
| No encryption at rest |
High |
Enable disk/database encryption |
| Inadequate logging |
Medium |
Implement centralized audit logging |
| No change management |
High |
Require PR reviews, approval gates |
| Missing incident response plan |
High |
Document and test IR procedures |
| No vulnerability scanning |
Medium |
Add SAST/DAST to CI/CD |
| Shared service accounts |
Medium |
Individual accounts with RBAC |
| No backup verification |
Medium |
Quarterly restore tests |
| Missing security training |
Low |
Annual security awareness program |
SOC2 Readiness Checklist
Phase 1: Gap Assessment (2-4 hafta)
Phase 2: Remediation (2-6 ay)
Phase 3: Type I Audit (1-2 ay)
Phase 4: Type II Audit (6-12 ay observation)
1---2name: soc2-compliance3description: SOC2 Type II compliance - Trust Service Criteria, access controls, audit logging, change management, incident response, evidence collection4---56# SOC2 Type II Compliance78## Trust Service Criteria (TSC)910### 1. Security (Common Criteria - CC)1112| Control | Requirement | Implementation |13|---------|-------------|----------------|14| CC1.1 | COSO principles | Documented security policies |15| CC2.1 | Information communication | Security awareness training |16| CC3.1 | Risk assessment | Annual risk assessment process |17| CC5.1 | Control activities | Technical + administrative controls |18| CC6.1 | Logical access | RBAC, MFA, least privilege |19| CC6.2 | Auth mechanisms | SSO, password policy, key rotation |20| CC6.3 | Access revocation | Automated deprovisioning |21| CC7.1 | Threat detection | IDS/IPS, SIEM, vulnerability scanning |22| CC7.2 | System monitoring | Real-time alerting, log aggregation |23| CC7.3 | Incident evaluation | Severity classification, escalation |24| CC7.4 | Incident response | Documented IR plan, tabletop exercises |25| CC8.1 | Change management | PR review, CI/CD gates, rollback plan |26| CC9.1 | Risk mitigation | Business continuity, DR plan |2728### 2. Availability (A)2930- [ ] SLA definitions (99.9%, 99.99%)31- [ ] Uptime monitoring (health checks, synthetic monitoring)32- [ ] Disaster recovery plan tested annually33- [ ] Capacity planning documented34- [ ] Failover procedures tested35- [ ] Backup verification (restore tests quarterly)3637### 3. Processing Integrity (PI)3839- [ ] Input validation on all data entry points40- [ ] Data processing accuracy checks41- [ ] Error handling and correction procedures42- [ ] Output reconciliation43- [ ] Transaction logging with checksums4445### 4. Confidentiality (C)4647- [ ] Data classification policy (Public, Internal, Confidential, Restricted)48- [ ] Encryption at rest (AES-256)49- [ ] Encryption in transit (TLS 1.2+)50- [ ] Key management procedures (rotation, revocation)51- [ ] Confidential data access logging52- [ ] NDA tracking for third parties5354### 5. Privacy (P)5556- [ ] Privacy notice published57- [ ] Consent collection mechanism58- [ ] Data subject request handling (30 gun)59- [ ] Data retention and disposal schedule60- [ ] Third-party data sharing agreements6162## Access Control Checklist6364### Authentication6566```typescript67// MFA enforcement middleware68async function requireMFA(req: Request, res: Response, next: NextFunction) {69 const user = req.user;70 if (!user) return res.status(401).json({ error: 'Unauthenticated' });7172 if (!user.mfaVerified) {73 await auditLog({74 action: 'auth.mfa.required',75 actor: user.id,76 resource: req.path,77 result: 'blocked',78 });79 return res.status(403).json({ error: 'MFA verification required' });80 }81 next();82}83```8485### Authorization (RBAC)8687```typescript88interface Permission {89 resource: string;90 action: 'read' | 'write' | 'delete' | 'admin';91}9293interface Role {94 name: string;95 permissions: Permission[];96}9798function checkPermission(user: User, resource: string, action: string): boolean {99 const role = getRoleByName(user.role);100 const hasPermission = role.permissions.some(101 (p) => p.resource === resource && p.action === action102 );103104 auditLog({105 action: `authz.${action}.${hasPermission ? 'granted' : 'denied'}`,106 actor: user.id,107 resource,108 });109110 return hasPermission;111}112```113114### Access Review Checklist115116- [ ] Quarterly access reviews for all systems117- [ ] Terminated employee access revoked within 24 hours118- [ ] Privileged access requires manager approval119- [ ] Service account inventory maintained120- [ ] API key rotation schedule (90 gun max)121- [ ] SSH key inventory and rotation122123## Audit Logging Requirements124125### What to Log (ZORUNLU)126127| Event Category | Examples | Retention |128|---------------|----------|-----------|129| Authentication | Login, logout, MFA, password reset | 1 yil |130| Authorization | Permission grants, denials, role changes | 1 yil |131| Data access | PII reads, exports, downloads | 1 yil |132| Data modification | Create, update, delete operations | 1 yil |133| System events | Config changes, deployments, restarts | 1 yil |134| Admin actions | User management, policy changes | 3 yil |135136### Log Format137138```typescript139interface AuditLogEntry {140 id: string; // UUID141 timestamp: string; // ISO 8601142 action: string; // 'user.login.success'143 actor: {144 id: string;145 email: string;146 ip: string;147 userAgent: string;148 };149 resource: {150 type: string; // 'user', 'document', 'config'151 id: string;152 name?: string;153 };154 result: 'success' | 'failure' | 'error';155 details?: Record<string, unknown>;156 correlationId?: string; // Request tracing157}158159async function writeAuditLog(entry: AuditLogEntry): Promise<void> {160 // Append-only, tamper-evident storage161 await auditStore.append({162 ...entry,163 hash: computeHash(entry), // Chain hash for integrity164 });165}166```167168### Anti-Patterns169170| Anti-Pattern | Neden Yanlis | Dogru Yol |171|-------------|-------------|-----------|172| Logging PII in plaintext | Data exposure riski | Mask/hash sensitive fields |173| Mutable audit logs | Tampering riski | Append-only, immutable store |174| No correlation ID | Trace edilemez | Her request'e UUID ata |175| Missing failure logs | Saldiri tespiti zorlasiyor | Basarisiz denemeleri de logla |176| Client-side only logging | Manipule edilebilir | Server-side zorunlu |177178## Change Management179180### Change Request Template181182```markdown183## Change Request184185**Requester:** [isim]186**Date:** [tarih]187**Priority:** [P0-P3]188**Type:** [Standard | Emergency | Normal]189190### Description191[Ne degisecek]192193### Impact Assessment194- Affected systems: [liste]195- Affected users: [kac kisi, hangi roller]196- Risk level: [Low | Medium | High | Critical]197- Rollback plan: [nasil geri alinir]198199### Approval200- [ ] Engineering lead201- [ ] Security review (High/Critical risk)202- [ ] Business owner (user-facing changes)203204### Implementation205- [ ] Changes tested in staging206- [ ] Monitoring dashboards checked207- [ ] Rollback procedure verified208- [ ] Post-deployment verification209```210211### CI/CD Gates212213```yaml214# SOC2 compliant pipeline215deployment:216 stages:217 - lint-and-test218 - security-scan219 - code-review-approval # Min 1 reviewer220 - staging-deploy221 - staging-verification222 - production-approval # Manual gate223 - production-deploy224 - post-deploy-verification225226 rules:227 - require_code_review: true228 - require_passing_tests: true229 - require_security_scan: true230 - no_direct_push_to_main: true231 - branch_protection: true232```233234## Incident Response Plan235236### Severity Classification237238| Severity | Definition | Response Time | Examples |239|----------|-----------|--------------|---------|240| SEV-1 | Service down, data breach | 15 min | Production outage, unauthorized access |241| SEV-2 | Major degradation | 1 saat | Feature broken, performance issue |242| SEV-3 | Minor impact | 4 saat | Non-critical bug, cosmetic issue |243| SEV-4 | No user impact | Next business day | Internal tool issue |244245### Response Workflow246247```2481. DETECT → Monitoring alert / user report2492. TRIAGE → Classify severity, assign IC (Incident Commander)2503. CONTAIN → Stop the bleeding (isolate, rollback, block)2514. ERADICATE → Root cause fix2525. RECOVER → Restore normal operations2536. REVIEW → Post-incident review within 48 saat2547. IMPROVE → Action items tracked to completion255```256257### Post-Incident Review Template258259```markdown260## Post-Incident Review261262**Incident:** [INC-XXXX]263**Date:** [tarih]264**Duration:** [suresi]265**Severity:** [SEV-1/2/3/4]266**IC:** [isim]267268### Timeline269- HH:MM - Event detected270- HH:MM - IC assigned271- HH:MM - Root cause identified272- HH:MM - Fix deployed273- HH:MM - Service restored274275### Root Cause276[Detayli aciklama]277278### Impact279- Users affected: [sayi]280- Duration: [sure]281- Data impact: [varsa]282283### Action Items284- [ ] [Action 1] - Owner: [isim] - Due: [tarih]285- [ ] [Action 2] - Owner: [isim] - Due: [tarih]286287### Lessons Learned288[Ne ogrendi]289```290291## Evidence Collection Guide292293### Continuous Evidence Collection294295| Evidence Type | Source | Frequency | Tool |296|--------------|--------|-----------|------|297| Access reviews | IAM provider | Quarterly | Okta/Auth0 export |298| Change logs | Git, CI/CD | Continuous | GitHub audit log |299| Security scans | SAST/DAST | Per deploy | Snyk, SonarQube |300| Penetration tests | External auditor | Annual | Report PDF |301| Training records | LMS | Annual | Completion certs |302| Incident reports | Incident tracker | Per incident | PagerDuty, Jira |303| Backup tests | DR runbook | Quarterly | Restore verification |304| Uptime metrics | Monitoring | Continuous | Datadog, Grafana |305| Vulnerability patches | Dependency manager | Continuous | Dependabot, Renovate |306307### Evidence Automation308309```typescript310// Automated evidence collector311async function collectMonthlyEvidence(): Promise<EvidencePackage> {312 const [accessLogs, changeLog, securityScans, uptimeMetrics] = await Promise.all([313 fetchAccessReviewReport(),314 fetchGitChangeLog(),315 fetchSecurityScanResults(),316 fetchUptimeMetrics(),317 ]);318319 return {320 period: getCurrentMonth(),321 accessReview: accessLogs,322 changeManagement: changeLog,323 securityScanning: securityScans,324 availability: uptimeMetrics,325 generatedAt: new Date().toISOString(),326 };327}328```329330## Common SOC2 Findings & Fixes331332| Finding | Risk | Fix |333|---------|------|-----|334| No MFA for admin accounts | High | Enable MFA for all privileged users |335| Missing access reviews | Medium | Implement quarterly review process |336| No encryption at rest | High | Enable disk/database encryption |337| Inadequate logging | Medium | Implement centralized audit logging |338| No change management | High | Require PR reviews, approval gates |339| Missing incident response plan | High | Document and test IR procedures |340| No vulnerability scanning | Medium | Add SAST/DAST to CI/CD |341| Shared service accounts | Medium | Individual accounts with RBAC |342| No backup verification | Medium | Quarterly restore tests |343| Missing security training | Low | Annual security awareness program |344345## SOC2 Readiness Checklist346347### Phase 1: Gap Assessment (2-4 hafta)348349- [ ] Current state documentation350- [ ] Policy inventory351- [ ] Control gap identification352- [ ] Remediation roadmap353354### Phase 2: Remediation (2-6 ay)355356- [ ] Policies written and approved357- [ ] Technical controls implemented358- [ ] Monitoring and alerting configured359- [ ] Evidence collection automated360- [ ] Employee training completed361362### Phase 3: Type I Audit (1-2 ay)363364- [ ] Point-in-time assessment365- [ ] Control design evaluation366- [ ] Report received367368### Phase 4: Type II Audit (6-12 ay observation)369370- [ ] Operating effectiveness tested371- [ ] Evidence provided for observation period372- [ ] Exceptions documented and remediated373- [ ] Final report received